/* ============================================================
   SubtitleAI Pro — Design System (proMOTION Apple Glass Dark Red)
   ============================================================ */

:root {
  --bg:           #060608;
  --bg-alt:       #0b0b0e;

  --s1:           rgba(255,255,255,0.038);
  --s2:           rgba(255,255,255,0.065);
  --s3:           rgba(255,255,255,0.10);

  --b1:           rgba(255,255,255,0.07);
  --b2:           rgba(255,255,255,0.13);
  --b3:           rgba(255,255,255,0.22);

  --red:          #D4111A;
  --red-2:        #E8202A;
  --red-glow:     rgba(212,17,26,0.22);
  --red-soft:     rgba(212,17,26,0.10);
  --red-softer:   rgba(212,17,26,0.06);

  --text:         #F0F0F2;
  --text-2:       rgba(240,240,242,0.50);
  --text-3:       rgba(240,240,242,0.26);

  --green:        #30D158;
  --green-soft:   rgba(48,209,88,0.10);
  --orange:       #FF9F0A;
  --orange-soft:  rgba(255,159,10,0.12);

  --blur-sm: 16px;
  --blur-md: 28px;
  --blur-lg: 56px;

  --r-xs: 8px;
  --r-sm: 12px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 32px;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --t: 0.22s;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  padding-bottom: 60px;
}

/* ── Background atmosphere ── */
.bg-atmosphere {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0; overflow: hidden;
}
.bg-atmosphere::before {
  content: '';
  position: absolute; top: -40%; left: 50%; translate: -50% 0;
  width: 120vw; height: 70vh;
  background: radial-gradient(ellipse, rgba(212,17,26,0.10) 0%, transparent 70%);
  filter: blur(1px);
}
.bg-atmosphere::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 90% 80% at 50% 0%, black 0%, transparent 80%);
}

/* ── Glass card ── */
.glass {
  background: linear-gradient(160deg, var(--s2) 0%, var(--s1) 100%);
  backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-lg)) saturate(160%);
  border: 1px solid var(--b1);
  border-top-color: var(--b2);
  position: relative;
}
.glass::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: inherit;
  background: linear-gradient(to bottom, rgba(255,255,255,0.055) 0%, transparent 50%);
  pointer-events: none;
}

/* ── Buttons ── */
.btn-primary {
  background: var(--red);
  color: #fff; width: 100%; height: 52px;
  font-size: 15px; font-weight: 600;
  border: none; border-radius: var(--r-sm);
  box-shadow: 0 8px 32px var(--red-glow), 0 1px 0 rgba(255,255,255,0.15) inset;
  cursor: pointer; transition: all var(--t) var(--ease);
  letter-spacing: 0.01em;
}
.btn-primary:hover:not(:disabled) {
  background: var(--red-2);
  transform: translateY(-1px);
  box-shadow: 0 12px 40px var(--red-glow);
}
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-ghost {
  background: var(--s1); color: var(--text-2);
  border: 1px solid var(--b1); border-top-color: var(--b2);
  height: 40px; font-size: 13px; font-weight: 600;
  padding: 0 16px; border-radius: var(--r-xs);
  backdrop-filter: blur(16px); cursor: pointer;
  transition: all var(--t) var(--ease);
  white-space: nowrap;
}
.btn-ghost:hover:not(:disabled) { background: var(--s2); color: var(--text); }
.btn-ghost:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-icon {
  width: 36px; height: 36px;
  background: var(--s1); color: var(--text-2);
  border: 1px solid var(--b1); border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--t) var(--ease);
  font-size: 16px;
}
.btn-icon:hover { background: var(--s2); color: var(--text); }

/* ── Inputs ── */
label {
  display: block; font-size: 11px; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 10px;
}
.input, select.input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--b1);
  border-top-color: var(--b2);
  border-radius: var(--r-sm);
  color: var(--text);
  font-family: inherit; font-size: 15px;
  padding: 14px 18px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  -webkit-appearance: none;
}
.input:focus, select.input:focus {
  border-color: var(--b3);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.04);
}
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M0 0l6 8 6-8z' fill='rgba(255,255,255,0.3)'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px; }
textarea.input { resize: vertical; min-height: 80px; padding: 12px 18px; }

/* ── Form group ── */
.form-group { margin-bottom: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Toast ── */
.toast-container {
  position: fixed; bottom: 80px; right: 24px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500;
  backdrop-filter: blur(20px); border: 1px solid var(--b2);
  animation: toast-in 0.3s var(--ease);
  max-width: 340px;
}
.toast.success { background: rgba(48,209,88,0.15);  color: #30D158; border-color: rgba(48,209,88,0.25); }
.toast.error   { background: rgba(212,17,26,0.15);  color: #ff6060; border-color: rgba(212,17,26,0.25); }
.toast.info    { background: var(--s2); color: var(--text); }
.toast.warning { background: var(--orange-soft); color: var(--orange); border-color: rgba(255,159,10,0.25); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(0.95); } }

/* ── Footer ── */
/* ── Scroll hint button ── */
@keyframes bounce-down {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(5px); }
}
#scroll-hint {
  position: fixed;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 150;
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--b2);
  background: rgba(28,28,32,0.85);
  backdrop-filter: blur(12px);
  color: var(--text-2);
  font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s;
  animation: bounce-down 1.6s ease-in-out infinite;
}
#scroll-hint.visible { opacity: 1; pointer-events: auto; }

.app-footer-fixed {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(8,8,10,0.65);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-top: 1px solid var(--b1);
  padding: 10px 24px;
  text-align: center;
}
.app-footer-text { font-size: 12px; color: rgba(240,240,242,0.25); }
.app-footer-text a { color: rgba(212,17,26,0.7); text-decoration: none; font-weight: 600; }

/* ── Progress steps ── */
.progress-steps { display: flex; flex-direction: column; gap: 12px; }
.step {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 18px; border-radius: var(--r-sm);
  background: var(--s1); border: 1px solid var(--b1);
  transition: all var(--t) var(--ease);
}
.step.active  { background: var(--red-softer); border-color: rgba(212,17,26,0.2); }
.step.done    { background: var(--green-soft); border-color: rgba(48,209,88,0.2); }
.step.error   { background: rgba(212,17,26,0.08); border-color: rgba(212,17,26,0.25); }
.step-icon { font-size: 18px; width: 28px; text-align: center; flex-shrink: 0; }
.step-label { font-size: 14px; font-weight: 500; color: var(--text-2); }
.step.active .step-label, .step.done .step-label { color: var(--text); }

/* ── Spinner ── */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--b2);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
}
.badge-company    { background: rgba(0,122,255,0.15); color: #409cff; }
.badge-product    { background: var(--red-softer); color: var(--red-2); }
.badge-person     { background: var(--green-soft); color: var(--green); }
.badge-technical  { background: var(--orange-soft); color: var(--orange); }
.badge-other      { background: var(--s2); color: var(--text-2); }
.badge-abbreviation { background: rgba(175,82,222,0.12); color: #bf5af2; }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--b2);
  border-radius: var(--r-lg);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t) var(--ease);
  background: var(--s1);
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--red);
  background: var(--red-softer);
}
.upload-zone input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; z-index: 10;
}
.upload-zone-icon,
.upload-zone-title,
.upload-zone-sub { pointer-events: none; }
.upload-zone-icon { font-size: 36px; margin-bottom: 12px; }
.upload-zone-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.upload-zone-sub   { font-size: 13px; color: var(--text-2); }
.upload-zone.has-file { border-color: var(--green); background: var(--green-soft); }
.upload-zone.has-file .upload-zone-icon::after { content: ' ✓'; }

/* ── Video zone — pulsing red glow before file is selected ── */
@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,59,48,0); border-color: var(--red); }
  50%       { box-shadow: 0 0 18px 4px rgba(255,59,48,0.22); border-color: var(--red); }
}
.upload-zone-video {
  border-color: var(--red);
  background: var(--red-softer);
  animation: pulse-red 2.8s ease-in-out infinite;
}
.upload-zone-video:hover,
.upload-zone-video.drag-over {
  animation: none;
  box-shadow: 0 0 24px 6px rgba(255,59,48,0.28);
}
.upload-zone-video.has-file {
  animation: none;
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: none;
}

/* ── Glossary grid ── */
.glossary-grid { display: flex; flex-direction: column; gap: 6px; }
.glossary-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--r-sm);
  background: var(--s1); border: 1px solid var(--b1);
  transition: background var(--t);
}
.glossary-item:hover { background: var(--s2); }
.glossary-item-term { font-size: 14px; font-weight: 600; flex: 1; }
.glossary-item-ctx  { font-size: 12px; color: var(--text-2); flex: 2; }
.glossary-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.btn-icon-edit { color: var(--text-2); }
.btn-icon-edit:hover { color: var(--accent); background: rgba(10,132,255,0.1); }

.glossary-edit-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(10,132,255,0.05);
  border: 1px solid rgba(10,132,255,0.2);
  border-top: none;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  margin-top: -4px;
}

/* ── SRT Editor layout ── */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 20px;
  height: calc(100vh - 140px);
}
.video-panel {
  position: relative;
  border-radius: var(--r-lg);
  overflow: hidden;
  background: #000;
  display: flex; align-items: center; justify-content: center;
}
#video-player {
  width: 100%; height: 100%;
  object-fit: contain;
  max-height: 100%;
}
.subtitle-overlay {
  position: absolute; bottom: 10%;
  left: 50%; translate: -50% 0;
  background: rgba(0,0,0,0.72);
  color: #fff;
  font-size: clamp(14px, 2vw, 20px);
  font-weight: 500;
  line-height: 1.4;
  padding: 6px 18px;
  border-radius: 6px;
  text-align: center;
  pointer-events: none;
  max-width: 90%;
  white-space: pre-line;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
  display: none;
}
.subtitle-overlay.visible { display: block; }

.srt-panel {
  display: flex; flex-direction: column;
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--r-lg);
  overflow: hidden;
}
.srt-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--b1);
  flex-shrink: 0;
}
.srt-toolbar-title { font-size: 12px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); flex: 1; }

.srt-list {
  flex: 1; overflow-y: auto;
  padding: 8px;
  display: flex; flex-direction: column; gap: 4px;
}
.srt-list::-webkit-scrollbar { width: 4px; }
.srt-list::-webkit-scrollbar-track { background: transparent; }
.srt-list::-webkit-scrollbar-thumb { background: var(--b2); border-radius: 2px; }

.srt-block {
  border-radius: var(--r-sm);
  border: 1px solid var(--b1);
  background: var(--s1);
  padding: 10px 12px;
  cursor: pointer;
  transition: all var(--t) var(--ease);
}
.srt-block:hover { background: var(--s2); }
.srt-block.active { border-color: var(--red); background: var(--red-softer); }
.srt-block.flagged { border-color: var(--orange); background: var(--orange-soft); }
.srt-block-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.srt-block-num { font-size: 11px; color: var(--text-3); font-weight: 700; min-width: 24px; }
.srt-time { font-size: 11px; color: var(--text-2); font-family: 'SF Mono', 'Fira Code', monospace; }
.srt-flag-icon { color: var(--orange); font-size: 13px; }
.btn-add-glossary {
  background: none; border: none; color: var(--text-3); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 4px; border-radius: var(--r-xs);
  transition: color var(--t) var(--ease), background var(--t) var(--ease);
  opacity: 0;
}
.srt-block:hover .btn-add-glossary { opacity: 1; }
.btn-add-glossary:hover { color: var(--accent); background: rgba(10,132,255,0.12); }
.glossary-quick-add {
  margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.glossary-quick-add-inner {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.glossary-quick-add input {
  flex: 1; min-width: 100px; height: 28px; padding: 0 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--r-xs); color: var(--text-1); font-size: 12px;
  outline: none;
}
.glossary-quick-add input:focus { border-color: var(--accent); }
.srt-block-text {
  font-size: 13px; line-height: 1.5;
  white-space: pre-line;
  outline: none;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
  transition: background 0.15s;
}
.srt-block-text:focus { background: rgba(255,255,255,0.05); }
.flag-hint { font-size: 11px; color: var(--orange); margin-top: 4px; }
.flag-hint-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 5px;
}
.flag-hint-text { display: flex; align-items: center; gap: 5px; flex: 1; min-width: 0; }
.flag-orig  { color: var(--text-3); text-decoration: line-through; font-size: 11px; }
.flag-arrow { color: var(--text-3); font-size: 11px; }
.flag-corr  { color: var(--orange); font-size: 11px; font-weight: 600; }
.flag-conf  { color: var(--text-3); font-size: 10px; }
.btn-accept-suggestion {
  flex-shrink: 0; height: 24px; padding: 0 10px;
  font-size: 11px; font-weight: 600;
  background: var(--orange-soft); color: var(--orange);
  border: 1px solid rgba(255,159,10,0.25); border-radius: var(--r-xs);
  cursor: pointer; transition: all var(--t) var(--ease);
  white-space: nowrap;
}
.btn-accept-suggestion:hover { background: rgba(255,159,10,0.2); }

/* ── Nav bar ── */
.app-nav {
  display: flex; align-items: center; gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--b1);
  background: rgba(6,6,8,0.6);
  backdrop-filter: blur(20px);
  position: sticky; top: 0; z-index: 50;
}
.app-nav-logo { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }
.app-nav-logo span { color: var(--red); }
.app-nav-steps { display: flex; gap: 4px; flex: 1; justify-content: center; }
.nav-step {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  padding: 6px 14px; border-radius: 20px;
  color: var(--text-3);
  transition: all var(--t);
}
.nav-step.active { color: var(--text); background: var(--s2); }
.nav-step.done   { color: var(--green); }

/* ── Section layout ── */
.section { display: none; }
.section.visible { display: block; }

main { padding: 24px 24px 80px; max-width: 1400px; margin: 0 auto; position: relative; z-index: 1; }

/* ── Headings ── */
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 16px; font-weight: 600; }
.section-header { margin-bottom: 28px; }
.section-header p { color: var(--text-2); font-size: 14px; margin-top: 6px; }

/* ── Setup grid ── */
.setup-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.upload-zones-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }

/* ── Options row ── */
.options-row { display: flex; gap: 12px; align-items: flex-end; }
.options-row .form-group { flex: 1; }
.options-row .form-group:last-child { margin-bottom: 0; }

/* ── Scrollbar global ── */
* { scrollbar-width: thin; scrollbar-color: var(--b2) transparent; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .editor-layout { grid-template-columns: 1fr; height: auto; }
  .srt-panel { height: 400px; }
  .setup-grid { grid-template-columns: 1fr; }
  .upload-zones-grid { grid-template-columns: 1fr; }
}

/* ── Login page specific ── */
.login-wrap {
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  position: relative; z-index: 1;
}
.login-card {
  width: 100%; max-width: 420px;
  border-radius: var(--r-xl);
  padding: 48px 40px;
}
.login-logo { text-align: center; margin-bottom: 36px; }
.login-logo-title { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.login-logo-sub { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.login-logo-badge {
  display: inline-block; margin-bottom: 16px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--red); background: var(--red-softer); border: 1px solid rgba(212,17,26,0.2);
  padding: 4px 12px; border-radius: 20px;
}

/* ── Divider ── */
.divider { height: 1px; background: var(--b1); margin: 20px 0; }

/* ── Engine selection cards ───────────────────────────────────────── */
.engine-card {
  display: block;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--b1);
  background: var(--s1);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  /* Reset global label styles */
  text-transform: none;
  letter-spacing: normal;
  font-size: inherit;
  font-weight: 400;
  color: var(--text);
}
.engine-card:hover { border-color: var(--accent); }
.engine-card.selected {
  border-color: var(--accent);
  background: rgba(10,132,255,0.08);
}
.engine-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.engine-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
}
.engine-card.selected .engine-card-name { color: #409cff; }
.engine-card-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  border: 1.5px solid var(--b2);
  font-size: 10px; font-weight: 700;
  color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}
.engine-card.selected .engine-card-check {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.engine-card-speed { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.engine-card-desc { font-size: 13px; color: var(--text-2); line-height: 1.6; font-weight: 400; }
.engine-card-desc strong, .engine-card-desc b { font-weight: 400; }
.engine-card-em { font-weight: 600; color: var(--text-1); }

/* ── Animated loading dots ── */
.loading-dots::after {
  content: '';
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots {
  0%   { content: ''; }
  25%  { content: '.'; }
  50%  { content: '..'; }
  75%  { content: '...'; }
  100% { content: ''; }
}

/* ── File list ── */
.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.file-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--r-xs);
  background: var(--s1); font-size: 13px;
}
.file-item-name { flex: 1; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item-size { font-size: 11px; color: var(--text-3); flex-shrink: 0; }
.file-item-remove { cursor: pointer; color: var(--text-3); font-size: 14px; flex-shrink: 0; transition: color 0.15s; }
.file-item-remove:hover { color: var(--red); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 60px 24px; color: var(--text-3); }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 14px; }
