@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Space+Mono&display=swap');

/* =====================================================
   AlohaTone AI — Global Design System
   "Sunset-to-Sky" dark theme
   ===================================================== */

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

:root {
  /* Brand colors */
  --orange:       #e8632b;
  --orange-l:     #f0884e;
  --orange-glow:  rgba(232,99,43,0.15);
  --rose:         #a8456e;
  --cyan:         #5ce0d8;
  --cyan-dim:     rgba(92,224,216,0.25);
  --cyan-glow:    rgba(92,224,216,0.09);

  /* Surfaces */
  --night:        #1a1030;
  --card:         #221640;
  --card2:        #271848;
  --border:       #3d2a5c;
  --border2:      #4a3368;

  /* Legacy aliases for older page-local styles */
  --orange-light: var(--orange-l);
  --night-card:   var(--card);
  --night-border: var(--border);

  /* Text */
  --text:         #e8dff0;
  --text-dim:     #9a8cb5;
  --text-muted:   #6b5a8a;

  /* Misc */
  --r:            12px;
  --r-sm:         8px;
  --nav-h:        60px;
  --max-w:        1240px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background:
    linear-gradient(160deg,
      #2a1008 0%,
      #3a1830 18%,
      #2a1650 38%,
      #1a1030 60%,
      #0e0820 100%
    );
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: 28px 28px;
}

/* ── NAV ── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  padding: 0 28px;
  background: rgba(26,16,48,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
}

.nav-logo {
  height: 26px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.9;
}

.tenant-pill {
  padding: 3px 10px;
  border: 1px solid var(--border2);
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  font-family: 'SF Mono','Fira Code', monospace;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 24px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  padding: 6px 11px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s, background 0.2s;
  white-space: nowrap;
}
.nav-link:hover  { color: var(--text); background: rgba(255,255,255,0.05); }
.nav-link.active { color: var(--cyan); }

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ── LIVE BADGE ── */
.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(232,99,43,0.3);
  border-radius: 100px;
  font-size: 10px;
  font-weight: 700;
  color: var(--orange-l);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── PULSE ── */
.pulse-dot,
.live-pulse {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--orange);
  flex-shrink: 0;
  animation: at-pulse 2s ease-in-out infinite;
}
.live-pulse { width: 8px; height: 8px; animation-duration: 1.6s; }

@keyframes at-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(232,99,43,0.5); opacity: 1; }
  50%      { box-shadow: 0 0 0 5px rgba(232,99,43,0); opacity: 0.6; }
}

/* ── PAGE SHELL ── */
.page {
  position: relative;
  z-index: 1;
  padding-top: var(--nav-h);
  min-height: 100vh;
}

.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 28px 28px 60px;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ── STATS ── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover { border-color: var(--border2); transform: translateY(-1px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(92,224,216,0.2), transparent);
}
.stat-card.stat-hot::before {
  background: linear-gradient(90deg, transparent, rgba(232,99,43,0.35), transparent);
}

.stat-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-value.active { color: var(--orange); }
.stat-value.leads  { color: var(--orange-l); }
.stat-value.cyan   { color: var(--cyan); }
.stat-value.dim    { font-size: 20px; color: var(--text-dim); }

.stat-active {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── SECTION ── */
.section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 20px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(92,224,216,0.04);
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
}
.section-title.warm { color: var(--orange-l); }

.section-body {
  padding: 16px 18px 18px;
}

.section-copy {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.65;
}

.section-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono','Fira Code', monospace;
}

/* ── TABLES ── */
table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 10px 16px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.right { text-align: right; }

tbody tr {
  border-bottom: 1px solid rgba(61,42,92,0.4);
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--cyan-glow); }

tbody td {
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  vertical-align: middle;
}
tbody td.right {
  text-align: right;
  font-family: 'SF Mono','Fira Code', monospace;
  font-size: 12px;
  color: var(--text-dim);
}
td.mono {
  font-family: 'SF Mono','Fira Code', monospace;
  font-size: 12px;
  color: var(--cyan);
}
td.warn {
  color: var(--orange-l);
  font-weight: 700;
}

.billing-muted {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 6px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill.good {
  color: var(--cyan);
  border-color: rgba(92,224,216,0.35);
  background: rgba(92,224,216,0.08);
}

.status-pill.muted {
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
}

.empty {
  padding: 32px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.6;
}

/* cost / progress bar */
.cost-bar-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cost-bar {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.cost-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--rose));
  border-radius: 2px;
}
.cost-val {
  font-family: 'SF Mono','Fira Code', monospace;
  font-size: 11px;
  color: var(--text-dim);
  min-width: 48px;
  text-align: right;
}

/* ── BADGES ── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-active      { background: rgba(232,99,43,0.12); color: var(--orange-l); border: 1px solid rgba(232,99,43,0.25); }
.badge-completed   { background: var(--cyan-glow);     color: var(--cyan);     border: 1px solid rgba(92,224,216,0.2); }
.badge-transferred { background: rgba(168,69,110,0.12); color: #d47fa0;        border: 1px solid rgba(168,69,110,0.25); }
.badge-internal    { background: var(--cyan-glow);      color: var(--cyan);    border: 1px solid rgba(92,224,216,0.2); }
.badge-external    { background: rgba(232,99,43,0.12);  color: var(--orange-l);border: 1px solid rgba(232,99,43,0.2); }

/* ── LIVE CALL CARDS ── */
.live-calls-grid {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.no-active {
  grid-column: 1/-1;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.8;
}
.no-active strong {
  display: block;
  color: var(--text-dim);
  font-size: 15px;
  margin-bottom: 8px;
}
.no-active code {
  font-family: 'SF Mono','Fira Code', monospace;
  font-size: 12px;
  color: var(--cyan);
  background: rgba(92,224,216,0.07);
  padding: 2px 7px;
  border-radius: 4px;
}

.call-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s;
}
.call-card:hover { border-color: var(--border2); }

.call-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(232,99,43,0.05);
}

.caller-info   { display: flex; flex-direction: column; gap: 2px; }
.caller-name   { font-size: 14px; font-weight: 600; }
.caller-num    { font-size: 11px; color: var(--text-muted); font-family: 'SF Mono','Fira Code', monospace; }

.call-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--orange-l);
}

.call-card-body {
  padding: 12px 14px;
  flex: 1;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
  max-height: 120px;
  overflow-y: auto;
}

.call-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono','Fira Code', monospace;
}

/* ── EXPANDABLE TRANSCRIPT ── */
.call-row { cursor: pointer; }
.call-detail { display: none; }
.call-detail.open { display: table-row; }

.transcript-cell {
  padding: 16px 20px 16px 40px !important;
  background: rgba(14,8,32,0.5);
  border-bottom: 1px solid var(--border) !important;
}

.transcript {
  font-size: 12.5px;
  line-height: 1.9;
  color: var(--text-dim);
  max-width: 700px;
}
.transcript .ai-turn     { color: var(--cyan); }
.transcript .caller-turn { color: var(--text); }
.transcript .turn-label  {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-right: 6px;
  opacity: 0.65;
}

.expand-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  transition: color 0.2s, background 0.2s;
}
.expand-toggle:hover { color: var(--cyan); background: var(--cyan-glow); }

.caller-cell            { display: flex; flex-direction: column; gap: 2px; }
.caller-cell strong     { font-weight: 600; font-size: 13px; }
.caller-cell span       { font-size: 11px; color: var(--text-muted); font-family: 'SF Mono','Fira Code', monospace; }

/* ── AGENT CARDS ── */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.agent-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
  position: relative;
  overflow: hidden;
}
.agent-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--orange), var(--rose));
  opacity: 0;
  transition: opacity 0.3s;
}
.agent-card:hover {
  border-color: rgba(232,99,43,0.35);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  transform: translateY(-2px);
}
.agent-card:hover::before { opacity: 1; }

.agent-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.agent-name-block { display: flex; flex-direction: column; gap: 5px; }
.agent-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }

.ext-pill {
  display: inline-block;
  padding: 3px 9px;
  background: rgba(232,99,43,0.1);
  border: 1px solid rgba(232,99,43,0.25);
  border-radius: 6px;
  font-family: 'SF Mono','Fira Code', monospace;
  font-size: 12px;
  color: var(--orange-l);
  letter-spacing: 0.04em;
}

.agent-summary {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.55;
}

.agent-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.meta-pill {
  padding: 3px 9px;
  border: 1px solid var(--border2);
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.agent-link {
  font-size: 13px;
  font-weight: 600;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: 4px;
}
.agent-link svg { transition: transform 0.2s; }
.agent-card:hover .agent-link svg { transform: translateX(3px); }

/* ── DOC PANELS (agent detail) ── */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.doc-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.doc-panel-title {
  padding: 11px 16px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
  background: rgba(92,224,216,0.04);
  border-bottom: 1px solid var(--border);
}

.doc-panel-body {
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
}

.doc-panel-body ul { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.doc-panel-body li::before {
  content: '>';
  font-family: 'SF Mono','Fira Code', monospace;
  color: var(--orange);
  margin-right: 8px;
  font-size: 11px;
}

.script-block {
  font-size: 13px;
  line-height: 1.65;
  color: var(--text);
  font-style: italic;
  border-left: 2px solid var(--orange);
  padding-left: 14px;
}

/* ── FORMS ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
}

.form-input {
  padding: 11px 14px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(92,224,216,0.1);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 24px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.btn-primary {
  background: var(--orange);
  color: #fff;
}
.btn-primary:hover {
  background: var(--orange-l);
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(232,99,43,0.3);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover {
  border-color: var(--border2);
  background: rgba(255,255,255,0.04);
}

/* ── FLASH MESSAGES ── */
.flash-success {
  padding: 12px 16px;
  background: var(--cyan-glow);
  border: 1px solid rgba(92,224,216,0.2);
  border-radius: var(--r-sm);
  color: var(--cyan);
  font-size: 13px;
  margin-bottom: 16px;
}
.flash-error {
  padding: 12px 16px;
  background: rgba(220,60,60,0.1);
  border: 1px solid rgba(220,60,60,0.25);
  border-radius: var(--r-sm);
  color: #e88;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── SCROLLBARS ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ── RESPONSIVE ── */
@media (max-width: 900px) {
  .nav { padding: 0 14px; }
  .nav-logo { height: 23px; }
  .tenant-pill { display: none; }
  .nav-links { margin-left: 12px; }
  .nav-right { gap: 4px; }
  .live-badge { display: none; }
  .nav-links .nav-link { display: none; }
  .nav-links .nav-link.active { display: block; }
  .container { padding: 20px 16px 48px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .doc-grid { grid-template-columns: 1fr; }
}
