/* ==============================================================================
   LiveKit Voice AI - Modern Premium Stylesheet
   ============================================================================== */

:root {
  --bg-primary: #080c15;
  --bg-secondary: #0d1322;
  --surface-card: rgba(16, 24, 40, 0.75);
  --surface-border: rgba(255, 255, 255, 0.08);
  --surface-hover: rgba(255, 255, 255, 0.04);

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

  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-glow-cyan: 0 0 35px rgba(6, 182, 212, 0.25);
  --shadow-glow-purple: 0 0 35px rgba(139, 92, 246, 0.25);
  --shadow-glass: 0 10px 30px rgba(0, 0, 0, 0.4);
}

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

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

/* Ambient glow backgrounds */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
}

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, rgba(6, 182, 212, 0.05) 70%, transparent 100%);
  top: -100px;
  left: 10%;
}

.bg-glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, rgba(59, 130, 246, 0.04) 70%, transparent 100%);
  bottom: -150px;
  right: 5%;
}

/* Application Layout */
.app-layout {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 28px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-glass);
}

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

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(6, 182, 212, 0.2), rgba(139, 92, 246, 0.3));
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-cyan);
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

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

.status-disconnected {
  background: rgba(148, 163, 184, 0.1);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.2);
}
.status-disconnected .badge-dot {
  background: var(--text-muted);
}

.status-connecting {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border-color: rgba(245, 158, 11, 0.3);
}
.status-connecting .badge-dot {
  background: var(--accent-amber);
  box-shadow: 0 0 8px var(--accent-amber);
  animation: pulse-dot 1.2s infinite;
}

.status-connected {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.3);
}
.status-connected .badge-dot {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.env-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.env-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}
.env-configured .env-dot {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}
.env-configured {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.2);
}

/* Main Grid Layout */
.main-content {
  display: grid;
  grid-template-columns: 600px 1fr;
  gap: 24px;
  flex: 1;
  min-height: 0;
}

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

/* Glass Panel Component */
.glass-panel {
  background: var(--surface-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

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

.section-title {
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.header-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.video-mode-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

/* Dual Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

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

.video-tile {
  background: rgba(10, 16, 28, 0.85);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  aspect-ratio: 4 / 3;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.video-tile:hover {
  border-color: rgba(255, 255, 255, 0.18);
}

.video-tile.speaking {
  border-color: var(--accent-emerald);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.35);
}

.video-tile.thinking {
  border-color: var(--accent-purple);
  box-shadow: 0 0 18px rgba(139, 92, 246, 0.35);
}

.video-tile.listening {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(6, 182, 212, 0.3);
}

.tile-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(8, 12, 21, 0.85) 0%, transparent 100%);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  pointer-events: none;
}

.tile-identity {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-primary);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

.identity-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.ai-badge {
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  color: #fff;
}

.candidate-badge {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.tile-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
}

.tile-status-badge.status-cam-on {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.4);
}

.tile-status-badge.status-cam-off {
  color: var(--text-muted);
}

.tile-status-badge.status-speaking {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.15);
}

.tile-status-badge.status-thinking {
  color: var(--accent-purple);
  border-color: rgba(139, 92, 246, 0.4);
  background: rgba(139, 92, 246, 0.15);
}

.tile-status-badge.status-listening {
  color: var(--accent-cyan);
  border-color: rgba(6, 182, 212, 0.4);
  background: rgba(6, 182, 212, 0.15);
}

.remote-participant-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
  border-radius: var(--radius-md);
}

.ai-avatar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(14, 23, 42, 0.95) 0%, rgba(6, 10, 18, 0.98) 100%);
  position: relative;
  padding: 10px 0;
}

.ai-avatar-wrapper .voice-orb {
  width: 90px;
  height: 90px;
}

.ai-avatar-wrapper .orb-core {
  width: 44px;
  height: 44px;
}

.video-viewport {
  flex: 1;
  position: relative;
  background: #040711;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.video-element {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: none;
}

.video-element.active {
  display: block;
}

.camera-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-muted);
  text-align: center;
  padding: 16px;
  z-index: 2;
}

.placeholder-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.camera-placeholder p {
  font-size: 0.76rem;
  max-width: 160px;
  line-height: 1.3;
}

.tile-bottom-bar {
  padding: 8px 12px;
  background: linear-gradient(0deg, rgba(8, 12, 21, 0.9) 0%, transparent 100%);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tile-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tile-indicators {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.mini-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.mini-indicator.active {
  color: var(--accent-emerald);
  border-color: rgba(16, 185, 129, 0.3);
}

.mini-indicator.muted {
  color: var(--accent-rose);
  border-color: rgba(244, 63, 94, 0.3);
}

/* Agent State Badge */
.agent-state-badge {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: all 0.3s ease;
}

.state-idle {
  background: rgba(100, 116, 139, 0.2);
  color: var(--text-muted);
}
.state-listening {
  background: rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.4);
}
.state-thinking {
  background: rgba(139, 92, 246, 0.2);
  color: var(--accent-purple);
  border: 1px solid rgba(139, 92, 246, 0.4);
  animation: pulse-border 1.5s infinite;
}
.state-speaking {
  background: rgba(16, 185, 129, 0.2);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.25);
}

/* Voice Visualizer Orb */
.orb-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 0;
  position: relative;
}

.voice-orb {
  width: 140px;
  height: 140px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.orb-core {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #06b6d4, #8b5cf6);
  box-shadow: 0 0 25px rgba(6, 182, 212, 0.4);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 2;
}

.orb-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(6, 182, 212, 0.3);
  transition: all 0.5s ease;
}

.ring-1 {
  width: 90px;
  height: 90px;
  border-color: rgba(6, 182, 212, 0.25);
}

.ring-2 {
  width: 120px;
  height: 120px;
  border-color: rgba(139, 92, 246, 0.2);
}

.ring-3 {
  width: 150px;
  height: 150px;
  border-color: rgba(59, 130, 246, 0.15);
}

/* Orb Dynamic States */
.voice-orb.state-speaking .orb-core {
  transform: scale(1.3);
  background: linear-gradient(135deg, #10b981, #06b6d4);
  box-shadow: 0 0 45px rgba(16, 185, 129, 0.6);
  animation: pulse-core 0.9s infinite alternate;
}
.voice-orb.state-speaking .ring-1 {
  transform: scale(1.2);
  border-color: rgba(16, 185, 129, 0.6);
  animation: ring-pulse 1.6s infinite ease-out;
}
.voice-orb.state-speaking .ring-2 {
  transform: scale(1.3);
  border-color: rgba(6, 182, 212, 0.4);
  animation: ring-pulse 2.2s infinite ease-out 0.4s;
}

.voice-orb.state-thinking .orb-core {
  transform: scale(1.1);
  background: linear-gradient(135deg, #8b5cf6, #d946ef);
  box-shadow: 0 0 35px rgba(139, 92, 246, 0.6);
  animation: rotate-core 3s infinite linear;
}

.voice-orb.state-listening .orb-core {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

.orb-hint {
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-align: center;
  min-height: 20px;
}

/* Audio Wave Bars */
.audio-waves {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  margin-bottom: 20px;
}

.wave-bar {
  width: 4px;
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  transition: height 0.15s ease, background-color 0.3s ease;
}

.audio-waves.active .wave-bar {
  background: var(--accent-cyan);
  animation: wave-anim 0.8s ease-in-out infinite alternate;
}

.audio-waves.active .wave-bar:nth-child(2) { animation-delay: 0.1s; }
.audio-waves.active .wave-bar:nth-child(3) { animation-delay: 0.2s; }
.audio-waves.active .wave-bar:nth-child(4) { animation-delay: 0.3s; }
.audio-waves.active .wave-bar:nth-child(5) { animation-delay: 0.4s; }
.audio-waves.active .wave-bar:nth-child(6) { animation-delay: 0.35s; }
.audio-waves.active .wave-bar:nth-child(7) { animation-delay: 0.25s; }
.audio-waves.active .wave-bar:nth-child(8) { animation-delay: 0.15s; }
.audio-waves.active .wave-bar:nth-child(9) { animation-delay: 0.05s; }
.audio-waves.active .wave-bar:nth-child(10) { animation-delay: 0.2s; }

/* Tech Pills */
.tech-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 24px;
}

.tech-pill {
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Action Buttons */
.controls-row {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, #06b6d4, #2563eb);
  color: #ffffff;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.45);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--surface-border);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
}

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

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
  border-color: rgba(244, 63, 94, 0.5);
}

.btn-outline {
  background: transparent;
  border: 1px dashed var(--surface-border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.btn-sm {
  padding: 8px 14px;
  font-size: 0.8rem;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

/* Accordion for Configuration */
.connection-accordion {
  margin-top: 20px;
  border-top: 1px solid var(--surface-border);
  padding-top: 16px;
}

.accordion-header {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  list-style: none;
  user-select: none;
}

.accordion-header::-webkit-details-marker {
  display: none;
}

.chevron-icon {
  transition: transform 0.2s ease;
}

.connection-accordion[open] .chevron-icon {
  transform: rotate(180deg);
}

.accordion-body {
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent-cyan);
}

/* Transcript Card */
.transcript-card {
  min-height: 520px;
  height: calc(100vh - 170px);
  max-height: 800px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.transcript-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topic-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  background: rgba(6, 182, 212, 0.1);
  border: 1px solid rgba(6, 182, 212, 0.2);
  color: var(--accent-cyan);
  border-radius: var(--radius-sm);
}

.transcript-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Scrollable Container */
.transcript-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 6px 20px 4px;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

/* Custom scrollbar */
.transcript-scroll::-webkit-scrollbar {
  width: 6px;
}
.transcript-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.transcript-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}
.transcript-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Empty State */
.empty-state {
  margin: auto;
  text-align: center;
  max-width: 360px;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--surface-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Messages List */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.transcript-item {
  display: flex;
  gap: 14px;
  animation: slide-up 0.25s ease-out;
}

.transcript-item.item-user {
  flex-direction: row-reverse;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-agent {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.3), rgba(6, 182, 212, 0.3));
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #c084fc;
}

.avatar-user {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(20, 184, 166, 0.3));
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
}

.message-content {
  max-width: 80%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.item-user .message-content {
  align-items: flex-end;
}

.message-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
}

.sender-name {
  font-weight: 600;
  color: var(--text-secondary);
}

.timestamp {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.stream-badge {
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.bubble-agent {
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.25);
  color: #f1f5f9;
  border-top-left-radius: 4px;
}

.bubble-user {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #f1f5f9;
  border-top-right-radius: 4px;
}

/* Live stream typing cursor */
.typing-cursor {
  display: inline-block;
  width: 2px;
  height: 14px;
  background-color: var(--accent-cyan);
  vertical-align: middle;
  margin-left: 4px;
  animation: blink 0.8s infinite;
}

/* Transcript Footer */
.transcript-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--surface-border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-connected ~ .main-content .live-dot,
body.room-active .live-dot {
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

/* Toast Notifications */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: #1e293b;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 0.85rem;
  box-shadow: var(--shadow-glass);
  z-index: 100;
  transition: all 0.3s ease;
}

.hidden {
  display: none !important;
}

/* Animations */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(139, 92, 246, 0.4); }
  50% { border-color: rgba(139, 92, 246, 0.9); }
}

@keyframes pulse-core {
  0% { transform: scale(1.15); }
  100% { transform: scale(1.35); }
}

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

@keyframes rotate-core {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes wave-anim {
  0% { height: 6px; }
  100% { height: 28px; }
}

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

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ==============================================================================
   Candidate Pre-Join Lobby Styles
   ============================================================================== */
.lobby-screen {
  grid-column: 1 / -1;
  max-width: 800px;
  margin: 20px auto;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(13, 19, 34, 0.92);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
  animation: slide-up 0.3s ease-out;
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid var(--surface-border);
  padding-bottom: 18px;
}

.lobby-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.3);
  margin-bottom: 8px;
}

.lobby-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
}

.lobby-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 4px;
}

.slot-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
}

.slot-scheduled {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

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

.slot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.lobby-schedule-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  background: rgba(16, 24, 40, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.schedule-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.schedule-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schedule-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.schedule-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

.countdown-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(6, 182, 212, 0.05);
  border: 1px solid rgba(6, 182, 212, 0.2);
}

.countdown-label {
  font-size: 0.8rem;
  color: var(--accent-cyan);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.countdown-timer {
  font-family: var(--font-mono);
  font-size: 2.2rem;
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 2px;
  margin: 6px 0;
}

.countdown-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.lobby-devices-card, .lobby-tips-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px;
  background: rgba(16, 24, 40, 0.6);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.devices-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
}

.device-check-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.device-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.device-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.mic-meter-wrapper {
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 4px;
}

.mic-meter-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #10b981, #06b6d4);
  transition: width 0.08s ease;
  border-radius: var(--radius-full);
}

.lobby-tips-card h4 {
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.lobby-tips-card ul {
  padding-left: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.lobby-action-row {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

.btn-lg {
  padding: 14px 36px;
  font-size: 1.05rem;
  font-weight: 600;
}

.main-content.in-lobby .video-stage-card,
.main-content.in-lobby .transcript-card {
  display: none !important;
}

.main-content.in-completion .video-stage-card,
.main-content.in-completion .transcript-card,
.main-content.in-completion .lobby-screen {
  display: none !important;
}

/* ==============================================================================
   Completion & Thank You Screen Styles
   ============================================================================== */
.completion-screen {
  grid-column: 1 / -1;
  max-width: 680px;
  margin: 30px auto;
  padding: 44px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(16, 185, 129, 0.25);
  background: radial-gradient(circle at 50% 0%, rgba(16, 185, 129, 0.12) 0%, rgba(15, 23, 42, 0.8) 75%);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5), 0 0 40px rgba(16, 185, 129, 0.1);
}

.completion-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.completion-icon-wrapper {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.15);
  border: 2px solid rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.3);
  animation: pulse-success 2.5s infinite ease-in-out;
}

@keyframes pulse-success {
  0%, 100% { transform: scale(1); box-shadow: 0 0 25px rgba(16, 185, 129, 0.25); }
  50% { transform: scale(1.05); box-shadow: 0 0 40px rgba(16, 185, 129, 0.45); }
}

.completion-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.completion-badge-pill.locked {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
}

.completion-title {
  font-size: 1.85rem;
  font-weight: 800;
  color: #f8fafc;
  margin-top: 4px;
}

.completion-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
  max-width: 540px;
  line-height: 1.6;
}

.completion-meta-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  margin: 14px 0;
}

.meta-card {
  padding: 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.meta-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.meta-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: #f1f5f9;
}

.text-emerald {
  color: #10b981 !important;
}

.completion-notice-box {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-md);
  text-align: left;
  margin-top: 6px;
}

.completion-notice-box p {
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.55;
  margin: 0;
}
