/* ============================================
   Cueboard - QuickLook Preview System
   SINGLE SOURCE OF TRUTH for all preview windows
   ============================================ */

/* Cue Type Color Variables */
:root {
    --type-video: #FF3B30;
    --type-photo: #34C759;
    --type-drone: #FFCC00;
    --type-graphics: #00C7BE;
    --type-voiceover: #007AFF;
    --type-audio: #32ADE6;
    --type-music: #AF52DE;
    --type-note: #FF9500;
    --type-location: #5856D6;
}

.cue-type-video {
    --cue-color: var(--type-video);
}

.cue-type-photo {
    --cue-color: var(--type-photo);
}

.cue-type-drone {
    --cue-color: var(--type-drone);
}

.cue-type-graphics {
    --cue-color: var(--type-graphics);
}

.cue-type-voiceover {
    --cue-color: var(--type-voiceover);
}

.cue-type-audio {
    --cue-color: var(--type-audio);
}

.cue-type-music {
    --cue-color: var(--type-music);
}

.cue-type-note {
    --cue-color: var(--type-note);
}

.cue-type-location {
    --cue-color: var(--type-location);
}

/* ============================================
   Base Preview Window Structure
   ============================================ */

.app-preview-window {
    background: #1C1C1E;
    /* iOS systemGray6 */
    margin: 16px;
    border-radius: 16px;
    border: 1px solid #2C2C2E;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    height: 320px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1;
}

/* ============================================
   Preview Window States
   ============================================ */

/* Transitioning state - used during expansion animation */
.app-preview-window.transitioning {
    opacity: 0 !important;
    transition: none !important;
    pointer-events: none !important;
}

/* Instant reveal state - used after expansion completes */
.app-preview-window.reveal-instant {
    opacity: 1 !important;
    transition: none !important;
}

/* Cloned state - used for full-screen expansion */
.app-preview-window.cloned {
    position: fixed !important;
    z-index: 10001 !important;
    margin: 0 !important;
    pointer-events: auto !important;
    max-width: none !important;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.app-preview-window.cloned.is-expanded {
    box-shadow: 0 50px 100px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Remove max-height constraint from content area when expanded */
.app-preview-window.cloned .preview-content {
    max-height: none !important;
}

/* ============================================
   Preview Backdrop (for expanded view)
   ============================================ */

.preview-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.preview-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* Scroll Lock Helper */
body.lock-scroll {
    overflow: hidden !important;
    height: 100vh !important;
    width: 100vw !important;
    position: fixed !important;
    overscroll-behavior: none !important;
}

/* ============================================
   Preview Header (Traffic Lights & Title)
   ============================================ */

.preview-header {
    height: 36px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: #2C2C2E;
    /* iOS systemGray5 */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    outline: none;
    transition: background 0.2s;
}

.preview-header:hover .traffic-lights .light {
    filter: brightness(1.2);
}

.preview-header:focus-visible {
    background: #3A3A3C;
    outline: 3px solid var(--primary-yellow);
    outline-offset: 0px;
    position: relative;
    z-index: 10;
    border-radius: 8px;
}

.preview-header:focus-visible .traffic-lights .light {
    filter: brightness(1.3);
}

.app-preview-window:has(.preview-header:focus-visible) {
    overflow: visible;
}

.traffic-lights {
    display: flex;
    gap: 8px;
    position: relative;
    z-index: 1;
}

.window-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: 500;
    color: #8E8E93;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45%;
    pointer-events: none;
}

@media (max-width: 480px) {
    .window-title {
        max-width: 45%;
    }
}

.light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.light.red {
    background: #FF5F56;
}

.light.yellow {
    background: #FFBD2E;
}

.light.green {
    background: #27C93F;
}

/* ============================================
   Preview Content Area (Scrollable Cue List)
   ============================================ */

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.preview-content::-webkit-scrollbar {
    width: 6px;
}

.preview-content::-webkit-scrollbar-thumb {
    background: #3A3A3C;
    border-radius: 3px;
}

/* ============================================
   Cue Rows (Individual Shot List Items)
   ============================================ */

.cue-row {
    padding: 3px 16px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
    outline: none;
}

.cue-row:focus-visible {
    background: rgba(231, 210, 0, 0.15);
    box-shadow: inset 0 0 0 2px var(--primary-yellow);
    border-radius: 6px;
}

.cue-row.completed .cue-title {
    text-decoration: line-through;
    text-decoration-thickness: 2.5px;
    color: #FFFFFF !important;
    opacity: 1;
}

.cue-row.completed .cue-icon {
    background-color: #FFFFFF !important;
}

.cue-row.completed .icon-circle {
    background-color: transparent !important;
}

.icon-circle {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: color-mix(in srgb, var(--cue-color, #FF3B30) 15%, transparent);
    transition: background-color 0.2s ease;
}

.cue-icon {
    width: 20px;
    height: 20px;
    background-color: var(--cue-color, #FF3B30);
    transition: background-color 0.2s ease;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.cue-text {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.cue-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    display: flex;
    align-items: center;
    color: var(--cue-color, #FF3B30);
    padding-top: 7px;
    transition: color 0.2s ease;
}

.cue-details {
    font-size: 12px;
    color: #8E8E93;
    line-height: 1.3;
    margin-top: 4px;
    padding-bottom: 4px;
}

/* More Items Indicator */
.more-items {
    padding: 12px 16px;
    font-size: 13px;
    font-style: italic;
    color: #8E8E93;
}

/* ============================================
   Context-Specific Variations
   ============================================ */

/* Template Detail Page Preview */
.template-preview-column .app-preview-window {
    margin: 0;
    height: auto;
    max-height: 600px;
}

.template-preview-column .preview-content {
    max-height: 540px;
}

/* Hover hint for template detail page */
.template-preview-column .preview-header::after {
    content: 'Click to expand';
    position: absolute;
    right: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.template-preview-column .preview-header:hover::after {
    opacity: 1;
}

/* Embedded Preview (Blog Posts & Content Pages) */
.embedded-template-container {
    margin: 25px 0;
    width: 100%;
    display: flex;
    justify-content: center;
}

.embedded-preview {
    width: 100%;
    max-width: 700px;
    min-height: 500px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.embedded-preview .preview-content {
    max-height: 600px;
    overflow-y: auto;
}

/* Hover hint for embedded templates */
.embedded-preview .preview-header::after {
    content: 'Click to expand';
    position: absolute;
    right: 16px;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.embedded-preview .preview-header:hover::after {
    opacity: 1;
}

/* Error state for missing templates */
.template-embed-error {
    padding: 32px;
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.3);
    border-radius: 12px;
    color: #ff3b30;
    text-align: center;
    margin: 32px 0;
}

/* ============================================
   Responsive Adjustments
   ============================================ */

@media (max-width: 1024px) {
    .template-preview-column .app-preview-window {
        max-height: 400px;
        max-width: 100%;
        width: 100%;
        margin: 0 auto;
    }

    .template-preview-column .preview-content {
        max-height: 340px;
    }

    /* Hide hover hint on mobile/tablet */
    .template-preview-column .preview-header::after {
        display: none;
    }
}

@media (max-width: 768px) {
    .embedded-preview {
        max-width: 100%;
        min-height: 400px;
    }

    .embedded-preview .preview-content {
        max-height: 500px;
    }

    .embedded-preview .preview-header::after {
        display: none;
    }
}