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

:root {
  --bg:        #080f1e;
  --surface:   #0d1b33;
  --surface2:  #122040;
  --border:    #1e3464;
  --border2:   #2a4880;
  --text:      #e8eeff;
  --text-dim:  #7a8fbb;
  --accent:    #d4af37;
  --accent2:   #f0cc55;
  --blue:      #3b82f6;
  --green:     #22c55e;
  --red:       #ef4444;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow:    0 4px 24px rgba(0,0,0,.45);
  --font:      'Inter', system-ui, sans-serif;
  --font-ar:   'Cairo', 'Inter', sans-serif;
  --transition: 150ms ease;
}

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8,15,30,.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 24px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-wave {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 28px;
}
.brand-wave span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
  animation: wave 1.2s ease-in-out infinite;
}
.brand-wave span:nth-child(1){ height:12px; animation-delay:0s; }
.brand-wave span:nth-child(2){ height:20px; animation-delay:.1s; }
.brand-wave span:nth-child(3){ height:28px; animation-delay:.2s; }
.brand-wave span:nth-child(4){ height:20px; animation-delay:.3s; }
.brand-wave span:nth-child(5){ height:12px; animation-delay:.4s; }

@keyframes wave {
  0%,100%{ transform:scaleY(1); }
  50%{ transform:scaleY(.4); }
}

.brand-text h1 { font-size: 1.1rem; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.brand-text p  { font-size: .75rem; color: var(--text-dim); }

.pills { display: flex; gap: 6px; margin-left: auto; }
.pill {
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { background: var(--accent); border-color: var(--accent); color: #000; font-weight: 600; }

.header-badges { display: flex; gap: 8px; }
.badge-stat {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: .72rem;
  color: var(--text-dim);
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px 60px;
  gap: 24px;
  min-height: calc(100vh - 60px);
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.sidebar-section { display: flex; flex-direction: column; gap: 8px; }
.sidebar-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
}

.mode-tabs { display: flex; flex-direction: column; gap: 2px; }
.mode-tab {
  padding: 9px 14px;
  border-radius: var(--radius);
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: .85rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: var(--transition);
}
.mode-tab:hover { background: var(--surface2); color: var(--text); }
.mode-tab.active {
  background: var(--surface2);
  color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 11px;
}

.model-list { display: flex; flex-direction: column; gap: 4px; }
.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.model-item:hover { background: var(--surface2); border-color: var(--border); }
.model-item.active {
  background: rgba(212,175,55,.08);
  border-color: rgba(212,175,55,.35);
}
.model-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
  transition: var(--transition);
}
.model-item.active .model-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.model-item-name { font-size: .83rem; font-weight: 500; color: var(--text); }
.model-item-meta { font-size: .7rem; color: var(--text-dim); }

.select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 12px;
  font-size: .85rem;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
  transition: var(--transition);
  width: 100%;
}
.select:focus { border-color: var(--accent); }

/* ── Content panels ─────────────────────────────────────────────────────── */
.content { padding: 24px 0; }
.panel { display: none; }
.panel.active { display: block; }

.panel-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.panel-header h2 { font-size: 1.4rem; font-weight: 700; color: var(--text); }
.panel-header .panel-sub {
  font-size: .85rem;
  color: var(--text-dim);
  flex: 1;
}

/* ── Input area ─────────────────────────────────────────────────────────── */
.input-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 24px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.suggestion-chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-dim);
  font-size: .78rem;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  font-family: var(--font-ar);
}
.suggestion-chip:hover { border-color: var(--accent); color: var(--accent); }

.textarea-wrap { position: relative; }
.textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: .95rem;
  font-family: var(--font);
  padding: 12px 40px 12px 14px;
  resize: vertical;
  outline: none;
  transition: var(--transition);
  line-height: 1.7;
}
.textarea:focus { border-color: var(--accent); }
.textarea.arabic { font-family: var(--font-ar); font-size: 1rem; }
.textarea::placeholder { color: var(--text-dim); }

.clear-btn {
  position: absolute;
  top: 10px; right: 10px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--border2);
  color: var(--text-dim);
  font-size: .75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.clear-btn:hover { background: var(--red); color: #fff; }

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}
.char-count { font-size: .75rem; color: var(--text-dim); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  padding: 10px 22px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: #000;
  font-weight: 600;
  font-size: .88rem;
  font-family: var(--font);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
}
.btn-primary:hover { background: var(--accent2); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-secondary {
  padding: 8px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--text-dim);
  font-size: .82rem;
  font-family: var(--font);
  cursor: pointer;
  transition: var(--transition);
}
.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(212,175,55,.06);
}
.btn-sm { padding: 6px 12px; font-size: .78rem; }
.btn-icon { font-size: .9rem; }

/* ── Result card ────────────────────────────────────────────────────────── */
.result-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.result-model { font-weight: 600; color: var(--accent); font-size: .95rem; }
.result-metrics { display: flex; gap: 10px; flex-wrap: wrap; }
.metric-pill {
  padding: 4px 10px;
  border-radius: 6px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: .75rem;
  color: var(--text-dim);
  font-family: 'Courier New', monospace;
}
.metric-pill b { color: var(--text); }

.audio-player {
  width: 100%;
  margin-bottom: 16px;
  border-radius: 8px;
  accent-color: var(--accent);
}
.audio-player.small { margin-top: 10px; }

.rating-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rating-label { font-size: .8rem; color: var(--text-dim); }
.stars { display: flex; gap: 2px; }
.stars button {
  background: none;
  border: none;
  color: var(--border2);
  font-size: 1.3rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 0;
}
.stars button.active,
.stars button:hover { color: var(--accent); }
.rating-done { font-size: .8rem; color: var(--green); }

/* ── Error / Spinner ────────────────────────────────────────────────────── */
.error-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #fca5a5;
  font-size: .85rem;
  margin-bottom: 16px;
}
.error-icon { font-size: 1rem; flex-shrink: 0; }

.spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 0;
  color: var(--text-dim);
  font-size: .85rem;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Benchmark grid ─────────────────────────────────────────────────────── */
.bench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}
.bench-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: var(--transition);
}
.bench-card:hover { border-color: var(--border2); }
.bench-card-name {
  font-weight: 600;
  color: var(--accent);
  font-size: .88rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
}
.status-dot.ok   { background: var(--green); }
.status-dot.fail { background: var(--red); }
.status-dot.busy { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.4;} }

/* ── Voice clone ────────────────────────────────────────────────────────── */
.clone-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  color: var(--text-dim);
  font-size: .85rem;
  line-height: 1.6;
}
.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(212,175,55,.05);
  color: var(--text);
}
.drop-icon { font-size: 2rem; margin-bottom: 8px; }
.clone-model-row { margin-top: 16px; }
.clone-tips {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 16px;
}
.clone-tips h4 { font-size: .88rem; color: var(--accent); margin-bottom: 12px; }
.clone-tips ul { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.clone-tips li {
  font-size: .82rem;
  color: var(--text-dim);
  padding-left: 16px;
  position: relative;
}
.clone-tips li::before { content: "›"; position: absolute; left: 0; color: var(--accent); }
.opt { color: var(--text-dim); font-weight: 400; }

/* ── Leaderboard ────────────────────────────────────────────────────────── */
.leaderboard-wrap { margin-bottom: 32px; }
.lb-title {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}
.lb-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.lb-table th {
  text-align: left;
  padding: 10px 14px;
  background: var(--surface2);
  color: var(--text-dim);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
.lb-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.lb-table tr:hover td { background: var(--surface2); }
.lb-table .rank-1 td:first-child { color: var(--accent); font-weight: 700; }

.model-info-wrap {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 32px;
}
.model-info-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.model-info-card h4 { font-size: .88rem; color: var(--accent); margin-bottom: 10px; }
.model-info-row {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  padding: 4px 0;
  border-bottom: 1px solid var(--border);
}
.model-info-row:last-child { border-bottom: none; }
.model-info-key { color: var(--text-dim); }
.model-info-val { color: var(--text); font-weight: 500; }
.tag-clone { color: var(--green); }
.tag-no-clone { color: var(--text-dim); }

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

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { flex-direction: row; flex-wrap: wrap; padding: 16px 0 0; }
  .sidebar-section { min-width: 180px; }
  .clone-layout { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .topbar-inner { flex-wrap: wrap; gap: 12px; }
  .header-badges { display: none; }
  .layout { padding: 0 12px 40px; }
}
