/* Aftomatik~Səs — design tokens and styles */

:root {
  --bg-base: #0f1117;
  --bg-surface: #1a1d27;
  --bg-elevated: #232734;
  --bg-input: #2a2e3c;

  --text-primary: #e8eaed;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --border: #2d3142;
  --border-light: #3a3f52;

  --accent: #4f8fff;
  --accent-hover: #6ba1ff;
  --accent-muted: #1e3a5f;

  --ok: #34d399;
  --ok-bg: #0a2e24;
  --warn: #fbbf24;
  --warn-bg: #2a2005;
  --danger: #f87171;
  --danger-bg: #2e0a0a;

  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 24px;

  --shadow-1: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-2: 0 4px 16px rgba(0,0,0,0.4);

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --font-sans: "Segoe UI", "Arial", "Helvetica", sans-serif;
  --font-mono: "Cascadia Code", "Fira Code", monospace;

  --transition: 150ms ease;
  --transition-slow: 300ms ease;

  --max-width: 1200px;
}

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

html, body {
  height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }

/* ─── TOPBAR ─── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: var(--space-sm);
}
.brand { display: flex; align-items: center; gap: var(--space-sm); }
.logo {
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.topbar h1 { font-size: 14px; font-weight: 600; line-height: 1.2; }
.tagline { font-size: 11px; color: var(--text-muted); }
.topbar-right { display: flex; gap: var(--space-sm); align-items: center; flex-wrap: wrap; }

/* ─── BADGES ─── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 500;
  background: var(--bg-elevated); color: var(--text-secondary);
  border: 1px solid var(--border);
}
.badge-ok { background: var(--ok-bg); color: var(--ok); border-color: #1a4f3a; }
.badge-warn { background: var(--warn-bg); color: var(--warn); border-color: #4a3505; }

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  user-select: none; min-height: 36px;
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:not(:disabled):hover { filter: brightness(1.1); }
.btn:not(:disabled):active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--bg-elevated); border-color: var(--border); color: var(--text-primary); }
.btn.danger { background: var(--danger-bg); border-color: #5a1a1a; color: var(--danger); }
.btn.sm, .sm { padding: 5px 10px; font-size: 12px; min-height: 28px; }

/* ─── SCREENS ─── */
.screen {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--space-md);
  scroll-behavior: smooth;
}

/* ─── UPLOAD ─── */
.upload-card {
  max-width: 640px; margin: 0 auto;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-xl);
  text-align: center;
}
.dropzone {
  border: 2px dashed var(--border-light); border-radius: var(--radius-md);
  padding: 40px 20px; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-sm);
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag {
  border-color: var(--accent); background: var(--accent-muted);
  outline: none;
}
.dz-icon { font-size: 40px; color: var(--text-muted); }
.dz-title { font-size: 15px; font-weight: 500; }
.dz-sub { font-size: 12px; color: var(--text-muted); }
.privacy-note {
  margin-top: var(--space-md); font-size: 12px; color: var(--text-secondary);
  line-height: 1.5;
}
.hint { font-size: 12px; color: var(--text-muted); padding: var(--space-sm); }
.projects-section { max-width: 640px; margin: var(--space-lg) auto 0; }
.projects-section h2 { font-size: 13px; color: var(--text-secondary); margin-bottom: var(--space-sm); }

/* ─── PROGRESS ─── */
.progress-card {
  max-width: 480px; margin: 60px auto; text-align: center;
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: var(--space-xl);
}
.progress-label { font-size: 13px; color: var(--text-secondary); margin-top: var(--space-sm); }
.progress-track {
  height: 6px; background: var(--bg-elevated); border-radius: 99px;
  overflow: hidden; margin-top: var(--space-sm);
}
.progress-fill {
  height: 100%; background: var(--accent); border-radius: 99px;
  transition: width 200ms ease; width: 0%;
}

/* ─── EDITOR GRID ─── */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--space-md);
  max-width: var(--max-width);
  margin: 0 auto;
  align-items: start;
}
.preview-pane { display: flex; flex-direction: column; gap: var(--space-sm); }
.video-wrap {
  position: relative; background: #000; border-radius: var(--radius-sm);
  overflow: hidden; aspect-ratio: 16/9;
}
.video-wrap video { width: 100%; height: 100%; display: block; }
.sub-overlay {
  position: absolute; left: 0; right: 0; bottom: 8%;
  display: flex; justify-content: center; pointer-events: none;
  z-index: 10; padding: 0 var(--space-md);
}
.sub-overlay .line { display: inline-block; padding: 3px 10px; border-radius: var(--radius-xs); text-align: center; white-space: pre-wrap; }

.tl {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); height: 48px; position: relative;
  overflow: hidden; user-select: none; cursor: crosshair;
}
.tl-track { position: absolute; inset: 0; }
.tl-playhead {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--danger); opacity: 0.8; left: 0%; z-index: 5;
}
.tl-cue {
  position: absolute; top: 8px; bottom: 8px;
  background: var(--accent-muted); border: 1px solid var(--accent);
  border-radius: var(--radius-xs); cursor: ew-resize;
  display: flex; align-items: center; padding: 0 4px; min-width: 4px;
  transition: background var(--transition);
}
.tl-cue:hover { background: rgba(79,143,255,0.25); }
.tl-cue.sel { background: rgba(79,143,255,0.35); border-color: var(--accent-hover); }
.tl-label {
  font-size: 10px; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  pointer-events: none;
}

/* ─── SIDE PANE ─── */
.side-pane {
  background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); overflow: hidden;
  display: flex; flex-direction: column; max-height: calc(100vh - 80px);
}
.editor-tabs {
  display: flex; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.editor-tab {
  flex: 1; padding: 10px 8px; background: none; border: none;
  border-bottom: 2px solid transparent; cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--text-muted); transition: color var(--transition), border-color var(--transition);
}
.editor-tab:hover { color: var(--text-primary); }
.editor-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { overflow-y: auto; flex: 1; padding: var(--space-md); }
.list-toolbar { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-bottom: var(--space-sm); }
.cue-list { display: flex; flex-direction: column; gap: var(--space-xs); }

.cue-item {
  display: grid; grid-template-columns: 90px 1fr;
  gap: var(--space-sm); align-items: start;
  padding: var(--space-sm); border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border);
  cursor: pointer; transition: border-color var(--transition);
}
.cue-item:hover { border-color: var(--border-light); }
.cue-item.active { border-color: var(--accent); background: var(--accent-muted); }
.cue-time {
  font-size: 11px; font-family: var(--font-mono);
  color: var(--text-secondary); padding-top: 6px;
  cursor: pointer; white-space: nowrap;
}
.cue-time:hover { color: var(--accent); }
.cue-text {
  width: 100%; background: var(--bg-input); border: 1px solid transparent;
  border-radius: var(--radius-xs); color: var(--text-primary);
  font: inherit; font-size: 13px; padding: 6px 8px;
  resize: vertical; min-height: 32px; max-height: 120px;
  transition: border-color var(--transition);
}
.cue-text:focus { outline: none; border-color: var(--accent); }
.cue-text.dirty { background: #1a2020; }

/* ─── STYLE FORM ─── */
.style-form { display: flex; flex-direction: column; gap: var(--space-sm); }
.style-form label { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--text-secondary); }
.style-form input[type="range"] { width: 100%; }
.style-form input[type="color"] { width: 36px; height: 28px; padding: 2px; }
.style-form select { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); border-radius: var(--radius-xs); padding: 4px 6px; font: inherit; }
.check-fieldset {
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  padding: var(--space-sm); display: flex; gap: var(--space-md); flex-wrap: wrap;
}
.check-fieldset label { flex-direction: row; align-items: center; gap: 4px; }
.check-fieldset legend { font-size: 12px; color: var(--text-secondary); padding: 0 4px; }
.style-form output { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.inline { flex-direction: row !important; align-items: center !important; }

/* ─── EXPORT ─── */
.export-actions { display: flex; flex-direction: column; gap: var(--space-xs); }
hr { border: none; border-top: 1px solid var(--border); margin: var(--space-md) 0; }
.proj-list { display: flex; flex-direction: column; gap: var(--space-xs); margin-top: var(--space-sm); }
.proj-item {
  display: flex; align-items: center; gap: var(--space-sm);
  padding: var(--space-sm); border-radius: var(--radius-sm);
  background: var(--bg-elevated); border: 1px solid var(--border);
  flex-wrap: wrap;
}
.p-name { flex: 1; font-size: 13px; font-weight: 500; min-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-meta { font-size: 11px; color: var(--text-muted); }

/* ─── TOAST ─── */
.toast {
  position: fixed; bottom: var(--space-lg); left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated); border: 1px solid var(--border-light);
  color: var(--text-primary); padding: 10px 20px;
  border-radius: var(--radius-sm); font-size: 13px;
  z-index: 1000; box-shadow: var(--shadow-2);
  max-width: 90vw; text-align: center;
}
.toast.toast-error { border-color: var(--danger); color: var(--danger); }
.toast[hidden] { display: none; }

/* ─── ANIMATIONS ─── */
@keyframes ov-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ov-pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.ov-fade { animation: ov-fade 160ms ease; }
.ov-pop { animation: ov-pop 180ms ease; }

/* ─── RESPONSIVE ─── */
@media (max-width: 860px) {
  .editor-grid { grid-template-columns: 1fr; }
  .side-pane { max-height: none; position: static; }
  .topbar h1 { display: none; }
  .topbar-right { gap: 4px; }
  .badge { font-size: 10px; padding: 2px 6px; }
  .btn { padding: 7px 10px; font-size: 12px; min-height: 32px; }
  .cue-item { grid-template-columns: 80px 1fr; }
}
@media (max-width: 480px) {
  .upload-card { padding: var(--space-md); }
  .screen { padding: var(--space-sm); }
  .topbar { padding: var(--space-xs) var(--space-sm); }
  .logo { width: 28px; height: 28px; font-size: 11px; }
  .editor-tab { font-size: 11px; padding: 8px 6px; }
}

/* ─── UTILITY ─── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: #fff; }

/* ─── ANIMATIONS FOR OVERLAY ─── */
.sub-overlay .line.fade { animation: ov-fade 160ms ease; }
.sub-overlay .line.pop { animation: ov-pop 180ms ease; }