/* ═══════════════════════════════════════════════════
   HeyDoc AI — Premium Dark Theme
   ═══════════════════════════════════════════════════ */

:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #111827;
  --bg-card: #1a2235;
  --bg-card-hover: #1e2740;
  --bg-glass: rgba(17, 24, 39, 0.7);
  --border: #1e293b;
  --border-glow: rgba(99, 102, 241, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.15);

  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, 0.1);
  --yellow: #eab308;
  --yellow-bg: rgba(234, 179, 8, 0.1);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --orange: #f97316;
  --blue: #3b82f6;
  --cyan: #06b6d4;

  --sarvam-color: #06b6d4;
  --groq-color: #f97316;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

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

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

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(12px);
}

.header-left { display: flex; align-items: center; gap: 16px; }
.logo { display: flex; align-items: center; gap: 8px; }
.logo-icon { font-size: 24px; }
.logo h1 { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.logo-accent { color: var(--accent-light); }
.header-tag {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

.header-right { display: flex; align-items: center; gap: 16px; }
.api-badges { display: flex; gap: 8px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.badge-sarvam {
  background: rgba(6, 182, 212, 0.15);
  color: var(--sarvam-color);
  border: 1px solid rgba(6, 182, 212, 0.3);
}
.badge-groq {
  background: rgba(249, 115, 22, 0.15);
  color: var(--groq-color);
  border: 1px solid rgba(249, 115, 22, 0.3);
}
.header-status {
  font-size: 12px;
  color: var(--text-muted);
}
.header-status.connected { color: var(--green); }

/* ── Main Grid ── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  height: calc(100vh - 53px);
}

/* ── Panels ── */
.panel {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 20px;
}

.voice-panel {
  border-right: 1px solid var(--border);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.panel-head h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.upload-link {
  font-size: 12px;
  color: var(--accent-light);
  cursor: pointer;
  transition: var(--transition);
}
.upload-link:hover { color: var(--text-primary); }

.btn-export {
  font-size: 12px;
  color: var(--sarvam-color);
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.2);
  padding: 4px 10px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font);
  transition: var(--transition);
}
.btn-export:hover {
  background: rgba(6, 182, 212, 0.2);
  border-color: rgba(6, 182, 212, 0.4);
}

/* ── Phone Input ── */
.phone-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.phone-row label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.phone-row input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: var(--transition);
}
.phone-row input:focus { border-color: var(--accent); }

/* ── Conversation ── */
.conversation {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
  min-height: 200px;
}

.conversation-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--text-muted);
  text-align: center;
  gap: 8px;
}
.conversation-empty-icon { font-size: 48px; opacity: 0.3; }
.conversation-empty p { font-size: 14px; }
.conversation-empty-sub { font-size: 11px; opacity: 0.7; }

/* Messages */
.msg {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msgSlide 0.3s ease;
}
@keyframes msgSlide {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user { align-self: flex-end; }
.msg-bot { align-self: flex-start; }

.msg-text {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  line-height: 1.5;
  word-wrap: break-word;
}

.msg-user .msg-text {
  background: var(--accent);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-bot .msg-text {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-meta {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.msg-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.msg-transliteration {
  font-size: 11px;
  color: var(--sarvam-color);
  font-style: italic;
  margin-top: 4px;
  padding-left: 4px;
}

/* ── Language Badge ── */
.lang-badge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.lang-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid var(--border-glow);
}
.transliteration-text {
  font-size: 11px;
  color: var(--sarvam-color);
  font-style: italic;
}

/* ── Record Button ── */
.record-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 0 8px;
}

.rec-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.3);
  position: relative;
}

.rec-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 30px rgba(99, 102, 241, 0.5);
}

.rec-btn.recording {
  background: linear-gradient(135deg, var(--red), #dc2626);
  box-shadow: 0 4px 30px rgba(239, 68, 68, 0.5);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(239, 68, 68, 0.3); }
  50% { box-shadow: 0 4px 40px rgba(239, 68, 68, 0.6); }
}

.rec-btn.processing {
  background: linear-gradient(135deg, var(--yellow), #ca8a04);
  animation: none;
  cursor: wait;
}

.rec-label {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Latency Badge ── */
.latency-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Pipeline Phases ── */
.phases {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}

.phase {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  transition: var(--transition);
  flex-shrink: 0;
}

.phase.active .phase-dot {
  background: var(--yellow);
  border-color: var(--yellow);
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.5);
  animation: phasePulse 1s infinite;
}

@keyframes phasePulse {
  0%, 100% { box-shadow: 0 0 4px rgba(234, 179, 8, 0.3); }
  50% { box-shadow: 0 0 12px rgba(234, 179, 8, 0.6); }
}

.phase.completed .phase-dot {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.3);
  animation: none;
}

.phase-info { display: flex; flex-direction: column; }
.phase-name { font-size: 12px; font-weight: 500; color: var(--text-primary); }
.phase-detail { font-size: 11px; color: var(--text-muted); }

/* ── Urgency Card ── */
.urgency-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
  animation: msgSlide 0.3s ease;
}

.urgency-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.urgency-score {
  font-size: 28px;
  font-weight: 700;
}
.urgency-score.critical { color: var(--red); }
.urgency-score.moderate { color: var(--yellow); }
.urgency-score.routine { color: var(--green); }

.urgency-track {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.urgency-track.critical { background: var(--red-bg); color: var(--red); border: 1px solid rgba(239, 68, 68, 0.3); }
.urgency-track.moderate { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(234, 179, 8, 0.3); }
.urgency-track.routine { background: var(--green-bg); color: var(--green); border: 1px solid rgba(34, 197, 94, 0.3); }

.urgency-complaint {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.urgency-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.flag-pill {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* ── Agent Cards ── */
.agents-section { margin-bottom: 16px; }
.agents-section h3,
.profile-section h3,
.sarvam-usage h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.agent-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  animation: msgSlide 0.3s ease;
}

.agent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.agent-card-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
}

.agent-card-status {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--green-bg);
  color: var(--green);
}

.agent-card-summary {
  font-size: 11px;
  color: var(--text-secondary);
}

/* ── Sarvam API Usage ── */
.sarvam-usage {
  margin-bottom: 16px;
}

.sarvam-api-list {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sarvam-api-pill {
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(6, 182, 212, 0.1);
  color: var(--sarvam-color);
  border: 1px solid rgba(6, 182, 212, 0.2);
  animation: msgSlide 0.3s ease;
}

/* ── Patient Profile ── */
.profile-section { margin-bottom: 16px; }
.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.profile-item {
  font-size: 11px;
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
}
.profile-item-label {
  color: var(--text-muted);
  font-size: 10px;
  display: block;
}
.profile-item-value {
  color: var(--text-primary);
  font-weight: 500;
}
.profile-empty {
  font-size: 12px;
  color: var(--text-muted);
  grid-column: 1 / -1;
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .main-grid {
    grid-template-columns: 1fr;
    height: auto;
  }
  .voice-panel {
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: 60vh;
  }
}

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