/**
 * campaigns.css — Campaigns View
 * Sub-vista A: Products grid
 * Sub-vista B: Campaign detail (product + videos + scenes + wizard)
 * Mobile-first: 2 cols → 4 cols on desktop
 */

/* ─── SCROLL ─── */
#view-campaigns {
    overflow-y: auto !important;
    overflow-x: hidden;
    justify-content: flex-start !important;
}
#view-campaigns::-webkit-scrollbar { width: 4px; }
#view-campaigns::-webkit-scrollbar-track { background: transparent; }
#view-campaigns::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.35); border-radius: 4px; }

/* ─── LAYOUT (match Library) ─── */
.campaigns-layout {
    padding: 20px 40px 160px;
    width: 100%;
}

/* ─── BACK ARROW ─── */
.campaigns-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-family: Inter, sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 8px 4px;
    margin-bottom: 20px;
    transition: color 0.2s;
}
.campaigns-back:hover { color: #fff; }
.campaigns-back svg {
    width: 16px; height: 16px;
    stroke: currentColor; fill: none;
    stroke-width: 2;
}

/* ─── SUB-VISTA A: PRODUCTS GRID ─── */
.campaigns-products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
@media (min-width: 768px) {
    .campaigns-products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}
@media (min-width: 1200px) {
    .campaigns-products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.campaigns-product-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
    position: relative;
}
.campaigns-product-card:hover {
    border-color: rgba(255,255,255,0.18);
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.campaigns-product-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: rgba(255,255,255,0.02);
}

.campaigns-product-info {
    padding: 12px 14px 14px;
}
.campaigns-product-name {
    display: block;
    font-family: Inter, sans-serif;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}
.campaigns-product-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.campaigns-product-stat {
    font-family: Inter, sans-serif;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.45);
    display: flex;
    align-items: center;
    gap: 4px;
}
.campaigns-product-stat .stat-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    display: inline-block;
}
.stat-dot.dot-video { background: #34d399; }
.stat-dot.dot-scene { background: #60a5fa; }
.stat-dot.dot-progress { background: #fbbf24; }

/* Expand button (fullscreen product) */
.campaigns-product-expand {
    position: absolute;
    top: 8px; right: 8px;
    width: 32px; height: 32px;
    border-radius: 8px;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s;
}
.campaigns-product-card:hover .campaigns-product-expand { opacity: 1; }
.campaigns-product-expand svg { width: 14px; height: 14px; }

/* ─── SUB-VISTA B: CAMPAIGN DETAIL ─── */
.campaign-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 28px;
    padding: 16px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
}
.campaign-header-img {
    width: 80px; height: 80px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}
.campaign-header-info {
    flex: 1;
    min-width: 0;
}
.campaign-header-name {
    font-family: Inter, sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.campaign-header-subcat {
    font-family: Inter, sans-serif;
    font-size: 12px;
    color: rgba(255,255,255,0.45);
}

/* ─── SECTION HEADERS ─── */
.campaign-section {
    margin-bottom: 28px;
}
.campaign-section-title {
    font-family: Inter, sans-serif;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

/* ─── CAMPAIGN CARDS GRID (Videos section) ─── */
/* Uses flex-wrap like Library for consistent card sizing */
.campaign-cards-grid {
    display: flex;
    flex-wrap: wrap;
    row-gap: 16px;
    column-gap: 16px;
    justify-content: center;
}

/* Video card sizing — match Library */
.campaign-cards-grid .campaign-card-wrapper .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;
}
.campaign-cards-grid .campaign-card-wrapper .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;
}

/* ─── CARD WRAPPER (video cards) ─── */
.campaign-card-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ─── SCENE EDITOR BUTTON (thicker gradient border, 90% width) ─── */
.campaign-scene-btn {
    width: 90% !important;
    height: 48px !important;
    margin: 0 auto !important;
}
.campaign-scene-btn::before {
    padding: 2px !important;
}

/* ─── EMPTY STATE ─── */
.campaigns-empty {
    text-align: center;
    padding: 80px 24px;
    color: rgba(255,255,255,0.35);
    font-family: Inter, sans-serif;
    font-size: 14px;
}

/* ─── PRODUCT FULLSCREEN MODAL ─── */
.campaigns-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.92);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.campaigns-fullscreen.show {
    opacity: 1;
    pointer-events: auto;
}
.campaigns-fullscreen img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 12px;
}
.campaigns-fullscreen-close {
    position: absolute;
    top: 16px; right: 16px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ─── CAMPAIGN SCENES — Preview-style layout ─── */
/* Scenes grid uses flex-wrap like preview-cards-scroll */
[data-section="scenes"] .campaign-cards-grid {
    display: flex;
    flex-wrap: wrap;
    row-gap: 40px;
    column-gap: 24px;
    justify-content: center;
}

/* Scene card sizing inside campaigns */
[data-section="scenes"] .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;
}
[data-section="scenes"] .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 dimming (from Preview) */
[data-section="scenes"].has-selection .preview-option:not(.selected) .vcard .thumb {
    opacity: 0.5;
}
[data-section="scenes"].has-selection .preview-option:not(.selected) .vcard .thumb img {
    opacity: 0.6;
}
[data-section="scenes"] .preview-option.selected .vcard .thumb {
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.05);
}

/* ─── MOBILE ─── */
@media (max-width: 768px) {
    .campaigns-layout {
        padding: 6px 6px 160px;
    }

    /* All campaign grids: tighter spacing */
    .campaign-cards-grid {
        row-gap: 6px;
        column-gap: 6px;
    }
    [data-section="scenes"] .campaign-cards-grid {
        row-gap: 24px;
        column-gap: 6px;
    }

    /* Video cards mobile: match Library sizing */
    .campaign-cards-grid .campaign-card-wrapper .vcard.card-P .thumb {
        width: calc((100vw - 18px) / 2) !important;
        aspect-ratio: 9/16;
        height: auto !important;
    }
    .campaign-cards-grid .campaign-card-wrapper .vcard.card-L .thumb {
        width: calc(100vw - 12px) !important;
        aspect-ratio: 16/9;
        height: auto !important;
    }

    /* Scene cards mobile: match Library sizing */
    [data-section="scenes"] .preview-option .vcard.card-P .thumb {
        width: calc((100vw - 18px) / 2) !important;
        aspect-ratio: 9/16;
        height: auto !important;
    }
    [data-section="scenes"] .preview-option .vcard.card-L .thumb {
        width: calc(100vw - 12px) !important;
        aspect-ratio: 16/9;
        height: auto !important;
    }
}
