/* ============================================================
   AI FILM PRODUCTION SUITE — MAIN.CSS
   Design System: Dark Cinema Theme
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── DESIGN TOKENS ─────────────────────────────────────────── */
:root {
  --bg-base:        #090a0f;
  --bg-surface:     #0e1018;
  --bg-panel:       #13151f;
  --bg-card:        #191c28;
  --bg-hover:       #1e2133;
  --bg-active:      #252840;
  --border-subtle:  #1e2235;
  --border-default: #2a2f47;
  --border-active:  #3d4470;
  --gold:           #f5a623;
  --gold-dim:       #b87a1a;
  --gold-glow:      rgba(245, 166, 35, 0.15);
  --gold-light:     #ffd580;
  --accent-blue:    #4f8ef7;
  --accent-teal:    #2dd4bf;
  --accent-purple:  #a855f7;
  --accent-red:     #ef4444;
  --accent-green:   #22c55e;
  --accent-orange:  #f97316;
  --text-primary:   #f0f2ff;
  --text-secondary: #8891b8;
  --text-muted:     #505880;
  --text-disabled:  #363d5c;
  --status-planned:   #4f8ef7;
  --status-shooting:  #f5a623;
  --status-completed: #22c55e;
  --status-skipped:   #ef4444;
  --font-body:   'Inter', system-ui, sans-serif;
  --font-head:   'Space Grotesk', system-ui, sans-serif;
  --font-mono:   'JetBrains Mono', monospace;
  --sidebar-w:  260px;
  --header-h:   60px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-gold:0 0 24px rgba(245,166,35,0.2);
  --ease:       cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:   150ms;
  --dur-base:   250ms;
  --dur-slow:   400ms;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea, select {
  font: inherit; color: var(--text-primary);
  background: var(--bg-card); border: 1px solid var(--border-default);
  border-radius: var(--radius-sm); padding: 8px 12px; outline: none;
  transition: border-color var(--dur-fast) var(--ease);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-glow);
}
select option { background: var(--bg-card); }
img { display: block; max-width: 100%; }
ul, ol { list-style: none; }

/* ── APP LAYOUT ─────────────────────────────────────────────── */
#app { display: flex; height: 100vh; overflow: hidden; }

/* ── SIDEBAR ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w); height: 100vh;
  background: var(--bg-surface); border-right: 1px solid var(--border-subtle);
  display: flex; flex-direction: column; overflow: hidden;
  position: relative; z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border-subtle);
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sidebar-logo .logo-text { font-family: var(--font-head); font-size: 13px; font-weight: 700; line-height: 1.2; }
.sidebar-logo .logo-text span { display: block; font-size: 10px; font-weight: 400; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 4px; }
.nav-section-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); padding: 12px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-md);
  color: var(--text-secondary); font-size: 13.5px; font-weight: 500;
  transition: all var(--dur-fast) var(--ease); cursor: pointer; user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: var(--gold-glow); color: var(--gold); border: 1px solid rgba(245,166,35,0.2); }
.nav-item .nav-icon { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.nav-item .nav-label { flex: 1; }
.nav-item .nav-badge { font-size: 10px; font-weight: 700; background: var(--gold); color: var(--bg-base); border-radius: 10px; padding: 1px 6px; min-width: 18px; text-align: center; }
.nav-item .nav-check { width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid var(--border-default); display: flex; align-items: center; justify-content: center; font-size: 10px; flex-shrink: 0; }
.nav-item .nav-check.done { background: var(--accent-green); border-color: var(--accent-green); color: white; }
.sidebar-footer { padding: 12px 10px; border-top: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 6px; }
.autosave-indicator { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-muted); padding: 6px 10px; }
.autosave-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-green); animation: pulse-save 2s infinite; }
.autosave-dot.saving { background: var(--gold); animation: pulse-fast 0.5s infinite; }
@keyframes pulse-save { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes pulse-fast { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(1.3); } }

/* ── MAIN CONTENT ───────────────────────────────────────────── */
#main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#topbar {
  height: var(--header-h); min-height: var(--header-h);
  background: var(--bg-surface); border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; z-index: 50;
}
.topbar-title { font-family: var(--font-head); font-size: 16px; font-weight: 600; flex: 1; display: flex; align-items: center; gap: 10px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.project-title-input {
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius-sm); font-family: var(--font-head);
  font-size: 14px; font-weight: 600; color: var(--text-primary);
  padding: 4px 8px; width: 220px;
}
.project-title-input:hover { border-color: var(--border-default); }
.project-title-input:focus { border-color: var(--gold); background: var(--bg-card); }

#content-area { flex: 1; overflow-y: auto; scroll-behavior: smooth; }
#content-area::-webkit-scrollbar { width: 6px; }
#content-area::-webkit-scrollbar-track { background: transparent; }
#content-area::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 6px; }
.page-content { padding: 28px 32px; max-width: 1400px; margin: 0 auto; }

/* ── PIPELINE BAR ───────────────────────────────────────────── */
.pipeline-bar { display: flex; align-items: center; padding: 0 16px; background: var(--bg-panel); border-bottom: 1px solid var(--border-subtle); overflow-x: auto; gap: 0; }
.pipeline-bar::-webkit-scrollbar { height: 0; }
.pipeline-step-btn {
  display: flex; align-items: center; gap: 7px; padding: 10px 14px;
  font-size: 12px; font-weight: 500; color: var(--text-muted);
  border-bottom: 2px solid transparent; transition: all var(--dur-fast) var(--ease); white-space: nowrap; cursor: pointer;
}
.pipeline-step-btn:hover { color: var(--text-secondary); }
.pipeline-step-btn.active { color: var(--gold); border-bottom-color: var(--gold); }
.pipeline-step-btn.done { color: var(--accent-green); }
.pipeline-step-num { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid currentColor; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.pipeline-step-btn.done .pipeline-step-num { background: var(--accent-green); border-color: var(--accent-green); color: white; }
.pipeline-arrow { color: var(--border-default); font-size: 12px; padding: 0 2px; }

/* ── PAGE HEADERS ───────────────────────────────────────────── */
.page-header { margin-bottom: 28px; }
.page-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.page-title { font-family: var(--font-head); font-size: 26px; font-weight: 700; line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ── BUTTONS ────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 9px 18px; border-radius: var(--radius-md); font-size: 13.5px; font-weight: 600; transition: all var(--dur-fast) var(--ease); white-space: nowrap; cursor: pointer; border: 1px solid transparent; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--gold), #e0922a); color: #0a0900; box-shadow: 0 2px 12px rgba(245,166,35,0.25); }
.btn-primary:hover:not(:disabled) { background: linear-gradient(135deg, var(--gold-light), var(--gold)); box-shadow: var(--shadow-gold); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-primary); border-color: var(--border-default); }
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-active); }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--accent-red); border-color: rgba(239,68,68,0.3); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); }
.btn-success { background: rgba(34,197,94,0.15); color: var(--accent-green); border-color: rgba(34,197,94,0.3); }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,0.25); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn-ai { background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff; border: none; box-shadow: 0 2px 12px rgba(124,58,237,0.3); position: relative; overflow: hidden; }
.btn-ai::before { content:''; position:absolute; inset:0; background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.08)); }
.btn-ai:hover:not(:disabled) { box-shadow: 0 4px 20px rgba(124,58,237,0.45); transform: translateY(-1px); }
.btn-ai.loading { pointer-events: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 20px; transition: border-color var(--dur-fast) var(--ease); }
.card:hover { border-color: var(--border-default); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.card-title { font-family: var(--font-head); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }

/* ── STATS ──────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); padding: 16px 18px; display: flex; flex-direction: column; gap: 6px; transition: all var(--dur-fast) var(--ease); }
.stat-card:hover { border-color: var(--border-default); transform: translateY(-2px); }
.stat-value { font-family: var(--font-head); font-size: 26px; font-weight: 700; color: var(--gold); line-height: 1; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; }

/* ── TABLES ─────────────────────────────────────────────────── */
.table-wrap { border-radius: var(--radius-lg); border: 1px solid var(--border-subtle); overflow: hidden; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th { background: var(--bg-panel); color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border-subtle); white-space: nowrap; }
tbody tr { border-bottom: 1px solid var(--border-subtle); transition: background var(--dur-fast) var(--ease); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }
tbody td { padding: 11px 16px; vertical-align: middle; }
.cell-edit { min-width: 80px; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 4px 8px; width: 100%; font-size: 13px; color: var(--text-primary); }
.cell-edit:hover { border-color: var(--border-default); }
.cell-edit:focus { border-color: var(--gold); background: var(--bg-hover); }

/* ── TAGS ────────────────────────────────────────────────────── */
.tag-list { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; background: var(--bg-hover); border: 1px solid var(--border-default); color: var(--text-secondary); transition: all var(--dur-fast) var(--ease); }
.tag-remove { cursor: pointer; opacity: 0.6; font-size: 12px; line-height: 1; }
.tag-remove:hover { opacity: 1; color: var(--accent-red); }
.tag.character  { background: rgba(79,142,247,0.12); border-color: rgba(79,142,247,0.3); color: var(--accent-blue); }
.tag.prop       { background: rgba(245,166,35,0.12); border-color: rgba(245,166,35,0.3); color: var(--gold); }
.tag.wardrobe   { background: rgba(168,85,247,0.12); border-color: rgba(168,85,247,0.3); color: var(--accent-purple); }
.tag.vehicle    { background: rgba(45,212,191,0.12); border-color: rgba(45,212,191,0.3); color: var(--accent-teal); }
.tag.sfx        { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.3); color: var(--accent-red); }
.tag.makeup     { background: rgba(249,115,22,0.12); border-color: rgba(249,115,22,0.3); color: var(--accent-orange); }
.tag.animal     { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.3); color: var(--accent-green); }
.tag.extra      { background: rgba(136,145,184,0.12); border-color: rgba(136,145,184,0.3); color: var(--text-secondary); }

/* ── STATUS BADGES ──────────────────────────────────────────── */
.status-badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.status-badge::before { content:''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-planned   { background: rgba(79,142,247,0.12); color: var(--status-planned); }
.status-shooting  { background: rgba(245,166,35,0.15); color: var(--status-shooting); }
.status-completed { background: rgba(34,197,94,0.12); color: var(--status-completed); }
.status-skipped   { background: rgba(239,68,68,0.12); color: var(--status-skipped); }

/* ── PROGRESS BAR ───────────────────────────────────────────── */
.progress-bar-wrap { height: 6px; background: var(--border-subtle); border-radius: 6px; overflow: hidden; }
.progress-bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--gold), var(--accent-orange)); transition: width var(--dur-slow) var(--ease); }
.progress-bar-fill.green { background: linear-gradient(90deg, var(--accent-teal), var(--accent-green)); }

/* ── EMPTY STATE ────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 60px 24px; text-align: center; gap: 14px; }
.empty-icon { font-size: 48px; opacity: 0.3; }
.empty-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; color: var(--text-secondary); }
.empty-desc { font-size: 13px; color: var(--text-muted); max-width: 340px; line-height: 1.6; }

/* ── MODALS ─────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 9999; opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease); }
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal { background: var(--bg-panel); border: 1px solid var(--border-default); border-radius: var(--radius-xl); padding: 28px; width: 90%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); transform: translateY(20px) scale(0.97); transition: transform var(--dur-base) var(--ease); }
.modal-overlay.open .modal { transform: translateY(0) scale(1); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.modal-title { font-family: var(--font-head); font-size: 18px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 20px; transition: all var(--dur-fast) var(--ease); }
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { display: flex; flex-direction: column; gap: 16px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }

/* ── FORM FIELDS ────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.8px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
input[type="text"], input[type="date"], input[type="number"], input[type="time"], textarea, select { width: 100%; }
textarea { resize: vertical; min-height: 80px; }

/* ── TOAST ──────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 99999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--bg-panel); border: 1px solid var(--border-default); border-radius: var(--radius-md); padding: 13px 18px; font-size: 13px; box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 10px; animation: toast-in var(--dur-base) var(--ease) forwards; min-width: 260px; max-width: 360px; pointer-events: all; }
.toast.removing { animation: toast-out var(--dur-base) var(--ease) forwards; }
.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg { flex: 1; }
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.warning { border-left: 3px solid var(--gold); }
.toast.info    { border-left: 3px solid var(--accent-blue); }
@keyframes toast-in  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(20px); } }

/* ── UPLOAD ZONE ────────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border-default); border-radius: var(--radius-xl); padding: 48px 32px; text-align: center; cursor: pointer; transition: all var(--dur-base) var(--ease); background: var(--bg-panel); position: relative; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--gold); background: var(--gold-glow); }
.upload-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.upload-icon { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.upload-title { font-family: var(--font-head); font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.upload-desc { font-size: 13px; color: var(--text-muted); }
.drag-handle { cursor: grab; color: var(--text-muted); font-size: 16px; padding: 4px; }
.drag-handle:hover { color: var(--text-secondary); }
.drag-handle:active { cursor: grabbing; }
.divider { height: 1px; background: var(--border-subtle); margin: 20px 0; }
.kbd { display: inline-flex; align-items: center; justify-content: center; padding: 2px 6px; background: var(--bg-hover); border: 1px solid var(--border-default); border-radius: 4px; font-family: var(--font-mono); font-size: 10px; color: var(--text-muted); }

/* ── UTILITIES ──────────────────────────────────────────────── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold); }
.text-sm { font-size: 12px; }
.font-mono { font-family: var(--font-mono); }
.w-full { width: 100%; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
* { scrollbar-width: thin; scrollbar-color: var(--border-default) transparent; }

@media (max-width: 768px) {
  :root { --sidebar-w: 56px; }
  #sidebar .logo-text, #sidebar .nav-label, #sidebar .nav-section-label, .autosave-indicator span { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .page-content { padding: 16px; }
}
