/* =============================================================================
   Elusa AI Dashboard — Styles
   ============================================================================= */

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #232736;
  --border: #2e3345;
  --text: #e4e6ef;
  --text-dim: #8b8fa3;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --radius: 8px;
  --radius-lg: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 32px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-left { display: flex; align-items: baseline; gap: 12px; }
header h1 { font-size: 20px; font-weight: 700; color: var(--accent); }
.subtitle { font-size: 13px; color: var(--text-dim); }
.header-right { display: flex; align-items: center; gap: 16px; }
.server-status { font-size: 13px; color: var(--text-dim); }
.server-status.online { color: var(--green); }
.server-status.offline { color: var(--red); }
.clock { font-size: 13px; color: var(--text-dim); font-variant-numeric: tabular-nums; }

/* Nav */
nav {
  display: flex; gap: 2px; padding: 8px 32px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.nav-btn {
  padding: 8px 20px; border: none; background: transparent; color: var(--text-dim);
  font-size: 14px; font-weight: 500; cursor: pointer; border-radius: var(--radius);
  transition: all 0.15s;
}
.nav-btn:hover { color: var(--text); background: var(--surface2); }
.nav-btn.active { color: var(--accent); background: var(--surface2); }

/* Views */
.view { display: none; padding: 24px 32px; max-width: 1400px; margin: 0 auto; }
.view.active { display: block; }

/* KPI Grid */
.kpi-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 20px; text-align: center;
}
.kpi-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-value.good { color: var(--green); }
.kpi-value.warn { color: var(--amber); }
.kpi-value.bad { color: var(--red); }

/* Cards */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 20px;
}
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { margin-bottom: 0; }

/* Layouts */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }

/* Call List Items */
.call-list { display: flex; flex-direction: column; gap: 8px; max-height: 400px; overflow-y: auto; }
.call-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--surface2); border-radius: var(--radius);
  cursor: pointer; transition: background 0.15s;
}
.call-item:hover { background: #2a2e3f; }
.call-item-left { display: flex; flex-direction: column; gap: 2px; }
.call-item-title { font-size: 14px; font-weight: 500; }
.call-item-sub { font-size: 12px; color: var(--text-dim); }
.call-item-right { display: flex; align-items: center; gap: 12px; }

/* Badges */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;
}
.badge-approved { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-denied { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-pended { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge-unknown { background: rgba(139,143,163,0.15); color: var(--text-dim); }
.badge-active { background: rgba(99,102,241,0.15); color: var(--accent); }
.badge-completed { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-failed { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-running { background: rgba(59,130,246,0.15); color: var(--blue); }

/* Score display */
.score {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  font-size: 14px; font-weight: 700;
}
.score-high { background: rgba(34,197,94,0.15); color: var(--green); }
.score-mid { background: rgba(245,158,11,0.15); color: var(--amber); }
.score-low { background: rgba(239,68,68,0.15); color: var(--red); }

/* Actions */
.actions-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.action-btn {
  padding: 10px 20px; border: 1px solid var(--border); background: var(--surface2);
  color: var(--text); border-radius: var(--radius); cursor: pointer;
  font-size: 14px; font-weight: 500; transition: all 0.15s;
}
.action-btn:hover { border-color: var(--accent); color: var(--accent); }
.action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.action-btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.action-btn.primary:hover { background: var(--accent-hover); }
.action-btn.small { padding: 6px 14px; font-size: 13px; }

/* Data Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  text-align: left; padding: 10px 12px; color: var(--text-dim);
  font-weight: 500; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.5px; border-bottom: 1px solid var(--border);
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tbody tr { cursor: pointer; transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--surface2); }
.empty-state { color: var(--text-dim); font-size: 14px; text-align: center; padding: 40px 0; }

/* Batch Controls */
.batch-controls { display: flex; flex-direction: column; gap: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.form-row { display: flex; gap: 16px; }
.form-group input[type="number"] {
  width: 100px; padding: 8px 12px; background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius); font-size: 14px;
}
.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-group label {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.checkbox-group label:has(input:checked) { border-color: var(--accent); background: rgba(99,102,241,0.1); }
.checkbox-group input { accent-color: var(--accent); }

/* Progress */
.progress-bar-container {
  width: 100%; height: 6px; background: var(--surface2);
  border-radius: 3px; overflow: hidden; margin-bottom: 8px;
}
.progress-bar { height: 100%; background: var(--accent); transition: width 0.3s; border-radius: 3px; }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 1000; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  width: 90vw; max-width: 900px; max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; }
.close-btn {
  background: none; border: none; color: var(--text-dim); font-size: 18px;
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius);
}
.close-btn:hover { color: var(--text); background: var(--surface2); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }

/* Tabs */
.detail-tabs { display: flex; gap: 2px; margin-bottom: 20px; }
.tab-btn {
  padding: 8px 16px; border: none; background: transparent; color: var(--text-dim);
  font-size: 13px; font-weight: 500; cursor: pointer; border-radius: var(--radius);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); background: var(--surface2); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Transcript */
.transcript { display: flex; flex-direction: column; gap: 8px; }
.transcript-turn {
  display: flex; gap: 12px; padding: 10px 14px;
  border-radius: var(--radius); font-size: 14px; line-height: 1.5;
}
.transcript-turn.rep { background: rgba(59,130,246,0.08); }
.transcript-turn.caller { background: rgba(99,102,241,0.08); }
.turn-role {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  min-width: 52px; padding-top: 2px; white-space: nowrap;
}
.turn-role.rep { color: var(--blue); }
.turn-role.caller { color: var(--accent); }
.turn-text { flex: 1; }

/* Evaluation */
.eval-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.eval-dim {
  padding: 14px; background: var(--surface2); border-radius: var(--radius);
}
.eval-dim-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.eval-dim-name { font-size: 13px; font-weight: 600; }
.eval-dim-score { font-size: 18px; font-weight: 700; }
.eval-dim-text { font-size: 12px; color: var(--text-dim); }

.eval-section { margin-bottom: 16px; }
.eval-section h3 { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.eval-section ul { padding-left: 20px; }
.eval-section li { font-size: 13px; margin-bottom: 4px; }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 16px; padding: 10px 0;
  border-left: 2px solid var(--border); margin-left: 12px; padding-left: 20px;
  position: relative;
}
.timeline-item::before {
  content: ''; position: absolute; left: -5px; top: 14px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
}
.timeline-time { font-size: 12px; color: var(--text-dim); min-width: 60px; font-variant-numeric: tabular-nums; }
.timeline-event { font-size: 13px; }

/* Audio */
.audio-section { margin-bottom: 20px; }
.audio-section h3 { font-size: 14px; margin-bottom: 8px; }
audio { width: 100%; }

/* Batch Report */
.report-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }
.report-stat { padding: 14px; background: var(--surface2); border-radius: var(--radius); text-align: center; }
.report-stat-value { font-size: 24px; font-weight: 700; }
.report-stat-label { font-size: 11px; color: var(--text-dim); text-transform: uppercase; margin-top: 4px; }

/* Responsive */
@media (max-width: 1024px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .eval-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  header, nav, .view { padding-left: 16px; padding-right: 16px; }
  .modal { width: 95vw; }
}
