/* ============================================================
   generate.css — Page-specific styles for the video generator
   Global / shared styles live in style.css
   ============================================================ */

/* Override body for full-screen app layout */
body {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ── Top Navigation Bar ── */
.top-navbar {
    height: 64px;
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 24px;
}

.navbar-logo {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent-cyan);
    white-space: nowrap;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
}

.nav-link:hover { background-color: var(--border-color); color: var(--text-main); }
.nav-link.active { background-color: var(--bg-card); color: var(--accent-cyan); font-weight: 600; }

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.credits-pill {
    background-color: var(--bg-card);
    border: 1px solid var(--accent-cyan);
    border-radius: 100px;
    padding: 7px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background-color: var(--accent-cyan);
    color: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-family: var(--font-mono);
    font-size: 13px;
    flex-shrink: 0;
}

/* ── Announcement Bar ── */
.announcement-bar {
    background-color: rgba(34, 211, 238, 0.07);
    border-bottom: 1px solid rgba(34, 211, 238, 0.2);
    padding: 10px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 12px;
}

.announcement-content {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.announcement-badge {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--bg-main);
    background-color: var(--accent-cyan);
    padding: 2px 8px;
    border-radius: 4px;
    flex-shrink: 0;
}

.announcement-text {
    font-size: 13px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* ── Page Layout ── */
.dashboard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px 28px;
    gap: 0;
    overflow-y: auto;
}

.workspace {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

/* ── Right History Panel ── */
.history-panel {
    width: 240px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.history-panel-header {
    padding: 18px 20px 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 12px 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid transparent;
}

.history-item:hover {
    background-color: var(--bg-card);
    border-color: var(--border-color);
}

.history-item.active {
    background-color: var(--bg-card);
    border-color: var(--accent-cyan);
}

.history-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-meta {
    font-size: 10px;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-top: 3px;
}

.history-panel-footer {
    padding: 16px;
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
}

/* ── Config Panel ── */
.config-panel {
    width: 360px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex-shrink: 0;
}

/* Tab 2 專用：左右各半 */
#tab-storyboard .config-panel {
    width: auto;
    flex: 1;
    overflow-y: auto;
}


/* Product Image + Template side by side */
.product-template-row {
    display: flex;
    gap: 12px;
}

.pt-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dashed-box {
    aspect-ratio: 3 / 4;
    border: 1.5px dashed var(--border-color);
    border-radius: 10px;
    background-color: var(--bg-card);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 11px;
    transition: border-color 0.2s, background 0.2s;
}

.dashed-box:hover {
    border-color: var(--accent-cyan);
    background-color: rgba(34, 211, 238, 0.04);
}

.dashed-box svg { opacity: 0.5; }
.dashed-box:hover svg { opacity: 0.9; }

/* ── Preview Panel ── */
.preview-panel {
    flex: 1;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    overflow-y: auto;
    position: relative;
}

/* Storyboard Grid — 6 portrait frames */
.sb-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 10px;
}

.sb-frame {
    aspect-ratio: 9 / 16;
    background-color: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--accent-cyan);
    overflow: hidden;
    background-size: cover;
    background-position: center;
    position: relative; /* needed for download btn */
}

/* Upload variant — used in Tab 2 config panel */
.sb-frame.sb-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-style: dashed;
    border-color: var(--border-color);
    color: var(--text-muted);
    transition: border-color 0.2s, background 0.2s;
}

.sb-frame.sb-upload:hover {
    border-color: var(--accent-cyan);
    background-color: rgba(34, 211, 238, 0.04);
}

.sb-frame.sb-upload svg { opacity: 0.5; }
.sb-frame.sb-upload:hover svg { opacity: 0.9; }


/* ── Results Layout（Tab 1 新版）── */
.results-layout {
    display: flex;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

.results-left {
    flex: 0 0 40%;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.results-left .merged-frame {
    flex: 1;
    min-height: 0;
    width: 100%;
}

.results-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
    overflow-y: auto;
}

/* 3 欄版 sb-grid（Tab 1 結果區用） */
.sb-grid--3col {
    grid-template-columns: repeat(3, 1fr);
}

/* results-right 內的片段：3+2 排列 */
.results-right .clips-list .clip-thumb {
    flex: 0 0 calc((100% - 20px) / 3);
}

/* ── Video Section ── */
.video-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

/* Clips + merged preview side by side */
.clips-and-preview {
    display: flex;
    gap: 0;
    align-items: flex-start;
    width: 100%;
}

/* Left clips section */
.clips-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 24px;
    border-right: 1px solid var(--border-color);
}

/* Clip thumbnails: flex wrap, 3 per row, 2nd row centered */
.clips-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

/* Right column: large merged video preview */
.merged-preview-col {
    width: 200px;
    flex-shrink: 0;
    padding-left: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.merged-preview {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}

.merged-frame {
    aspect-ratio: 9 / 16;
    width: 100%;
    background: linear-gradient(135deg, #060d1a, #0d1f3c);
    border-radius: 10px;
    border: 2px solid var(--accent-cyan);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 0 20px rgba(34, 211, 238, 0.18);
}

.merged-frame-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background-color: rgba(34, 211, 238, 0.92);
    color: #0A0F1C;
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
}

.merged-frame-btn:hover {
    background-color: rgba(34, 211, 238, 1);
    transform: scale(1.08);
}

/* Clip Thumbnails */
.clip-thumb {
    aspect-ratio: 9 / 16;
    flex: 0 0 calc((100% - 20px) / 3); /* 3 per row, 2nd row centered */
    background-color: #0a0a0a;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    color: var(--text-muted);
    transition: border-color 0.2s;
    position: relative; /* needed for download btn */
}

.clip-thumb:hover { border-color: var(--text-muted); }

.clip-thumb.active {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

/* ── Per-frame Download Button (sb-frame & clip-thumb) ── */
.frame-dl-btn {
    position: absolute;
    bottom: 6px;
    right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 5px;
    background-color: rgba(34, 211, 238, 0.88);
    color: #0A0F1C;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transform: translateY(3px);
    transition: opacity 0.18s, transform 0.18s, background 0.15s;
}

.sb-frame:hover .frame-dl-btn,
.clip-thumb:hover .frame-dl-btn {
    opacity: 1;
    transform: translateY(0);
}

.frame-dl-btn:hover {
    background-color: rgba(34, 211, 238, 1);
}

.play-overlay {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(34, 211, 238, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000;
    font-size: 15px;
    cursor: pointer;
}

/* ── Template Picker Button ── */
.btn-template-picker {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 9px 12px;
    background-color: transparent;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.btn-template-picker:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background-color: rgba(34, 211, 238, 0.04);
}

/* ── Template Modal Overlay ── */
.tpl-modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.tpl-modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.tpl-modal {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: min(860px, 90vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(12px);
    transition: transform 0.2s;
}

.tpl-modal-overlay.open .tpl-modal {
    transform: translateY(0);
}

/* Modal Header */
.tpl-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 28px 16px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tpl-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: background 0.2s, color 0.2s;
}

.tpl-modal-close:hover {
    background-color: var(--bg-card);
    color: var(--text-main);
}

/* Filter Tabs */
.tpl-tabs {
    display: flex;
    gap: 6px;
    padding: 16px 28px 0;
    flex-shrink: 0;
}

.tpl-tab {
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 12px;
    color: var(--text-muted);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.tpl-tab:hover {
    color: var(--text-main);
    border-color: var(--border-color);
}

.tpl-tab.active {
    background-color: var(--bg-card);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    font-weight: 600;
}

/* Template Grid */
.tpl-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    padding: 20px 28px 28px;
    overflow-y: auto;
}

.tpl-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    cursor: pointer;
}

.tpl-card-thumb {
    aspect-ratio: 9 / 16;
    background: linear-gradient(135deg, var(--bg-card), #0d1f3c);
    border-radius: 8px;
    border: 2px solid var(--border-color);
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.tpl-card:hover .tpl-card-thumb {
    border-color: var(--text-muted);
    transform: translateY(-2px);
}

.tpl-card.selected .tpl-card-thumb {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.3);
}

.tpl-card-name {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
    transition: color 0.2s;
}

.tpl-card.selected .tpl-card-name {
    color: var(--accent-cyan);
}

/* ── Download All Button ── */
.dl-all-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 11px;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s;
}
.dl-all-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}
.dl-all-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── Error Toast ── */
.error-toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    border: 1px solid #ef4444;
    border-radius: 8px;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #f1f5f9;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: toast-slide-up 0.3s ease;
    white-space: nowrap;
    max-width: 90vw;
    white-space: normal;
    text-align: left;
}
.error-toast button {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 18px;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.error-toast button:hover { color: #f1f5f9; }
.error-toast.fade-out {
    animation: toast-fade-out 0.4s ease forwards;
}
@keyframes toast-slide-up {
    from { opacity: 0; transform: translateX(-50%) translateY(20px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes toast-fade-out {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to   { opacity: 0; transform: translateX(-50%) translateY(10px); }
}
