:root {
  --bg-dark: #090d16;
  --card-bg: rgba(18, 24, 38, 0.7);
  --card-border: rgba(255, 255, 255, 0.08);
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --font-heading: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
}

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

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6, 182, 212, 0.1) 0px, transparent 50%);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  border-radius: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-badge {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  color: white;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 20px;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(6, 182, 212, 0.3);
}

.brand-text h1 {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.brand-text .subtext {
  font-size: 13px;
  color: var(--text-secondary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.04);
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid var(--card-border);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.disconnected {
  background: var(--text-muted);
}

.status-dot.connected {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 360px 1fr 380px;
  gap: 20px;
}

@media (max-width: 1180px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  backdrop-filter: blur(16px);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

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

.card-header h3 {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 600;
}

.badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.badge-accent {
  background: rgba(6, 182, 212, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

/* Phone Screen */
.phone-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
}

.agent-avatar-container {
  position: relative;
  width: 110px;
  height: 110px;
  margin-top: 10px;
}

.avatar-circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 3px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.avatar-initials {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.pulse-ring {
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  opacity: 0;
  transition: all 0.3s;
}

.pulse-ring.active {
  animation: pulse-animation 2s infinite ease-out;
}

@keyframes pulse-animation {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.3); opacity: 0; }
}

.agent-name {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
}

.agent-role {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.call-timer {
  font-family: monospace;
  font-size: 15px;
  color: var(--accent-cyan);
  margin-top: 8px;
  font-weight: 600;
}

.voice-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.voice-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.voice-dropdown {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

.voice-dropdown:hover {
  border-color: var(--accent-cyan);
}

.voice-dropdown option {
  background: #0f172a;
  color: #f8fafc;
}

/* Audio Visualizer & Mic Diagnostics */
.visualizer-container {
  width: 100%;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.mic-status-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mic-badge {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  font-weight: 600;
}

.mic-badge.active {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.mic-badge.error {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.badge-echo {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lang-dropdown {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--accent-cyan);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  outline: none;
  cursor: pointer;
}

.lang-dropdown option {
  background: #0f172a;
  color: white;
}

#audioVisualizer {
  width: 100%;
  height: 55px;
}

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

.live-hearing-chip {
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.15), rgba(59, 130, 246, 0.15));
  border: 1px solid rgba(6, 182, 212, 0.4);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  word-break: break-word;
  animation: fadeIn 0.2s;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse-dot-anim 1s infinite alternate;
}

@keyframes pulse-dot-anim {
  from { opacity: 0.4; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1.2); }
}

/* Controls */
.controls-row {
  display: flex;
  gap: 12px;
  width: 100%;
}

.btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 14px;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-call {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-call:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-end {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
}

.btn-interrupt {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.btn-interrupt:not(:disabled):hover {
  background: #f59e0b;
  color: #111827;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
  transform: translateY(-2px);
}

.btn-interrupt:not(:disabled) {
  animation: interrupt-pulse 1.5s infinite;
}

@keyframes interrupt-pulse {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none !important;
}

/* Text Fallback Input */
.chat-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.chat-input-row input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 14px;
  color: white;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-row input:focus {
  border-color: var(--accent-cyan);
}

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--card-border);
  color: var(--accent-cyan);
  width: 42px;
  border-radius: 10px;
}

/* Transcript Section */
.transcript-section {
  display: flex;
  flex-direction: column;
  height: 600px;
}

.transcript-box {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-right: 6px;
}

.transcript-box::-webkit-scrollbar {
  width: 6px;
}
.transcript-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.empty-state {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.message-bubble {
  padding: 12px 16px;
  border-radius: 14px;
  max-width: 85%;
  font-size: 14px;
  line-height: 1.5;
  animation: fadeIn 0.2s ease-out;
}

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

.message-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(6, 182, 212, 0.2));
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-bubble.agent {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.sender-tag {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Lead Section */
.lead-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.lead-field {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lead-field.full-width {
  grid-column: span 2;
}

.field-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.field-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.field-value.highlight {
  color: var(--accent-cyan);
}

.field-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.status-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.status-tag.confirmed {
  color: var(--accent-emerald);
}

/* Saved Leads */
.saved-leads-box {
  margin-top: 24px;
  border-top: 1px solid var(--card-border);
  padding-top: 16px;
}

.saved-leads-box h4 {
  font-size: 13px;
  font-family: var(--font-heading);
  color: var(--text-secondary);
  margin-bottom: 12px;
}

.leads-list {
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.saved-lead-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.empty-mini {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}
