/* WARTOON Dashboard — Styles */

:root {
    --bg: #0a0a0f;
    --bg-card: #14141f;
    --bg-input: #1a1a2e;
    --border: #2a2a3e;
    --text: #e4e4ef;
    --text-muted: #8888aa;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --success: #22c55e;
    --success-hover: #16a34a;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    --accent: #a78bfa;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Navbar ── */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: 2px;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text);
}

/* ── Container ── */

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* ── Page Header ── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
}

/* ── Cards ── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.card-header h2, .card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Badges ── */

.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-parsed, .badge-character_ready, .badge-images_ready, .badge-prompts_ready, .badge-videos_ready {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
}

.badge-character_validated, .badge-images_validated, .badge-prompts_validated, .badge-videos_validated {
    background: rgba(34, 197, 94, 0.2);
    color: var(--success);
}

.badge-complete {
    background: rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.badge-uploaded {
    background: rgba(245, 158, 11, 0.2);
    color: var(--warning);
}

/* ── Status badges ── */

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-validated { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-rejected { background: rgba(239, 68, 68, 0.2); color: var(--danger); }
.status-ready { background: rgba(99, 102, 241, 0.2); color: var(--primary); }
.status-generating { background: rgba(245, 158, 11, 0.2); color: var(--warning); }
.status-pending { background: rgba(136, 136, 170, 0.2); color: var(--text-muted); }

/* ── Buttons ── */

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    background: var(--bg-input);
    border: 1px solid var(--border);
}

.btn:hover { background: var(--border); }

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }

.btn-success { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: var(--success-hover); }

.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-hover); }

.btn-outline { background: transparent; }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }
.btn-lg { padding: 0.8rem 2rem; font-size: 1.1rem; }
.btn-full { width: 100%; }

/* ── Forms ── */

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* ── File Drop ── */

.file-drop {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s;
    position: relative;
}

.file-drop:hover, .file-drop.dragover {
    border-color: var(--primary);
}

.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.file-drop p {
    color: var(--text-muted);
}

/* ── Episodes Grid ── */

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.episode-card .card-body p {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

/* ── Scenes Grid (Images) ── */

.scenes-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    padding: 1rem 1.5rem;
}

.image-variation {
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.image-variation.selected {
    border-color: var(--success);
}

.image-variation img {
    width: 100%;
    aspect-ratio: 9/16;
    object-fit: cover;
    display: block;
}

.image-variation form {
    padding: 0.5rem;
}

/* ── Scenes List (Prompts / Videos) ── */

.scenes-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.scene-card.scene-validated {
    border-color: rgba(34, 197, 94, 0.3);
}

.scene-card.scene-rejected {
    border-color: rgba(239, 68, 68, 0.3);
}

.scene-actions {
    padding: 0.75rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.5rem;
}

/* ── Prompt Form ── */

.prompt-form {
    margin-bottom: 1rem;
}

.prompt-form h4 {
    margin-bottom: 0.75rem;
    color: var(--accent);
}

/* ── Audio Player ── */

.vo-player {
    width: 100%;
    margin: 0.5rem 0;
    border-radius: 8px;
}

.vo-info {
    display: flex;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* ── Video Player ── */

.scene-video, .final-video {
    width: 100%;
    max-height: 500px;
    border-radius: 8px;
    background: black;
}

.final-video {
    max-height: 700px;
}

/* ── Progress Bar ── */

.progress-bar-container {
    position: relative;
    height: 40px;
    background: var(--bg-input);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--success));
    transition: width 0.5s ease;
}

.progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-weight: 600;
    font-size: 0.9rem;
}

/* ── Action Bar ── */

.action-bar {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
}

.bottom-bar {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* ── Music select ── */

.music-select {
    width: 100%;
    padding: 0.7rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
}

.music-select:focus {
    outline: none;
    border-color: var(--primary);
}

.assemble-form {
    width: 100%;
    max-width: 500px;
}

/* ── Script Review ── */

.script-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .script-grid {
        grid-template-columns: 1fr;
    }
}

.script-pre {
    white-space: pre-wrap;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg-input);
    padding: 1rem;
    border-radius: 8px;
    max-height: 600px;
    overflow-y: auto;
    line-height: 1.5;
}

.script-editor {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.script-editor:focus {
    outline: none;
    border-color: var(--primary);
}

.badge-script_enhanced, .badge-script_validated {
    background: rgba(167, 139, 250, 0.2);
    color: var(--accent);
}

/* ── Loading Overlay ── */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.loading-overlay.visible {
    display: flex;
}

.loading-content {
    text-align: center;
    max-width: 480px;
    padding: 2rem;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-right-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-content h2 {
    font-size: 1.6rem;
    margin-bottom: 1rem;
    color: var(--text);
}

.loading-step {
    font-size: 1.05rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 1rem;
    min-height: 1.5em;
}

.loading-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── First + Last Frame Grid ── */

.frames-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem 1.5rem;
}

.frame-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.frame-label {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    background: rgba(0, 0, 0, 0.7);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    z-index: 2;
}

.frame-card img {
    width: 100%;
    aspect-ratio: 9/16;
    object-fit: cover;
    display: block;
}

.frame-placeholder {
    width: 100%;
    aspect-ratio: 9/16;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-style: italic;
}

/* ── Character Lock ── */

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.character-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.2s, transform 0.2s;
}

.character-card:hover {
    border-color: var(--primary);
}

.character-card.selected {
    border-color: var(--success);
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.character-card img {
    width: 100%;
    aspect-ratio: 9/16;
    object-fit: cover;
    display: block;
    background: black;
}

.character-card form {
    padding: 0.75rem;
}

.info-box {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    color: var(--text);
    font-size: 0.95rem;
}

/* ── Insert Scene Form ── */

.insert-form {
    padding: 1rem 1.5rem;
    border-top: 1px dashed var(--border);
    background: rgba(99, 102, 241, 0.04);
}

.insert-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--accent);
}

.insert-form textarea {
    width: 100%;
    padding: 0.7rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    resize: vertical;
}

.insert-form textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* ── Style Details ── */

.style-details {
    padding: 0 1.5rem 1rem;
}

.style-details summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.style-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.style-fields div {
    color: var(--text-muted);
}

/* ── Login ── */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.login-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 900;
    color: var(--primary);
    letter-spacing: 3px;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* ── Export ── */

.export-container {
    max-width: 800px;
}

.caption-text {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text);
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.75rem;
}

.info-table {
    width: 100%;
}

.info-table td {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}

.info-table td:first-child {
    color: var(--text-muted);
    width: 150px;
}

/* ── Empty State ── */

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-state h2 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* ── Alerts ── */

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ── Spinner ── */

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 1rem auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Utilities ── */

.text-muted {
    color: var(--text-muted);
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .navbar {
        flex-direction: column;
        gap: 0.5rem;
    }
}
