/* ============================================================
   AI Film Studio — Main CSS
   Aesthetic: Industrial Cinematic — dark, amber accents, mono type
   ============================================================ */

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

:root {
  --black:    #0a0a0c;
  --dark:     #111115;
  --surface:  #18181f;
  --surface2: #1f1f28;
  --border:   #2a2a36;
  --border2:  #35353f;
  --amber:    #f5a623;
  --amber-dim:#b07510;
  --cyan:     #38bdf8;
  --red:      #ef4444;
  --green:    #22c55e;
  --text:     #e8e8ec;
  --muted:    #888898;
  --dim:      #555568;
  --white:    #ffffff;

  --font-display: 'Bebas Neue', sans-serif;
  --font-mono:    'DM Mono', monospace;
  --font-ui:      'DM Sans', sans-serif;

  --radius:   4px;
  --radius-lg: 8px;
  --shadow:   0 4px 24px rgba(0,0,0,.6);
  --shadow-lg:0 8px 48px rgba(0,0,0,.8);
}

html, body {
  height: 100%;
  background: var(--black);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── UTILITY ──────────────────────────────────────────────── */
.hidden  { display: none !important; }
.full    { width: 100%; }
.span2   { grid-column: span 2; }

input, textarea, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color .15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--amber); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }

/* ── BUTTONS ──────────────────────────────────────────────── */
button { cursor: pointer; font-family: var(--font-ui); border: none; outline: none; }

.btn-primary {
  background: var(--amber);
  color: var(--black);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 9px 18px;
  border-radius: var(--radius);
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: #ffb93c; }
.btn-primary:active { transform: scale(.97); }
.btn-primary.small { padding: 6px 14px; font-size: 11px; }

.btn-secondary {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border2);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: var(--radius);
  transition: border-color .15s;
}
.btn-secondary:hover { border-color: var(--amber); }
.btn-secondary.small { padding: 5px 10px; font-size: 11px; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: color .15s;
}
.btn-ghost:hover { color: var(--text); }

.btn-danger {
  background: var(--red);
  color: #fff;
  font-size: 12px;
  padding: 7px 14px;
  border-radius: var(--radius);
}

.btn-tag {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: .1em;
  font-family: var(--font-mono);
  padding: 4px 10px;
  border-radius: 2px;
}
.btn-tag.pitch { color: var(--cyan); border-color: var(--cyan); }
.btn-icon { background: transparent; color: var(--muted); font-size: 16px; padding: 4px 6px; border-radius: var(--radius); transition: color .15s; }
.btn-icon:hover { color: var(--amber); }
.btn-tiny { background: var(--surface2); color: var(--muted); border: 1px solid var(--border); font-size: 11px; padding: 3px 8px; border-radius: 2px; }

/* ── AUTH ─────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--black);
  z-index: 1000;
}
.auth-bg-film {
  position: absolute; inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(245,166,35,.04) 60px),
    repeating-linear-gradient(0deg,  transparent, transparent 89px, rgba(245,166,35,.04) 90px);
  pointer-events: none;
}
.auth-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo { font-family: var(--font-display); font-size: 36px; letter-spacing: .15em; line-height: 1; margin-bottom: 6px; }
.logo-film   { color: var(--amber); }
.logo-studio { color: var(--text); }
.auth-tagline { font-size: 12px; color: var(--muted); margin-bottom: 32px; letter-spacing: .04em; }
.auth-form h2 { font-size: 18px; font-weight: 600; margin-bottom: 20px; }
.auth-form input { display: block; margin-bottom: 12px; }
.auth-error { color: var(--red); font-size: 12px; min-height: 18px; margin-bottom: 8px; }
.auth-switch { font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }
.auth-switch a { color: var(--amber); text-decoration: none; }

/* ── APP SHELL ────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; }

/* Header */
.app-header {
  display: flex; align-items: center; gap: 0;
  background: var(--dark);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  position: sticky; top: 0; z-index: 100;
  flex-shrink: 0;
}
.header-logo { font-family: var(--font-display); font-size: 22px; letter-spacing: .1em; margin-right: 32px; }
.header-tabs { display: flex; align-items: center; gap: 2px; flex: 1; }
.tab {
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-family: var(--font-ui);
  padding: 6px 18px;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  transition: color .15s, background .15s;
  position: relative;
  top: 1px;
}
.tab:hover { color: var(--text); }
.tab.active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 1px solid var(--surface);
}
.icon-tab { font-size: 16px; padding: 4px 12px; }
.header-user { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.username-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--amber);
  background: rgba(245,166,35,.1);
  padding: 3px 10px;
  border-radius: 2px;
  border: 1px solid rgba(245,166,35,.25);
}
.username-badge::before { content: '@'; }

/* Tab content */
.tab-content { display: none; flex: 1; overflow-y: auto; padding: 28px 32px; }
.tab-content.active { display: block; }
.section-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.section-title { font-family: var(--font-display); font-size: 32px; letter-spacing: .08em; color: var(--text); }

/* ── SCREENPLAY GRID ──────────────────────────────────────── */
.screenplay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}
.screenplay-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  cursor: pointer;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.screenplay-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: var(--amber); opacity: 0;
  transition: opacity .2s;
}
.screenplay-card:hover { border-color: var(--amber-dim); transform: translateY(-2px); box-shadow: var(--shadow); }
.screenplay-card:hover::before { opacity: 1; }

.sc-title { font-family: var(--font-display); font-size: 22px; letter-spacing: .06em; color: var(--text); }
.sc-subtitle { font-size: 12px; color: var(--muted); }
.sc-author { font-size: 13px; font-weight: 500; margin-top: 8px; }
.sc-meta { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.sc-conf { font-size: 10px; color: var(--dim); letter-spacing: .08em; text-transform: uppercase; }
.sc-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ── MOVIE GRID ───────────────────────────────────────────── */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
.movie-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color .2s, transform .15s;
}
.movie-card:hover { border-color: var(--amber-dim); transform: translateY(-2px); }
.movie-poster {
  width: 100%; aspect-ratio: 2/3;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  overflow: hidden;
}
.movie-poster img { width: 100%; height: 100%; object-fit: cover; }
.movie-card-title { padding: 12px 14px; font-weight: 600; font-size: 13px; }

/* ── TEAMS ────────────────────────────────────────────────── */
.teams-list { display: flex; flex-direction: column; gap: 12px; max-width: 860px; }
.team-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.team-row-header {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 20px;
  cursor: pointer;
}
.team-name { font-weight: 600; font-size: 15px; flex: 1; }
.team-desc { font-size: 12px; color: var(--muted); flex: 2; }
.team-expand-body { display: none; padding: 0 20px 20px; border-top: 1px solid var(--border); }
.team-expand-body.open { display: block; }
.team-member-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.team-member-row:last-child { border-bottom: none; }
.member-role { background: var(--surface2); padding: 3px 10px; border-radius: 2px; font-family: var(--font-mono); font-size: 11px; }
.member-name { flex: 1; }
.member-username { color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
.perms { display: flex; gap: 10px; align-items: center; font-size: 11px; color: var(--muted); }

/* ── SETTINGS ─────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 900px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.settings-card h3 { font-size: 14px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--amber); margin-bottom: 4px; }
.settings-card h4 { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-top: 8px; }
.roles-list { display: flex; flex-wrap: wrap; gap: 8px; }
.role-chip { display: flex; align-items: center; gap: 6px; background: var(--surface2); border: 1px solid var(--border2); border-radius: 2px; padding: 4px 10px; font-family: var(--font-mono); font-size: 11px; }
.role-chip.active { border-color: var(--amber); color: var(--amber); }
.role-chip button { background: none; color: var(--dim); font-size: 12px; padding: 0 2px; line-height: 1; }
.role-add-row { display: flex; gap: 8px; }
.role-add-row input { flex: 1; }
.channel-row { display: flex; gap: 8px; margin-bottom: 8px; }
.channel-row input { flex: 1; }

/* ── SCREENPLAY EDITOR ────────────────────────────────────── */
.editor-overlay {
  position: fixed; inset: 0;
  background: var(--black);
  z-index: 500;
  display: flex; flex-direction: column;
}
.editor-shell { display: flex; flex-direction: column; height: 100%; }

/* Editor header */
.editor-header {
  background: var(--dark);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  padding: 0 16px;
}
.editor-title-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0;
  flex-wrap: wrap;
}
.ed-screenplay-title {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: .08em;
  color: var(--text);
  flex-shrink: 0;
}
.ed-share-group { display: flex; align-items: center; gap: 6px; margin-left: 8px; }
.notif-badge {
  background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.bookmark-select { width: 150px; font-size: 11px; padding: 4px 8px; }
.ed-line-group { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-left: auto; }
.line-input { width: 60px; text-align: center; font-family: var(--font-mono); font-size: 12px; }

/* Element toolbar */
.element-toolbar {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  overflow-x: auto;
}
.el-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius);
  white-space: nowrap;
  font-family: var(--font-ui);
  transition: color .15s, border-color .15s;
}
.el-btn:hover  { color: var(--text); border-color: var(--border2); }
.el-btn.active { color: var(--amber); border-color: var(--amber); background: rgba(245,166,35,.08); }
.el-toolbar-right { margin-left: auto; display: flex; gap: 4px; }
.icon-btn { background: transparent; color: var(--muted); font-size: 15px; padding: 4px 7px; border-radius: var(--radius); transition: color .15s; cursor: pointer; border: none; }
.icon-btn:hover { color: var(--amber); }
.icon-btn.active { color: var(--cyan); }

/* Timeline */
.timeline-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); font-family: var(--font-mono);
}
.tl-track { flex: 1; height: 6px; background: var(--surface2); border-radius: 3px; position: relative; overflow: hidden; }
.tl-progress { height: 100%; background: var(--amber); border-radius: 3px; transition: width .3s; }
.tl-runtime { color: var(--amber); font-size: 11px; }

/* Editor body */
.editor-body {
  display: flex; flex: 1; overflow: hidden;
}
.editor-main {
  display: flex; flex: 1; overflow-y: auto;
  background: var(--dark);
}
.line-numbers {
  padding: 24px 0;
  min-width: 48px;
  background: var(--dark);
  text-align: right;
  padding-right: 14px;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 12px;
  user-select: none;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
}
.line-number-item { height: 22px; line-height: 22px; }

/* Screenplay content */
.screenplay-content {
  flex: 1;
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 24px 80px;
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 13px;
  line-height: 22px;
  color: var(--text);
  outline: none;
  white-space: pre-wrap;
}
/* Line type styling applied via data-type on .sc-line divs */
.sc-line { margin: 0; padding: 0 0 2px; min-height: 22px; }
.sc-line[data-type="scene_heading"] { text-transform: uppercase; font-weight: 700; color: #fff; margin-top: 16px; text-decoration: underline; }
.sc-line[data-type="character"] { text-transform: uppercase; margin-left: 200px; margin-top: 14px; color: var(--amber); }
.sc-line[data-type="dialogue"] { margin-left: 120px; margin-right: 120px; }
.sc-line[data-type="parenthetical"] { margin-left: 160px; margin-right: 160px; color: var(--muted); }
.sc-line[data-type="transition"] { text-align: right; text-transform: uppercase; color: var(--muted); margin-top: 12px; }
.sc-line[data-type="shot"] { text-transform: uppercase; color: var(--cyan); }
.sc-line[data-type="voice_over"] { margin-left: 120px; margin-right: 120px; font-style: italic; color: var(--muted); }

/* Notes sidebar */
.editor-sidebar {
  width: 320px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 12px; }
.note-line-ref { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.notes-list { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }

.note-card {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12px;
}
.note-card.active-reply { border-color: var(--cyan); }
.note-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.note-author { font-weight: 600; font-size: 11px; color: var(--amber); }
.note-line-ref-badge { font-family: var(--font-mono); font-size: 10px; color: var(--dim); margin-left: auto; }
.note-actions { display: flex; gap: 8px; margin-top: 8px; }
.note-actions button { background: none; color: var(--muted); font-size: 11px; border: none; cursor: pointer; }
.note-actions button:hover { color: var(--text); }

/* Storyboard card */
.storyboard-card {
  background: var(--surface2);
  border: 1px solid var(--amber-dim);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 11px;
}
.storyboard-card-header { font-family: var(--font-mono); font-size: 10px; color: var(--cyan); margin-bottom: 6px; }

/* ── MODALS ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 900;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(3px);
}
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: min(520px, 94vw);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
}
.modal-close { position: absolute; top: 14px; right: 16px; background: none; color: var(--muted); font-size: 18px; }
.modal-close:hover { color: var(--text); }
.modal-box h2 { font-family: var(--font-display); font-size: 28px; letter-spacing: .08em; margin-bottom: 24px; }
.modal-box label { margin-bottom: 14px; }
.modal-box select { margin-bottom: 14px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.modal-section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.modal-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; }

/* ── TOAST ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 13px;
  padding: 10px 22px;
  border-radius: 100px;
  box-shadow: var(--shadow);
  z-index: 9999;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .25s;
  opacity: 0;
  pointer-events: none;
}
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); color: var(--green); }
.toast.error   { border-color: var(--red);   color: var(--red); }

/* ── SCROLLBARS ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--dim); }

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .screenplay-grid { grid-template-columns: 1fr; }
  .settings-grid   { grid-template-columns: 1fr; }
  .settings-card.span2 { grid-column: span 1; }
  .editor-sidebar  { display: none; }
  .ed-screenplay-title { font-size: 18px; }
}
