/* ==========================================================================
   AI Calling Agent - Premium Human-Crafted UI
   Apex Healthcare Clinic Portal
   ========================================================================== */

:root {
  /* Surface & Base */
  --bg-main: #070A10;
  --bg-surface: #0B0F17;
  --bg-card: rgba(255, 255, 255, 0.028);
  --bg-card-hover: rgba(255, 255, 255, 0.045);
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-active: rgba(99, 102, 241, 0.4);

  /* Accents */
  --accent-indigo: #6366F1;
  --accent-purple: #8B5CF6;
  --accent-cyan: #06B6D4;
  --accent-emerald: #10B981;
  --accent-amber: #F59E0B;
  --accent-rose: #F43F5E;

  /* Text & Labels */
  --text-main: #F8FAFC;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;

  /* Typography */
  --font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
  --grad-cyan: linear-gradient(135deg, #06B6D4 0%, #3B82F6 100%);
  --grad-call: linear-gradient(135deg, #10B981 0%, #059669 100%);
  --grad-end: linear-gradient(135deg, #F43F5E 0%, #E11D48 100%);

  /* Shadows */
  --shadow-indigo: 0 10px 25px -5px rgba(99, 102, 241, 0.3);
  --shadow-emerald: 0 10px 25px -5px rgba(16, 185, 129, 0.3);
  --shadow-card: 0 12px 30px -10px rgba(0, 0, 0, 0.5);

  /* Animation timing */
  --ease-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Backdrops */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.12;
}

.glow-top {
  width: 600px;
  height: 350px;
  background: radial-gradient(circle, var(--accent-indigo) 0%, transparent 70%);
  top: -100px;
  left: 50%;
  transform: translateX(-50%);
}

.glow-bottom {
  width: 500px;
  height: 400px;
  background: radial-gradient(circle, var(--accent-purple) 0%, transparent 70%);
  bottom: -150px;
  right: 5%;
}

/* App Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(7, 10, 16, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
}

.header-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.35);
}

.brand-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.brand-clinic-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--accent-indigo);
  border: 1px solid rgba(99, 102, 241, 0.25);
}

.brand-tagline {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Segmented Navigation */
.nav-segment {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  gap: 3px;
}

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0.5rem 1.05rem;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ease-smooth);
}

.nav-tab:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.nav-tab.active {
  color: #fff;
  background: var(--grad-primary);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.counter-badge {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
}

/* System Status Pill */
.system-status {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0.4rem 0.85rem;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.22);
  border-radius: 9999px;
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--accent-emerald);
}

.system-status.calling {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.35);
  color: #A5B4FC;
}

.status-indicator-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: currentColor;
  box-shadow: 0 0 8px currentColor;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(1.2); }
}

/* Page Layout */
.page-container {
  max-width: 1320px;
  margin: 1.75rem auto 3rem;
  padding: 0 2rem;
  position: relative;
  z-index: 1;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
  animation: fadeSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Panels */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.5rem;
  transition: var(--ease-smooth);
}

.glass-panel:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.1);
}

.glass-panel.full-width {
  width: 100%;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.panel-header.border-bottom {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header.flex-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel-title {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-main);
}

.panel-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* TAB 1: Voice Assistant Grid */
.assistant-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* Console Panel (Left) */
.console-panel {
  display: flex;
  flex-direction: column;
}

.agent-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.avatar-holder {
  position: relative;
  width: 58px;
  height: 58px;
}

.avatar-core {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 25px rgba(99, 102, 241, 0.4);
  transition: var(--ease-smooth);
}

.avatar-wave-ring {
  position: absolute;
  top: -6px;
  left: -6px;
  right: -6px;
  bottom: -6px;
  border-radius: 50%;
  border: 2px solid rgba(99, 102, 241, 0.4);
  opacity: 0;
  pointer-events: none;
}

.avatar-holder.speaking .avatar-wave-ring {
  animation: ring-pulse 1.8s infinite ease-out;
}

@keyframes ring-pulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

.agent-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.voice-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 9999px;
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.agent-role {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.call-state-tag {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.3rem 0.75rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.call-state-tag.in-call {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--accent-emerald);
}

/* Soundwave Visualizer Stage */
.visualizer-container {
  position: relative;
  height: 180px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 1.25rem 0;
}

#waveformCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.visualizer-overlay {
  position: relative;
  z-index: 2;
  text-align: center;
}

.speaking-status-text {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.call-timer {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 6px;
  letter-spacing: 0.05em;
}

/* Call Buttons Section */
.call-action-section {
  display: flex;
  justify-content: center;
  margin: 0.5rem 0 1.25rem;
}

.call-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 0.85rem 2rem;
  border-radius: 12px;
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--ease-smooth);
}

.btn-start-call {
  background: var(--grad-call);
  color: #fff;
  box-shadow: var(--shadow-emerald);
}

.btn-start-call:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px -4px rgba(16, 185, 129, 0.45);
}

.btn-end-call {
  background: var(--grad-end);
  color: #fff;
  box-shadow: 0 10px 25px -5px rgba(244, 63, 94, 0.4);
}

.btn-end-call:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 28px -4px rgba(244, 63, 94, 0.55);
}

/* Quick Prompts */
.quick-prompts-wrapper {
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

.quick-prompts-label {
  display: block;
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.quick-prompts-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-chip {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-family: var(--font-family);
  font-size: 0.78rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--ease-smooth);
}

.prompt-chip:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--text-main);
  transform: translateY(-1px);
}

/* Transcript Panel (Right) */
.transcript-panel {
  display: flex;
  flex-direction: column;
  height: 540px;
}

.channel-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.pulse-mini {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
}

.transcript-feed {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.25rem 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.transcript-feed::-webkit-scrollbar {
  width: 4px;
}

.transcript-feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

/* Feed Placeholder */
.feed-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.placeholder-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.85rem;
  color: var(--text-muted);
}

.placeholder-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.placeholder-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 260px;
}

/* Speech Dialogue Messages */
.transcript-item {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: fadeIn 0.25s ease-out;
}

.transcript-item.agent {
  align-self: flex-start;
}

.transcript-item.user {
  align-self: flex-end;
}

.transcript-item.action {
  align-self: center;
  max-width: 95%;
  width: 100%;
}

.item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.73rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.transcript-item.agent .item-meta {
  color: var(--accent-indigo);
}

.transcript-item.user .item-meta {
  color: var(--accent-cyan);
  justify-content: flex-end;
}

.meta-time {
  font-size: 0.68rem;
  font-weight: 400;
  opacity: 0.5;
  font-family: var(--font-mono);
}

.item-bubble {
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.transcript-item.agent .item-bubble {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: var(--text-main);
  border-top-left-radius: 2px;
}

.transcript-item.user .item-bubble {
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  color: var(--text-main);
  border-top-right-radius: 2px;
}

/* Verified Action Chip (e.g. Appointment Booked) */
.action-event-card {
  background: rgba(16, 185, 129, 0.07);
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-radius: 10px;
  padding: 0.75rem 0.95rem;
}

.action-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-emerald);
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.action-details {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Text Reply Form (Bottom of Transcript) */
.text-reply-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-subtle);
  margin-top: 0.5rem;
}

.text-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 0.65rem 0.95rem;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.85rem;
  outline: none;
  transition: var(--ease-smooth);
}

.text-input:focus {
  border-color: var(--accent-indigo);
  background: rgba(0, 0, 0, 0.35);
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--grad-primary);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--ease-smooth);
}

.btn-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

/* ==================================================================== */
/* TAB 2: APPOINTMENTS HUB */
/* ==================================================================== */

.appointments-ribbon {
  display: flex;
  align-items: center;
  padding: 1rem 1.5rem;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
}

.ribbon-metric {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.ribbon-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.ribbon-value {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
  margin-top: 2px;
}

.ribbon-value.highlight-emerald {
  color: var(--accent-emerald);
}

.ribbon-divider {
  width: 1px;
  height: 38px;
  background: var(--border-subtle);
  margin: 0 1.5rem;
}

.clean-select {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
}

.clean-select option {
  background: var(--bg-surface);
  color: var(--text-main);
}

.clean-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0.45rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--ease-smooth);
}

.clean-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.15);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.clinic-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.clinic-table th {
  padding: 0.75rem 0.95rem;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.clinic-table td {
  padding: 0.95rem;
  font-size: 0.85rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}

.clinic-table tr:hover td {
  background: rgba(255, 255, 255, 0.015);
}

.booking-code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--accent-indigo);
  background: rgba(99, 102, 241, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
}

.patient-name {
  font-weight: 600;
  color: var(--text-main);
}

.status-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0.22rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: capitalize;
}

.status-tag.confirmed {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.status-tag.completed {
  background: rgba(6, 182, 212, 0.1);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.25);
}

.status-tag.cancelled {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.25);
}

/* Action Dropdown / Button in table */
.status-dropdown {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-family);
  cursor: pointer;
}

.status-dropdown option {
  background: var(--bg-surface);
  color: var(--text-main);
}

/* ==================================================================== */
/* MODAL */
/* ==================================================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.modal-dialog {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
  animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-heading {
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-content {
  padding: 1.5rem;
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 960px) {
  .assistant-grid {
    grid-template-columns: 1fr;
  }
  .header-container {
    flex-direction: column;
    align-items: flex-start;
    padding: 1rem;
  }
  .nav-segment {
    width: 100%;
    justify-content: space-between;
  }
  .page-container {
    padding: 0 1rem;
  }
}
