/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0b0b10;
  --surface: rgba(255,255,255,0.04);
  --surface-hover: rgba(255,255,255,0.07);
  --border: rgba(255,255,255,0.08);
  --accent: #7c3aed;
  --accent-light: #a855f7;
  --accent-glow: rgba(124, 58, 237, 0.35);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 4px 32px rgba(0,0,0,0.5);
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ===== Background Orbs ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.18;
}
.orb-1 { width: 500px; height: 500px; background: #7c3aed; top: -150px; left: -100px; }
.orb-2 { width: 400px; height: 400px; background: #2563eb; bottom: -100px; right: -100px; }
.orb-3 { width: 300px; height: 300px; background: #10b981; top: 50%; left: 50%; transform: translate(-50%,-50%); opacity: 0.08; }

/* ===== Layout ===== */
.container {
  position: relative;
  z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

/* ===== Header ===== */
.header {
  text-align: center;
  margin-bottom: 36px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.logo-text {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, #a855f7, #60a5fa);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.header-sub {
  color: var(--text-muted);
  font-size: 14px;
}

/* ===== Card ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  background: rgba(0,0,0,0.2);
  padding: 5px;
  border-radius: var(--radius-sm);
  width: fit-content;
}
.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.tab.active { background: var(--accent); color: white; }

/* ===== Tab Panes ===== */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ===== URL Textarea ===== */
.url-input-wrap { position: relative; }
.url-textarea {
  width: 100%;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', monospace;
  font-size: 13.5px;
  line-height: 1.7;
  padding: 14px 16px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
  min-height: 120px;
}
.url-textarea:focus { border-color: var(--accent); }
.url-textarea::placeholder { color: var(--text-muted); }

.paste-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  color: var(--accent-light);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}
.paste-btn:hover { background: rgba(124,58,237,0.3); }

/* ===== CSV Drop Zone ===== */
.csv-drop-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 36px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}
.csv-drop-zone:hover,
.csv-drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(124,58,237,0.05);
  color: var(--text);
}
.drop-title { font-weight: 500; font-size: 14px; }
.drop-sub { font-size: 12px; }

/* ===== Options Grid ===== */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 16px;
  margin-top: 18px;
  align-items: end;
}
@media (max-width: 580px) {
  .options-grid { grid-template-columns: 1fr 1fr; }
  .diarize-group { grid-column: 1 / -1; }
}

.option-group { display: flex; flex-direction: column; gap: 6px; }
.option-label { font-size: 12px; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.select {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 12px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.select:focus { border-color: var(--accent); }
.select option, .select optgroup { background: #1a1a2e; color: var(--text); }

/* ===== Toggle ===== */
.toggle-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.3s;
  border: 1px solid var(--border);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }
.toggle-label { font-size: 13px; color: var(--text-muted); min-width: 24px; }

/* ===== HF Section ===== */
.hf-section {
  margin-top: 14px;
  padding: 14px 16px;
  background: rgba(245,158,11,0.05);
  border: 1px solid rgba(245,158,11,0.2);
  border-radius: var(--radius-sm);
}
.hf-inner { display: flex; align-items: center; gap: 10px; }
.hf-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'Inter', monospace;
  font-size: 13px;
  outline: none;
}
.hf-input::placeholder { color: var(--text-muted); }
.hf-configured { align-items: center; gap: 8px; }
.hf-link { font-size: 12px; color: var(--accent-light); text-decoration: none; white-space: nowrap; }
.hf-link:hover { text-decoration: underline; }

/* ===== Transcribe Button ===== */
.transcribe-btn {
  width: 100%;
  margin-top: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px;
  background: linear-gradient(135deg, var(--accent), #2563eb);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 20px var(--accent-glow);
}
.transcribe-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 28px var(--accent-glow); }
.transcribe-btn:active { transform: translateY(0); }
.transcribe-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== Hint ===== */
.hint {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== Section Title ===== */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text-dim);
}

/* ===== Queue Item ===== */
.queue-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.queue-item:last-child { margin-bottom: 0; }

.queue-favicon {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}
.queue-favicon-placeholder {
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  color: white;
  font-weight: 700;
}

.queue-url {
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; min-width: 120px; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-pending { background: rgba(100,116,139,0.15); color: var(--text-muted); border: 1px solid rgba(100,116,139,0.2); }
.badge-running { background: rgba(245,158,11,0.12); color: var(--warning); border: 1px solid rgba(245,158,11,0.2); }
.badge-done { background: rgba(16,185,129,0.12); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.badge-error { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }

.mini-progress {
  width: 120px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 99px;
  overflow: hidden;
}
.mini-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #60a5fa);
  border-radius: 99px;
  transition: width 0.4s ease;
  width: 0%;
}

/* ===== Result Card ===== */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  backdrop-filter: blur(20px);
}
.result-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: rgba(0,0,0,0.2);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.2s;
}
.result-header:hover { background: rgba(255,255,255,0.02); }
.result-url {
  flex: 1;
  font-size: 13px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.result-lang-badge {
  padding: 2px 8px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: 99px;
  font-size: 11px;
  color: var(--accent-light);
  font-weight: 600;
  text-transform: uppercase;
}
.collapse-icon {
  color: var(--text-muted);
  transition: transform 0.3s;
  flex-shrink: 0;
}
.result-card.collapsed .collapse-icon { transform: rotate(-90deg); }

.result-body { display: block; }
.result-card.collapsed .result-body { display: none; }

.export-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.export-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
}
.export-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); border-color: rgba(255,255,255,0.15); }
.export-btn.copied { color: var(--success); border-color: var(--success); }

/* ===== Transcript ===== */
.transcript {
  padding: 20px;
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.transcript::-webkit-scrollbar { width: 5px; }
.transcript::-webkit-scrollbar-track { background: transparent; }
.transcript::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }

.segment {
  display: flex;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 6px;
  transition: background 0.15s;
  align-items: baseline;
}
.segment:hover { background: rgba(255,255,255,0.03); }

.seg-timestamp {
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}
.seg-speaker {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  padding: 1px 7px;
  border-radius: 99px;
  margin-top: 1px;
}
.seg-text {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text);
  flex: 1;
}
/* RTL support for Arabic, Urdu, Farsi, Pashto */
.rtl-text {
  direction: rtl;
  text-align: right;
  font-family: 'Inter', 'Noto Nastaliq Urdu', 'Scheherazade New', serif;
}

/* ===== Error display ===== */
.error-box {
  padding: 16px 20px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  margin: 16px 20px;
}

/* ===== Local model path ===== */
.option-label { display: flex; justify-content: space-between; align-items: center; }
.local-path-toggle {
  font-size: 11px;
  color: var(--accent-light);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  margin-left: 8px;
}
.local-path-toggle:hover { text-decoration: underline; }
.local-path-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  position: relative;
}
.local-path-input {
  flex: 1;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Inter', monospace;
  font-size: 12px;
  padding: 7px 10px;
  outline: none;
  min-width: 0;
}
.local-path-input:focus { border-color: var(--accent); }
.local-path-input::placeholder { color: var(--text-muted); }
.browse-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  background: rgba(124,58,237,0.15);
  border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-sm);
  color: var(--accent-light);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s;
}
.browse-btn:hover { background: rgba(124,58,237,0.28); }
.cached-picker {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #1a1a2e;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 100;
  overflow: hidden;
}
.cached-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.cached-item:last-child { border-bottom: none; }
.cached-item:hover { background: rgba(255,255,255,0.06); }
.cached-name { font-weight: 500; color: var(--text); }
.cached-size { font-size: 11px; color: var(--text-muted); }
.cached-empty { color: var(--text-muted); cursor: default; justify-content: center; }

/* ===== Translate row ===== */
.translate-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.08);
  flex-wrap: wrap;
}
.translate-select {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
  flex: 1;
  min-width: 160px;
  max-width: 240px;
}
.translate-select:focus { border-color: var(--accent); }
.translate-select option, .translate-select optgroup { background: #1a1a2e; }
.translate-btn { background: rgba(16,185,129,0.12); border-color: rgba(16,185,129,0.25); color: var(--success); }
.translate-btn:hover { background: rgba(16,185,129,0.22); }

/* ===== Translation panel ===== */
.translation-panel {
  border-top: 2px solid rgba(16,185,129,0.3);
  background: rgba(16,185,129,0.03);
}
.translation-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--success);
  border-bottom: 1px solid rgba(16,185,129,0.15);
}
.translation-header strong { color: var(--text); }

/* ===== Queue timer ===== */
.queue-timer {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--warning);
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* ===== Timing breakdown bar ===== */
.timing-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,0.12);
}
.timing-bar:empty { display: none; }
.timing-pill {
  font-size: 11px;
  padding: 3px 10px;
  background: rgba(124,58,237,0.1);
  border: 1px solid rgba(124,58,237,0.2);
  border-radius: 99px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timing-pill-total {
  background: rgba(16,185,129,0.12);
  border-color: rgba(16,185,129,0.25);
  color: var(--success);
  font-weight: 600;
}

/* ===== Spinner ===== */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

/* ===== Scrollbar global ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 99px; }
