/* ==========================================================================
   CSS Variables & Theming (Apple-style Liquid Glass & Dark Mode)
   ========================================================================== */
:root {
    /* Base Colors - Deep Cinematic Aesthetic */
    --bg-dark: #0f1115;
    --bg-panel: #16181d;
    --bg-card: #1c1f26;
    --card-header: #232730;
    --glass-border: rgba(255, 255, 255, 0.05);
    --glass-border-highlight: rgba(255, 255, 255, 0.12);

    /* Neon Accents */
    --accent-jade: #22c55e;
    --accent-cyan: #06b6d4;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-red: #ef4444;
    --accent-yellow: #eab308;

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Layout & Spacing */
    --sidebar-width: 380px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
    overflow: hidden;
}

/* ==========================================================================
   Left Sidebar (Input)
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
    z-index: 10;
    background: var(--bg-panel);
    border-right: 1px solid var(--glass-border);
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 32px;
    color: var(--text-primary);
}

.sidebar-section {
    margin-bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group.margin-top {
    margin-top: 8px;
}

.input-group.fill-height {
    flex-grow: 1;
}

label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: all var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-jade);
}

textarea {
    resize: none;
    min-height: 200px;
}

.options-row {
    display: flex;
    gap: 8px;
}

.radio-group {
    flex: 1;
    position: relative;
}

.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.radio-group label {
    display: block;
    width: 100%;
    padding: 8px 0;
    text-align: center;
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.radio-group input[type="radio"]:checked+label {
    border-color: var(--accent-jade);
    color: var(--accent-jade);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius-sm);
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-secondary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background: #2a2e38;
    color: #fff;
}

.btn-primary {
    background: var(--accent-jade);
    color: #000;
    font-weight: 600;
}

.btn-primary:hover {
    opacity: 0.9;
}

.generate-btn {
    margin-top: auto;
    width: 100%;
    padding: 12px;
}

/* ==========================================================================
   Right Main Content (Board) - Perfectly matches reference image
   ========================================================================== */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 32px 48px;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-dark);
}

/* Initially hidden state for generated content */
.generated-content {
    display: none;
    flex-direction: column;
    animation: fade-in 0.4s ease-out;
}

.generated-content.visible {
    display: flex;
}

/* Board Header */
.board-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 16px;
}

.title-area h1 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.subtitle {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent-jade);
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.meta-tags {
    display: flex;
    gap: 32px;
}

.meta-item {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.meta-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Global Settings Boxes - 3 Top Boxes */
.global-settings {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.settings-card {
    background: var(--bg-panel);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    min-height: 120px;
    position: relative;
    overflow: hidden;
}

.settings-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--accent-blue);
    opacity: 0.6;
}

.settings-card:nth-child(2)::before {
    background: var(--accent-purple);
}

.settings-card:nth-child(3)::before {
    background: var(--accent-cyan);
}

.settings-card .card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.settings-card ul {
    list-style: none;
}

.settings-card li {
    font-size: 0.8rem;
    color: var(--text-primary);
    margin-bottom: 6px;
    padding-left: 14px;
    position: relative;
    line-height: 1.5;
}

.settings-card li::before {
    content: "●";
    position: absolute;
    left: 0;
    font-size: 0.5rem;
    color: var(--accent-jade);
    top: 4px;
}

.character-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.char-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.2);
    color: var(--accent-purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.char-info {
    font-size: 0.75rem;
}

.char-name {
    font-weight: 600;
    margin-right: 6px;
}

.char-desc {
    color: var(--text-muted);
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.filter-tabs .tab {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-tabs .tab i {
    font-size: 0.6rem;
}

.filter-tabs .tab.t-all {
    color: #f59e0b;
}

.filter-tabs .tab.t-scene {
    color: #ec4899;
}

.filter-tabs .tab.t-char {
    color: #eab308;
}

.filter-tabs .tab.t-vfx {
    color: #06b6d4;
}

.filter-tabs .tab.t-audio {
    color: #a855f7;
}

/* Storyboard Grid (SCENE Cards) */
.storyboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    color: var(--text-muted);
    background: var(--bg-panel);
    border-radius: var(--radius-md);
    border: 1px dashed var(--glass-border);
}

/* Scene Card Design */
.scene-card {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card-yellow {
    border-color: rgba(234, 179, 8, 0.4);
}

.scene-header {
    background: var(--card-header);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
}

.scene-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.scene-badge {
    background: #fff;
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.card-yellow .scene-badge {
    background: var(--accent-yellow);
}

.scene-time {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--accent-jade);
    border: 1px solid rgba(34, 197, 94, 0.3);
    padding: 2px 8px;
    border-radius: 12px;
    font-family: monospace;
}

.scene-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-grow: 1;
}

.tags-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tag {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.7rem;
    padding: 2px 8px;
    color: var(--text-secondary);
}

.prompt-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 4px;
    padding: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.5;
    position: relative;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.prompt-box:hover {
    border-color: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
}

.p-action {
    color: var(--accent-blue);
    font-weight: 500;
    margin-right: 4px;
}

.audio-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.audio-tag {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.bgm-tag {
    background: rgba(234, 179, 8, 0.15);
    color: var(--accent-yellow);
}

.scene-footer {
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.target-row {
    font-size: 0.6rem;
    color: var(--accent-yellow);
    font-weight: 600;
    letter-spacing: 0.05em;
    display: flex;
    justify-content: space-between;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2px;
    overflow: hidden;
    display: flex;
}

.progress {
    background: var(--accent-jade);
    height: 100%;
}

.card-yellow .progress {
    background: var(--accent-yellow);
}

/* Timeline & Audio Engineering */
.timeline-section {
    background: var(--bg-panel);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--glass-border);
    margin-top: 10px;
}

.timeline-section h3 {
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--text-primary);
    border-left: 3px solid var(--accent-jade);
    padding-left: 8px;
}

.timeline-bar {
    position: relative;
    height: 32px;
    margin-bottom: 32px;
}

.time-marker {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 0.65rem;
    color: var(--text-muted);
}

.time-marker::after {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    width: 1px;
    height: 16px;
    background: var(--glass-border-highlight);
}

.timeline-track {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.1);
}

.time-dot {
    position: absolute;
    bottom: -2px;
    width: 6px;
    height: 6px;
    background: var(--accent-jade);
    border-radius: 50%;
    transform: translateX(-50%);
}

.audio-panel-layout {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 32px;
}

.table-header {
    display: grid;
    grid-template-columns: 1fr 1fr 3fr 1fr;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.table-body {
    padding-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.8rem;
}

.table-row {
    display: grid;
    grid-template-columns: 1fr 1fr 3fr 1fr;
    color: var(--text-secondary);
    align-items: center;
}

.intensity-stars {
    color: var(--accent-red);
    font-size: 0.7rem;
}

.audio-curve-chart h4 {
    font-size: 0.75rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.curve-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 16px;
    height: 120px;
}

.curve-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--bg-card);
    color: #fff;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    animation: fade-in 0.3s ease-out;
}

.toast.removing {
    animation: fade-out 0.3s ease-in forwards;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }

    to {
        opacity: 0;
        transform: translateY(10px);
    }
}

/* Loading Animation */
.skeleton-box {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 25%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.02) 75%);
    background-size: 200% 100%;
    animation: load 1.5s infinite;
    border-radius: 4px;
}

@keyframes load {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* --- Welcome Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 17, 21, 0.85);
    backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-sidebar);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    padding: 24px 24px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h2 {
    font-size: 1.15rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.modal-header h2 i {
    color: var(--accent-jade);
}

.modal-body {
    padding: 24px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

.modal-body p {
    margin: 0 0 16px;
}

.modal-body p:last-of-type {
    margin-bottom: 0;
}

.modal-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.modal-alert {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    color: var(--text-secondary);
    margin: 20px 0;
    font-size: 0.85rem;
    line-height: 1.5;
}

.modal-alert i {
    font-size: 1.25rem;
    flex-shrink: 0;
    color: var(--accent-red);
    margin-top: 2px;
}

.modal-alert strong {
    color: #fca5a5;
    font-weight: 600;
    display: inline-block;
    margin-bottom: 4px;
}

.modal-footer {
    padding: 16px 24px 24px;
}