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

:root {
  --bg:          #080b14;
  --bg2:         #0d1120;
  --bg3:         #131826;
  --surface:     rgba(255,255,255,0.04);
  --surface2:    rgba(255,255,255,0.07);
  --border:      rgba(255,255,255,0.08);
  --border2:     rgba(0,212,255,0.25);
  --text:        #e2e8f0;
  --text2:       #94a3b8;
  --text3:       #475569;
  --accent:      #00d4ff;
  --accent2:     #0099cc;
  --success:     #00e87a;
  --danger:      #ff4757;
  --warning:     #ffa502;
  --purple:      #a78bfa;
  --ai-blue:     #2563eb;
  --ai-glow:     rgba(37,99,235,0.25);
  --font:        'Inter', system-ui, sans-serif;
  --mono:        'JetBrains Mono', 'Fira Code', monospace;
  --radius:      12px;
  --shadow:      0 4px 24px rgba(0,0,0,0.4);
  --shadow2:     0 8px 40px rgba(0,0,0,0.6);
  --glow:        0 0 20px rgba(0,212,255,0.15);
  --sidebar-w:   260px;
  --header-h:    60px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }

/* ── Header ───────────────────────────────────────────────────────────── */
#header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: rgba(8,11,20,0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
  z-index: 100;
}

.header-left  { display: flex; align-items: center; flex: 1; }
.header-center { display: flex; gap: 10px; }
.header-right  { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; }

.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; }
.logo-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  display: block; line-height: 1.2;
}
.logo-ai { color: var(--accent); }
.logo-sub { font-size: 10px; color: var(--text3); display: block; }

.stat-pill {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 12px; color: var(--text2);
}

.connection-badge {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text2);
}

.btn-outline {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--accent);
  font-size: 12px; font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
}
.btn-outline:hover {
  background: rgba(0,212,255,0.08);
  box-shadow: var(--glow);
}

/* ── Dots ─────────────────────────────────────────────────────────────── */
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green  { background: var(--success); }
.dot-blue   { background: var(--accent); }
.dot-yellow { background: var(--warning); }
.dot-red    { background: var(--danger); }
.dot-gray   { background: var(--text3); }

.pulse {
  animation: pulse-anim 1.5s ease-in-out infinite;
}
@keyframes pulse-anim {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.85); }
}

/* ── Main layout — 2 column (no right sidebar) ───────────────────────── */
#main-layout {
  position: fixed;
  top: var(--header-h); left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
#sidebar {
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-header h2 { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); }

.badge {
  background: var(--accent);
  color: #000;
  font-size: 10px; font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 20px; text-align: center;
}

#agent-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* Agent card */
.agent-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
  margin-bottom: 4px;
  position: relative;
}
.agent-card:hover  { background: var(--surface2); }
.agent-card.active {
  background: rgba(0,212,255,0.08);
  border-color: var(--border2);
  box-shadow: var(--glow);
}

.agent-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #fff;
  flex-shrink: 0;
  text-transform: uppercase;
}

.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.agent-meta { font-size: 10px; color: var(--text3); }

.agent-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}
.agent-status-dot.offline { background: var(--text3); }

.empty-state {
  text-align: center; padding: 40px 16px;
  color: var(--text3);
}
.empty-icon { font-size: 36px; margin-bottom: 12px; }
.empty-state p { font-size: 13px; margin-bottom: 4px; color: var(--text2); }
.empty-state small { font-size: 11px; }

/* ── Transcript panel (full width) ───────────────────────────────────── */
#transcript-panel {
  background: var(--bg);
  display: flex; flex-direction: column;
  overflow: hidden;
}

.welcome-screen {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; text-align: center; padding: 40px;
  color: var(--text3);
}
.welcome-icon { font-size: 48px; margin-bottom: 16px; }
.welcome-screen h2 { font-size: 20px; font-weight: 700; color: var(--text2); margin-bottom: 8px; }
.welcome-screen p { font-size: 13px; max-width: 280px; line-height: 1.6; }

/* Panel header */
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.panel-title  { font-size: 14px; font-weight: 700; }
.panel-subtitle { font-size: 11px; color: var(--text3); margin-top: 2px; }
.panel-controls { display: flex; align-items: center; gap: 12px; }

.call-timer {
  font-family: var(--mono);
  font-size: 13px; font-weight: 500;
  color: var(--accent);
  background: rgba(0,212,255,0.08);
  padding: 4px 10px; border-radius: 6px;
}

.recording-badge {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: rgba(255,71,87,0.12);
  border: 1px solid rgba(255,71,87,0.3);
  border-radius: 20px;
  font-size: 10px; font-weight: 700; color: var(--danger);
  letter-spacing: 1px;
}

#transcript-active { display: flex; flex-direction: column; height: 100%; }

#transcript-scroll {
  flex: 1; overflow-y: auto;
  padding: 20px 40px;
  display: flex; flex-direction: column;
  gap: 6px;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

/* ── Chat bubbles ────────────────────────────────────────────────────── */
.msg {
  display: flex; flex-direction: column;
  max-width: 80%;
  animation: msg-in 0.25s ease;
}
.msg.no-anim { animation: none; }

@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Customer = left-aligned */
.msg.customer { align-self: flex-start; }

/* AI suggestion = right-aligned, blue bubble like the agent screenshot */
.msg.ai-suggestion { align-self: flex-end; }

.msg-speaker {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.8px; margin-bottom: 3px;
  color: var(--text3);
}
.msg.customer .msg-speaker { padding-left: 4px; color: var(--accent); }
.msg.ai-suggestion .msg-speaker { padding-right: 4px; color: var(--ai-blue); text-align: right; }

.msg-text {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px; line-height: 1.55;
  word-break: break-word;
}

/* Customer bubble — dark subtle */
.msg.customer .msg-text {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* AI Suggestion bubble — bright blue like agent in the screenshot */
.msg.ai-suggestion .msg-text {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none;
  border-bottom-right-radius: 4px;
  color: #fff;
  box-shadow: 0 2px 12px var(--ai-glow);
}
.msg.ai-suggestion .msg-text .suggestion-item {
  cursor: pointer;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.15);
  transition: opacity 0.2s;
}
.msg.ai-suggestion .msg-text .suggestion-item:last-child {
  border-bottom: none;
}
.msg.ai-suggestion .msg-text .suggestion-item:hover {
  opacity: 0.8;
}
.msg.ai-suggestion .msg-text .suggestion-item::before {
  content: attr(data-num) ". ";
  font-weight: 700;
  color: rgba(255,255,255,0.7);
}

/* AI loading indicator — inline */
.msg.ai-loading {
  align-self: flex-end;
  max-width: 200px;
}
.msg.ai-loading .msg-text {
  background: rgba(37,99,235,0.15);
  border: 1px solid rgba(37,99,235,0.3);
  border-bottom-right-radius: 4px;
  color: var(--ai-blue);
  font-style: italic;
  display: flex; align-items: center; gap: 8px;
}
.typing-dots {
  display: flex; gap: 3px;
}
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--ai-blue);
  border-radius: 50%;
  animation: typing 1.2s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Interim (partial) text */
.msg.interim .msg-text {
  background: transparent;
  border: 1px dashed var(--border2);
  color: var(--text2);
  font-style: italic;
}

.msg-time {
  font-size: 10px; color: var(--text3); margin-top: 3px;
  padding: 0 4px;
}
.msg.ai-suggestion .msg-time { text-align: right; }

/* ── Toast ────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999;
}
.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 13px;
  display: flex; align-items: center; gap: 10px;
  animation: toast-in 0.3s ease;
  box-shadow: var(--shadow2);
  max-width: 320px;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.toast.success { background: rgba(0,232,122,0.12); border: 1px solid rgba(0,232,122,0.3); color: var(--success); }
.toast.info    { background: rgba(0,212,255,0.12); border: 1px solid rgba(0,212,255,0.3); color: var(--accent); }
.toast.error   { background: rgba(255,71,87,0.12);  border: 1px solid rgba(255,71,87,0.3);  color: var(--danger); }
.toast.warning { background: rgba(255,165,2,0.12);  border: 1px solid rgba(255,165,2,0.3);  color: var(--warning); }
