/* ==========================================================================
   BLUEPRINT TRACKER OVERLAY — Red Orb + Blueprint Progress Panel
   
   Activated ONLY when the user arrives at a target app via a Vision Board
   rocket-button launch (URL contains ?from=blueprint&bp_id=...&ms_id=...&task_id=...).
   
   Follows the same injection pattern as the Light overlay (light-overlay.css)
   but uses a red theme and positions at bottom-right.
   
   Version: 1.0.0
   ========================================================================== */

/* === RED ORB TRIGGER BUTTON ============================================= */
.blueprint-tracker-orb {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Red-hot gradient core */
    background: radial-gradient(circle at 40% 40%, #ff4444 0%, #cc0033 50%, #990022 100%);
    box-shadow:
        0 0 12px 3px rgba(255, 50, 50, 0.5),
        0 0 30px 8px rgba(255, 0, 50, 0.25),
        inset 0 1px 2px rgba(255, 150, 150, 0.35);
    
    /* Smooth entrance */
    animation: bpTrackerOrbPulse 2.5s ease-in-out infinite,
               bpTrackerOrbEntrance 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    transform: scale(0);
    
    transition: box-shadow 0.3s ease, transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    font-size: 0;
}

.blueprint-tracker-orb:hover {
    box-shadow:
        0 0 18px 5px rgba(255, 50, 50, 0.65),
        0 0 45px 12px rgba(255, 0, 50, 0.35),
        inset 0 1px 2px rgba(255, 150, 150, 0.45);
    transform: scale(1.08);
}

.blueprint-tracker-orb:active {
    transform: scale(0.95);
}

/* Icon inside the orb */
.blueprint-tracker-orb i {
    font-size: 18px;
    color: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
    pointer-events: none;
}

/* Small progress badge on the orb */
.blueprint-tracker-orb .bp-orb-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #1a1a2e;
    border: 2px solid #ff4444;
    color: #ff8888;
    font-size: 10px;
    font-weight: 700;
    font-family: 'Inter', 'SF Pro Display', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    pointer-events: none;
}

/* Pulse animation */
@keyframes bpTrackerOrbPulse {
    0%, 100% {
        box-shadow:
            0 0 12px 3px rgba(255, 50, 50, 0.5),
            0 0 30px 8px rgba(255, 0, 50, 0.25),
            inset 0 1px 2px rgba(255, 150, 150, 0.35);
    }
    50% {
        box-shadow:
            0 0 18px 5px rgba(255, 50, 50, 0.7),
            0 0 40px 12px rgba(255, 0, 50, 0.35),
            inset 0 1px 2px rgba(255, 150, 150, 0.5);
    }
}

/* Entrance bounce */
@keyframes bpTrackerOrbEntrance {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}


/* === OVERLAY PANEL ====================================================== */
.blueprint-tracker-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Backdrop */
    background: rgba(5, 5, 15, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    
    /* Transition */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.35s ease, visibility 0.35s ease;
}

.blueprint-tracker-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main panel card */
.blueprint-tracker-panel {
    position: relative;
    width: 92vw;
    max-width: 740px;
    max-height: 85vh;
    border-radius: 20px;
    overflow: hidden;
    
    /* Liquid glass dark */
    background: linear-gradient(145deg, rgba(20, 10, 15, 0.92), rgba(30, 15, 20, 0.88));
    border: 1px solid rgba(255, 60, 60, 0.2);
    box-shadow:
        0 24px 80px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(255, 50, 50, 0.12),
        inset 0 1px 0 rgba(255, 100, 100, 0.08);
    
    transform: translateY(20px) scale(0.96);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.blueprint-tracker-overlay.active .blueprint-tracker-panel {
    transform: translateY(0) scale(1);
}


/* === PANEL HEADER ======================================================= */
.bp-tracker-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid rgba(255, 60, 60, 0.15);
    background: rgba(255, 30, 30, 0.05);
}

.bp-tracker-header-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #ff3333 0%, #cc0033 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bp-tracker-header-icon i {
    font-size: 16px;
    color: #fff;
}

.bp-tracker-header-info {
    flex: 1;
    min-width: 0;
}

.bp-tracker-title {
    font-family: 'Inter', 'SF Pro Display', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bp-tracker-subtitle {
    font-family: 'Inter', 'SF Pro Display', sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 120, 120, 0.7);
    margin: 2px 0 0;
    line-height: 1.3;
}

.bp-tracker-close-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.bp-tracker-close-btn:hover {
    background: rgba(255, 50, 50, 0.2);
    color: #ff6666;
    border-color: rgba(255, 50, 50, 0.3);
}


/* === PROGRESS BAR ======================================================= */
.bp-tracker-progress-bar {
    height: 3px;
    background: rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
}

.bp-tracker-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff3333, #ff6644, #ff3333);
    background-size: 200% 100%;
    border-radius: 0 3px 3px 0;
    transition: width 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    width: 0%;
    animation: bpProgressShimmer 3s linear infinite;
}

@keyframes bpProgressShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}


/* === SCROLLABLE CONTENT ================================================= */
.bp-tracker-body {
    overflow-y: auto;
    max-height: calc(85vh - 120px);
    padding: 16px 20px 24px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 60, 60, 0.3) transparent;
}

.bp-tracker-body::-webkit-scrollbar {
    width: 5px;
}

.bp-tracker-body::-webkit-scrollbar-thumb {
    background: rgba(255, 60, 60, 0.3);
    border-radius: 3px;
}


/* === CURRENT TASK HIGHLIGHT ============================================= */
.bp-current-task-card {
    background: linear-gradient(135deg, rgba(255, 50, 50, 0.12), rgba(255, 50, 50, 0.04));
    border: 1px solid rgba(255, 60, 60, 0.25);
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
}

.bp-current-task-label {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #ff6644;
    margin: 0 0 6px;
}

.bp-current-task-desc {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
    margin: 0;
}

.bp-current-task-hint {
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    color: rgba(255, 180, 180, 0.6);
    margin: 6px 0 0;
    line-height: 1.4;
}


/* === MILESTONE CARDS ==================================================== */
.bp-milestones-section {
    margin-top: 4px;
}

.bp-milestones-label {
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.35);
    margin: 0 0 10px;
}

.bp-milestone-card {
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(255, 255, 255, 0.02);
    margin-bottom: 10px;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.bp-milestone-card.active {
    border-color: rgba(255, 60, 60, 0.3);
    background: rgba(255, 50, 50, 0.04);
}

.bp-milestone-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
}

.bp-milestone-card-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.bp-milestone-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.bp-milestone-status.status-done {
    background: #27ae60;
    box-shadow: 0 0 6px rgba(39, 174, 96, 0.4);
}

.bp-milestone-status.status-in_progress {
    background: #ff6644;
    box-shadow: 0 0 6px rgba(255, 102, 68, 0.4);
    animation: bpStatusPulse 2s ease-in-out infinite;
}

.bp-milestone-status.status-todo {
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.2);
}

.bp-milestone-status.status-blocked {
    background: #e74c3c;
}

.bp-milestone-status.status-failed {
    background: #8b0000;
}

/* Locked milestone status indicator */
.bp-milestone-status.status-locked {
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bp-milestone-status.status-locked i {
    font-size: 6px;
    color: rgba(255, 255, 255, 0.25);
}

/* Completed milestone status */
.bp-milestone-status.status-completed {
    background: #27ae60;
    box-shadow: 0 0 6px rgba(39, 174, 96, 0.4);
}

/* Locked milestone card */
.bp-milestone-card.locked {
    opacity: 0.45;
    pointer-events: none;
    filter: grayscale(0.4);
}

.bp-milestone-card.locked .bp-milestone-card-header {
    cursor: default;
}

.bp-milestone-card.locked .bp-milestone-title {
    color: rgba(255, 255, 255, 0.35);
}

@keyframes bpStatusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.bp-milestone-title {
    flex: 1;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bp-milestone-progress-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    flex-shrink: 0;
}

.bp-milestone-chevron {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.2);
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.bp-milestone-card.expanded .bp-milestone-chevron {
    transform: rotate(90deg);
}

/* Task list inside milestone */
.bp-milestone-tasks {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 0 14px;
}

.bp-milestone-card.expanded .bp-milestone-tasks {
    max-height: 600px;
    padding: 0 14px 10px;
}

.bp-task-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 7px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s ease;
}

.bp-task-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

.bp-task-item:first-child {
    border-top: none;
}

.bp-task-checkbox {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1.5px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    margin-top: 1px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 8px;
    color: transparent;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.bp-task-checkbox.toggleable {
    cursor: pointer;
}

.bp-task-item:hover .bp-task-checkbox.toggleable {
    border-color: rgba(255, 255, 255, 0.45);
}

.bp-task-item.done .bp-task-checkbox {
    background: #27ae60;
    border-color: #27ae60;
    color: #fff;
}

.bp-task-item.in_progress .bp-task-checkbox {
    border-color: #ff6644;
    background: rgba(255, 102, 68, 0.15);
}

.bp-task-item.current .bp-task-checkbox {
    border-color: #ff3333;
    background: rgba(255, 50, 50, 0.2);
    box-shadow: 0 0 6px rgba(255, 50, 50, 0.4);
}

/* When current task is completed — done styling wins */
.bp-task-item.current.done .bp-task-checkbox {
    background: #27ae60;
    border-color: #27ae60;
    color: #fff;
    box-shadow: 0 0 6px rgba(39, 174, 96, 0.4);
}

.bp-task-desc {
    font-family: 'Inter', sans-serif;
    font-size: 11.5px;
    color: rgba(255, 255, 255, 0.65);
    line-height: 1.45;
    flex: 1;
}

.bp-task-item.done .bp-task-desc {
    text-decoration: line-through;
    color: rgba(255, 255, 255, 0.3);
}

.bp-task-item.current .bp-task-desc {
    color: rgba(255, 200, 200, 0.95);
    font-weight: 600;
}

/* When current task is completed — strikethrough wins */
.bp-task-item.current.done .bp-task-desc {
    text-decoration: line-through;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 400;
}


/* === BACK-TO-BLUEPRINT BUTTON =========================================== */
.bp-tracker-back-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    margin-top: 16px;
    border: 1px solid rgba(255, 60, 60, 0.25);
    border-radius: 10px;
    background: linear-gradient(135deg, rgba(255, 50, 50, 0.12), rgba(255, 50, 50, 0.04));
    color: #ff6666;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bp-tracker-back-btn:hover {
    background: linear-gradient(135deg, rgba(255, 50, 50, 0.22), rgba(255, 50, 50, 0.1));
    border-color: rgba(255, 60, 60, 0.4);
    color: #ff8888;
    transform: translateY(-1px);
}

.bp-tracker-back-btn i {
    font-size: 11px;
}


/* === LOADING STATE ====================================================== */
.bp-tracker-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 14px;
}

.bp-tracker-loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 60, 60, 0.15);
    border-top-color: #ff4444;
    border-radius: 50%;
    animation: bpSpin 0.8s linear infinite;
}

@keyframes bpSpin {
    to { transform: rotate(360deg); }
}

.bp-tracker-loading-text {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
}


/* === ERROR STATE ======================================================== */
.bp-tracker-error {
    text-align: center;
    padding: 30px 20px;
}

.bp-tracker-error-text {
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: rgba(255, 120, 120, 0.7);
    margin: 0 0 12px;
}

.bp-tracker-retry-btn {
    padding: 8px 18px;
    border-radius: 8px;
    border: 1px solid rgba(255, 60, 60, 0.3);
    background: rgba(255, 50, 50, 0.1);
    color: #ff6666;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bp-tracker-retry-btn:hover {
    background: rgba(255, 50, 50, 0.2);
}


/* === RESPONSIVE ========================================================= */
@media (max-width: 640px) {
    .blueprint-tracker-orb {
        bottom: 18px;
        right: 18px;
        width: 42px;
        height: 42px;
    }
    
    .blueprint-tracker-orb i {
        font-size: 16px;
    }
    
    .blueprint-tracker-panel {
        width: 96vw;
        max-height: 88vh;
        border-radius: 16px;
    }
    
    .bp-tracker-body {
        max-height: calc(88vh - 120px);
        padding: 12px 14px 20px;
    }
}

/* === HIDDEN STATE (orb not visible when not routed from blueprint) ======= */
.blueprint-tracker-orb.hidden {
    display: none !important;
}
