/**
 * preview.css — Screen 5: Campaign Preview
 * Card CONTENT = welcome vCard (.vcard, .thumb, .gen-anim, etc)
 * Card SIZE + SELECTION = format/style pattern
 * Layout = space-evenly like format/style
 * Architecture: ZERO inline CSS. SSR. External only.
 */

/* ═══ VIEW-PREVIEW — scrollable section (same as view-library) ═══ */
#view-preview {
    overflow-y: auto !important;
    overflow-x: hidden;
    justify-content: flex-start !important;
}

/* Thin scrollbar (same as library) */
#view-preview::-webkit-scrollbar { width: 4px; }
#view-preview::-webkit-scrollbar-track { background: transparent; }
#view-preview::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.35); border-radius: 4px; }

/* ═══ LAYOUT — page container (same as lib-page) ═══ */
.preview-layout {
    padding: 80px 40px 160px;
    width: 100%;
}

/* ═══ CARDS GRID — flex-wrap (same as lib-grid mobile) ═══ */
.preview-cards-scroll {
    display: flex;
    flex-wrap: wrap;
    row-gap: 40px;
    column-gap: 24px;
    justify-content: center;
}

/* ═══ FRAMES WRAPPER — invisible, children float ═══ */
.preview-frames {
    display: contents;
}

/* ═══ FAB BUTTONS — exact clone of lib-fab-wrap ═══ */
.preview-fab-wrap {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    pointer-events: none;
}

.preview-fab-wrap .btn-start {
    pointer-events: auto;
    width: 280px;
    height: 56px;
    font-size: 13px;
    border-radius: 14px;
}

.preview-fab-wrap .preview-btn-adjust {
    pointer-events: auto;
    width: 280px;
}

.preview-fab-wrap .preview-btn-generate {
    pointer-events: auto;
}

/* Top FAB: Personalizar Escena */
.preview-fab-top {
    top: 80px;
}

/* Bottom FAB: Generar Video */
.preview-fab-bottom {
    bottom: 40px;
}

/* ═══ OPTION WRAPPER ═══ */
.preview-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
    transition: transform 0.2s ease;
    flex: none;
}

/* ═══ SELECT ROW (check + label) — always visible ═══ */
.preview-select-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
}

/* ═══ SINGLE CARD MODE — hide check, keep label ═══ */
.preview-layout:not(.multi-card) .preview-check {
    display: none;
}

/* ═══ CARD SIZE — Desktop ═══ */
/* Portrait: ~300px wide → 3 per row on ~1200px containers */
.preview-option .vcard.card-P .thumb {
    aspect-ratio: 9/16;
    width: min(45vh, 238px);
    height: auto;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Landscape: ~500px wide → 2 per row */
.preview-option .vcard.card-L .thumb {
    aspect-ratio: 16/9;
    height: min(45vh, 238px);
    width: auto;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ═══ SELECTION STATES ═══ */
/* Selected: bright border */
.preview-option.selected .vcard .thumb {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

/* Dim non-selected when has-selection (skip video-card — always full brightness) */
.preview-layout.has-selection .preview-option:not(.selected):not(.video-card) .vcard .thumb {
    opacity: 0.5;
}

.preview-layout.has-selection .preview-option:not(.selected):not(.video-card) .vcard .thumb img {
    opacity: 0.6;
}

/* Hover */
.preview-option:hover .vcard .thumb {
    border-color: rgba(255, 255, 255, 0.3);
}

/* ═══ SELECT BUTTON (checkmark) ═══ */
.preview-check {
    width: 19px;
    height: 19px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.preview-option:hover .preview-check {
    border-color: rgba(255, 255, 255, 0.4);
}

.preview-option.selected .preview-check {
    background: #fff;
    border-color: #fff;
}

.preview-check svg {
    width: 11px;
    height: 11px;
    color: transparent;
    transition: color 0.3s;
}

.preview-option.selected .preview-check svg {
    color: #000;
}

/* ═══ CARD LABEL (A / B) — styled as tag badge ═══ */
.preview-card-label {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    text-align: center;
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
}

.preview-option.selected .preview-card-label {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
}

/* ═══ P3: VIDEO-CARD (has video, click → video view, no selection) ═══ */
.preview-option.video-card {
    cursor: pointer;
}

.preview-option.video-card .preview-select-row {
    justify-content: center;
}

/* ═══ P3: PRE-SELECTED CARD (always highlighted, can't deselect) ═══ */
.preview-option.pre-selected {
    cursor: default;
}

.preview-option.pre-selected .preview-check {
    background: #fff;
    border-color: #fff;
}

.preview-option.pre-selected .preview-check svg {
    color: #000;
}

.preview-option.pre-selected .preview-card-label {
    color: rgba(255, 255, 255, 0.8);
    border-color: rgba(255, 255, 255, 0.3);
}

.preview-option.pre-selected .vcard .thumb {
    border-color: rgba(255, 255, 255, 0.5);
}

/* ═══ BUTTONS ═══ */
.preview-btn-adjust {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 56px;
    padding: 0 1.5rem;
    border-radius: 14px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(10, 10, 10, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

/* Animated gradient border via pseudo-element */
.preview-btn-adjust::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 14px;
    padding: 1px;
    background: linear-gradient(110deg, rgba(130, 190, 255, 0.7) 30%, rgba(255, 150, 190, 0.7) 70%);
    background-size: 200% 200%;
    animation: directorPastel 4s ease-in-out infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.preview-btn-adjust:hover {
    filter: brightness(1.3);
}

/* Text + SVG above particles */
.adjust-label {
    position: relative;
    z-index: 2;
    background: linear-gradient(110deg, rgba(130, 190, 255, 0.9) 30%, rgba(255, 150, 190, 0.9) 70%);
    background-size: 200% 200%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: directorPastel 4s ease-in-out infinite;
}

.preview-btn-adjust svg {
    position: relative;
    z-index: 2;
}

/* ═══ PIXEL PARTICLES ═══ */
.adjust-pixels {
    position: absolute;
    inset: 0;
    overflow: hidden;
    border-radius: 14px;
    pointer-events: none;
}

.adjust-pixels .px {
    position: absolute;
    width: 3px;
    height: 3px;
    border-radius: 1px;
    background: linear-gradient(110deg, rgba(130, 190, 255, 0.9) 30%, rgba(255, 150, 190, 0.9) 70%);
    background-size: 200% 200%;
    left: 0;
    transform: translateX(-6px);
    animation: pxSlide 14s linear infinite, directorPastel 4s ease-in-out infinite;
    opacity: 0;
    will-change: transform, opacity;
}

/* 5 rows */
.px.r1 { top: 15%; } .px.r2 { top: 30%; } .px.r3 { top: 50%; } .px.r4 { top: 65%; } .px.r5 { top: 80%; }

/* Staggered — ~3-4 visible at once, matrix rain feel */
.px.r1:nth-child(1){animation-delay:0s,0s}.px.r1:nth-child(2){animation-delay:.8s,.3s}.px.r1:nth-child(3){animation-delay:1.6s,.7s}.px.r1:nth-child(4){animation-delay:2.4s,1s}.px.r1:nth-child(5){animation-delay:3.2s,1.5s}.px.r1:nth-child(6){animation-delay:4s,2s}.px.r1:nth-child(7){animation-delay:4.8s,.1s}.px.r1:nth-child(8){animation-delay:5.6s,.6s}.px.r1:nth-child(9){animation-delay:6.4s,1.2s}.px.r1:nth-child(10){animation-delay:7.2s,1.8s}
.px.r2:nth-child(11){animation-delay:.3s,.5s}.px.r2:nth-child(12){animation-delay:1.1s,1.1s}.px.r2:nth-child(13){animation-delay:1.9s,.2s}.px.r2:nth-child(14){animation-delay:2.7s,.8s}.px.r2:nth-child(15){animation-delay:3.5s,1.4s}.px.r2:nth-child(16){animation-delay:4.3s,2.1s}.px.r2:nth-child(17){animation-delay:5.1s,.4s}.px.r2:nth-child(18){animation-delay:5.9s,.9s}.px.r2:nth-child(19){animation-delay:6.7s,1.6s}.px.r2:nth-child(20){animation-delay:7.5s,2.2s}
.px.r3:nth-child(21){animation-delay:.5s,1s}.px.r3:nth-child(22){animation-delay:1.3s,.3s}.px.r3:nth-child(23){animation-delay:2.1s,.8s}.px.r3:nth-child(24){animation-delay:2.9s,1.5s}.px.r3:nth-child(25){animation-delay:3.7s,.1s}.px.r3:nth-child(26){animation-delay:4.5s,.6s}.px.r3:nth-child(27){animation-delay:5.3s,1.3s}.px.r3:nth-child(28){animation-delay:6.1s,2s}.px.r3:nth-child(29){animation-delay:6.9s,.4s}.px.r3:nth-child(30){animation-delay:7.7s,1.1s}
.px.r4:nth-child(31){animation-delay:.15s,.7s}.px.r4:nth-child(32){animation-delay:.95s,1.3s}.px.r4:nth-child(33){animation-delay:1.75s,.2s}.px.r4:nth-child(34){animation-delay:2.55s,.9s}.px.r4:nth-child(35){animation-delay:3.35s,1.6s}.px.r4:nth-child(36){animation-delay:4.15s,.1s}.px.r4:nth-child(37){animation-delay:4.95s,.5s}.px.r4:nth-child(38){animation-delay:5.75s,1.2s}.px.r4:nth-child(39){animation-delay:6.55s,1.9s}.px.r4:nth-child(40){animation-delay:7.35s,.3s}
.px.r5:nth-child(41){animation-delay:.45s,1.2s}.px.r5:nth-child(42){animation-delay:1.25s,.4s}.px.r5:nth-child(43){animation-delay:2.05s,1s}.px.r5:nth-child(44){animation-delay:2.85s,1.7s}.px.r5:nth-child(45){animation-delay:3.65s,.2s}.px.r5:nth-child(46){animation-delay:4.45s,.8s}.px.r5:nth-child(47){animation-delay:5.25s,1.5s}.px.r5:nth-child(48){animation-delay:6.05s,2.1s}.px.r5:nth-child(49){animation-delay:6.85s,.6s}.px.r5:nth-child(50){animation-delay:7.65s,1.4s}

@keyframes pxSlide {
    0%   { transform: translateX(-6px); opacity: 0; }
    5%   { opacity: 0.9; }
    75%  { opacity: 0.25; }
    100% { transform: translateX(100vw); opacity: 0; }
}

/* Multi-card: adjust button visible (user selects which scene to customize) */

.preview-btn-adjust svg {
    width: 14px;
    height: 14px;
    stroke: rgba(180, 170, 230, 0.9);
    fill: none;
    flex-shrink: 0;
}

.preview-btn-generate {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    height: 48px;
    padding: 0 1.5rem;
    border-radius: 14px;
    border: none;
    font-family: 'Inter', sans-serif;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: #000;
    background: #fff;
    overflow: hidden;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
}

.preview-btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 10%, rgba(130, 190, 255, 0.7) 40%, rgba(255, 150, 190, 0.7) 60%, transparent 90%);
    background-size: 200% 200%;
    animation: previewPastelFlow 4s ease-in-out infinite;
    pointer-events: none;
}

.preview-btn-generate:hover {
    box-shadow: 0 4px 24px rgba(130, 190, 255, 0.3), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.preview-btn-generate span,
.preview-btn-generate svg {
    position: relative;
    z-index: 2;
}

@keyframes previewPastelFlow {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ═══ GENERATE BUTTON DISABLED STATE ═══ */
.preview-btn-generate.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* ═══ FAST-TRACK CHECKBOX ═══ */
.preview-fasttrack {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    margin-top: 0.75rem;
}

.preview-fasttrack input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
    position: relative;
    margin-top: 1px;
    transition: all 0.2s ease;
}

.preview-fasttrack input[type="checkbox"]:checked {
    background: #fff;
    border-color: #fff;
}

.preview-fasttrack input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10px;
    font-weight: 900;
    color: #000;
    line-height: 1;
}

.preview-fasttrack-label {
    font-family: 'Inter', sans-serif;
    font-size: clamp(0.5rem, 2vw, 0.6rem);
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    line-height: 1.5;
    letter-spacing: 0.05em;
}

/* ═══ DESC ═══ */
.preview-desc {
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.55);
    line-height: 1.6;
    text-align: center;
    letter-spacing: 0.2em;
    text-transform: uppercase;
}



/* ═══ MOBILE (768px) — same breakpoint as library ═══ */
@media (max-width: 768px) {
    .preview-layout {
        padding: 60px 6px 140px;
    }

    .preview-cards-scroll {
        row-gap: 36px;
        column-gap: 6px;
    }

    .preview-option {
        gap: 6px;
    }

    /* Portrait thumb: exact library size via vw */
    .preview-option .vcard.card-P .thumb {
        width: calc((100vw - 18px) / 2) !important;
        aspect-ratio: 9/16;
        height: auto !important;
    }

    /* Landscape thumb: exact library size via vw */
    .preview-option .vcard.card-L .thumb {
        width: calc(100vw - 12px) !important;
        aspect-ratio: 16/9;
        height: auto !important;
    }

    .preview-btn-generate {
        width: 100%;
    }
}

/* ═══ EXPAND BUTTON (on card thumb) ═══ */
.preview-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.preview-expand-btn:hover {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    transform: scale(1.1);
}

/* ═══ LIGHTBOX OVERLAY ═══ */
.lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 950;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 2.5%;
}

.lightbox-overlay.open {
    display: flex;
}

.lightbox-overlay img {
    max-width: 95%;
    max-height: 95vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}
