/* ============================================================
   STORYBOARD TAB — Loki AI Dashboard
   Mint #5ce89a + dark #0a0a0a, matches Cinema visual language.
   ============================================================ */

.tab-page[data-page="storyboard"] {
    padding: 24px 28px 80px;
    max-width: 1600px;
    margin: 0 auto;
}

.sb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}
.sb-header h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.2px;
    color: #fff;
}
.sb-header h1 .accent { color: #5ce89a; }
.sb-header .sb-credits {
    font-size: 14px;
    color: #a0a0a0;
    font-variant-numeric: tabular-nums;
}

/* ---------- Reference strip ---------- */
.sb-refstrip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px dashed rgba(255,255,255,0.12);
    border-radius: 12px;
    background: #0f1212;
    margin-bottom: 14px;
    transition: border-color 120ms ease, background 120ms ease;
}
.sb-refstrip.dragover {
    border-color: #5ce89a;
    background: rgba(92,232,154,0.06);
}
.sb-refstrip__hint {
    color: #707070;
    font-size: 14px;
    letter-spacing: 0.2px;
}
.sb-refstrip__add {
    width: 56px; height: 56px;
    display: flex; align-items: center; justify-content: center;
    border: 1px dashed rgba(255,255,255,0.18);
    border-radius: 10px;
    color: #888;
    cursor: pointer;
    background: transparent;
    transition: border-color 120ms ease, color 120ms ease;
}
.sb-refstrip__add:hover { border-color: #5ce89a; color: #5ce89a; }
.sb-ref {
    position: relative;
    width: 56px; height: 56px;
    border-radius: 10px;
    overflow: hidden;
    background: #1a1a1a;
    border: 2px solid transparent;
}
.sb-ref.active { border-color: #5ce89a; }
.sb-ref img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sb-ref__close {
    position: absolute; top: 2px; right: 2px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: none;
    font-size: 13px;
    line-height: 18px;
    cursor: pointer;
    display: none;
}
.sb-ref:hover .sb-ref__close { display: block; }

/* ---------- Toolbar ---------- */
.sb-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    padding: 12px 14px;
    background: #0f1212;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 12px;
    margin-bottom: 14px;
}
.sb-toolbar__group { display: flex; align-items: center; gap: 6px; }
.sb-toolbar__label {
    font-size: 13px;
    color: #707070;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-right: 4px;
}
.sb-toolbar select,
.sb-toolbar input[type="number"] {
    background: #1a1d1d;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 15px;
    outline: none;
}
.sb-toolbar select:focus,
.sb-toolbar input[type="number"]:focus { border-color: #5ce89a; }
.sb-toolbar input[type="number"] { width: 64px; }

.sb-pill {
    background: transparent;
    color: #c0c0c0;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: all 120ms ease;
}
.sb-pill:hover { border-color: #5ce89a; color: #fff; }
.sb-pill.active {
    background: rgba(92,232,154,0.12);
    border-color: #5ce89a;
    color: #5ce89a;
}

.sb-prompt {
    width: 100%;
    background: #0f1212;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px 14px;
    color: #fff;
    font-size: 16px;
    line-height: 1.4;
    resize: vertical;
    min-height: 64px;
    margin-bottom: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 120ms ease;
}
.sb-prompt:focus { border-color: #5ce89a; }

.sb-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 18px;
}
.sb-btn {
    background: #1a1d1d;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 120ms ease;
}
.sb-btn:hover { border-color: #5ce89a; color: #5ce89a; }
.sb-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.sb-btn--primary {
    background: linear-gradient(180deg, #5ce89a 0%, #3fb578 100%);
    color: #0a0a0a;
    border-color: transparent;
}
.sb-btn--primary:hover { color: #0a0a0a; filter: brightness(1.05); }
.sb-btn--ghost { background: transparent; }

/* ---------- Grid ---------- */
.sb-grid {
    display: grid;
    gap: 10px;
    background: transparent;
    border-radius: 14px;
}
.sb-cell {
    position: relative;
    background: #0f1212;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 1 / 1;
    transition: border-color 120ms ease, transform 120ms ease;
}
.sb-cell.ar-9-16  { aspect-ratio: 9 / 16; }
.sb-cell.ar-16-9  { aspect-ratio: 16 / 9; }
.sb-cell.ar-4-5   { aspect-ratio: 4 / 5; }
.sb-cell.ar-1-1   { aspect-ratio: 1 / 1; }
.sb-cell:hover { border-color: rgba(92,232,154,0.4); }
.sb-cell img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    cursor: zoom-in;
}
.sb-cell__placeholder {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: #4a4a4a;
    font-size: 13px;
    text-align: center;
    padding: 12px;
}
.sb-cell__spinner {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(10,10,10,0.7);
    backdrop-filter: blur(2px);
}
.sb-cell__spinner::before {
    content: '';
    width: 28px; height: 28px;
    border: 2px solid rgba(92,232,154,0.2);
    border-top-color: #5ce89a;
    border-radius: 50%;
    animation: sb-spin 800ms linear infinite;
}
@keyframes sb-spin { to { transform: rotate(360deg); } }
.sb-cell__error {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(40,10,10,0.5);
    color: #ff8a8a;
    font-size: 13px;
    padding: 12px;
    text-align: center;
}
.sb-cell__idx {
    position: absolute;
    top: 8px; left: 8px;
    background: rgba(0,0,0,0.6);
    color: #5ce89a;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.6px;
    padding: 3px 7px;
    border-radius: 4px;
    z-index: 2;
}
.sb-cell__prompt {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.85), transparent);
    color: #c0c0c0;
    font-size: 13px;
    padding: 16px 8px 8px;
    line-height: 1.3;
    max-height: 50%;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
    transition: opacity 120ms ease;
}
.sb-cell:hover .sb-cell__prompt { opacity: 1; }
.sb-cell__controls {
    position: absolute;
    top: 8px; right: 8px;
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 120ms ease;
    z-index: 3;
}
.sb-cell:hover .sb-cell__controls { opacity: 1; }
.sb-cell__btn {
    width: 28px; height: 28px;
    border-radius: 6px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.15);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 120ms ease;
}
.sb-cell__btn:hover { border-color: #5ce89a; color: #5ce89a; }

/* ---------- Lightbox ---------- */
.sb-lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.sb-lightbox.open { display: flex; }
.sb-lightbox__inner {
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}
.sb-lightbox__img {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.sb-lightbox__meta {
    background: #0f1212;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px 16px;
    color: #c0c0c0;
    font-size: 15px;
    line-height: 1.4;
    max-width: 100%;
    word-wrap: break-word;
}
.sb-lightbox__actions {
    display: flex;
    gap: 8px;
}
.sb-lightbox__close {
    position: absolute;
    top: 20px; right: 20px;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
}
.sb-lightbox__close:hover { background: rgba(255,255,255,0.16); }

/* ---------- Cell-prompt edit modal ---------- */
.sb-edit-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}
.sb-edit-modal.open { display: flex; }
.sb-edit-modal__inner {
    background: #0f1212;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 14px;
    padding: 22px;
    width: 100%;
    max-width: 600px;
}
.sb-edit-modal h3 {
    margin: 0 0 12px;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
}
.sb-edit-modal textarea {
    width: 100%;
    min-height: 120px;
    background: #1a1d1d;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.10);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 15px;
    line-height: 1.4;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 12px;
    outline: none;
}
.sb-edit-modal textarea:focus { border-color: #5ce89a; }
.sb-edit-modal__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}
