/* ===== Global ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
}

body {
  background-color: #0f172a;
  color: #f8fafc;
  height: 100vh;
  /* Fixed height */
  overflow: hidden;
  /* No scrolling */
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  position: relative;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.95);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-card {
  background: #1e293b;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  min-width: 300px;
}

.spinner-wrapper {
  height: 50px;
  display: flex;
  align-items: center;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(56, 189, 248, 0.1);
  border-top-color: #38bdf8;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Success Checkmark */
.loading-success {
  font-size: 40px;
  color: #4ade80;
  display: block;
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.loading-spinner.hidden,
.loading-success.hidden {
  display: none;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#loadingMessage {
  font-size: 1.1rem;
  color: #e2e8f0;
}

.loading-btn {
  background: #38bdf8;
  color: #0f172a;
  border: none;
  padding: 10px 30px;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
}

.loading-btn:hover {
  background: #0ea5e9;
  transform: translateY(-2px);
}

.loading-btn.hidden {
  display: none;
}

/* ===== Status Banner ===== */
.status-banner {
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
  flex-shrink: 0;
  /* Prevent shrinking */
}

.status-card {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px 20px;
  border-radius: 16px;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.1);
  backdrop-filter: blur(10px);
}

.transcription-card {
  background: rgba(30, 41, 59, 0.4);
}

.status-icon {
  font-size: 28px;
}

.status-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow: hidden;
}

.status-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
}

.status-value {
  font-size: 18px;
  font-weight: 600;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-value[data-state="processing"] {
  color: #fb923c;
}

.status-value[data-state="responding"] {
  color: #60a5fa;
}

.status-value[data-state="silence"],
.status-value[data-state="idle"] {
  color: #4ade80;
}

.status-value[data-state="listening"] {
  color: #facc15;
}

.status-value[data-state="interrupted"] {
  color: #f87171;
}

.user-transcription {
  font-size: 16px;
  color: #e2e8f0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  /* direction: rtl; Truncate from start visually */
  text-align: left;
  /* Keep text aligned left */
}

.user-transcription.updated {
  color: #38bdf8;
}

/* ===== Main Container ===== */
.main-container {
  flex: 1;
  /* Fill remaining height */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* Center vertically */
  gap: 40px;
  width: 100%;
  max-width: 500px;
  padding-bottom: 20px;
}

/* Assistant Circle */
.circle-container {
  width: 280px;
  height: 280px;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.voice-circle {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.15) 0%, rgba(15, 23, 42, 0.4) 70%);
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.15), inset 0 0 20px rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Circle Status Text */
.circle-status {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(56, 189, 248, 0.8);
  z-index: 2;
  pointer-events: none;
  transition: color 0.3s ease;
}

/* --- Dynamic States for Circle --- */

/* State: Speaking (Assistant is talking) */
.voice-circle.state-speaking {
  background: radial-gradient(circle, rgba(168, 85, 247, 0.2) 0%, rgba(15, 23, 42, 0.4) 70%);
  border-color: rgba(168, 85, 247, 0.4);
  box-shadow: 0 0 50px rgba(168, 85, 247, 0.3), inset 0 0 30px rgba(168, 85, 247, 0.2);
  animation: pulse-purple 2s infinite;
}

.voice-circle.state-speaking .circle-status {
  color: rgba(216, 180, 254, 0.9);
}

/* State: Listening (User is talking or VAD active) */
.voice-circle.state-listening {
  background: radial-gradient(circle, rgba(56, 189, 248, 0.25) 0%, rgba(15, 23, 42, 0.4) 70%);
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 50px rgba(56, 189, 248, 0.3), inset 0 0 30px rgba(56, 189, 248, 0.2);
}

/* State: Processing (Thinking) */
.voice-circle.state-processing {
  background: radial-gradient(circle, rgba(251, 146, 60, 0.2) 0%, rgba(15, 23, 42, 0.4) 70%);
  border-color: rgba(251, 146, 60, 0.4);
  box-shadow: 0 0 40px rgba(251, 146, 60, 0.25);
  animation: breathe-orange 3s infinite ease-in-out;
}

.voice-circle.state-processing .circle-status {
  color: rgba(253, 186, 116, 0.9);
}

/* Animations */
@keyframes pulse-purple {
  0% {
    transform: scale(1);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.3);
  }

  50% {
    transform: scale(1.05);
    box-shadow: 0 0 60px rgba(168, 85, 247, 0.5);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.3);
  }
}

@keyframes breathe-orange {

  0%,
  100% {
    opacity: 0.8;
    transform: scale(0.98);
  }

  50% {
    opacity: 1;
    transform: scale(1.02);
  }
}

/* Controls */
.bottom-controls {
  display: flex;
  gap: 20px;
  width: 100%;
  justify-content: center;
}

.control-btn {
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 30px;
  background: rgba(56, 189, 248, 0.1);
  color: #38bdf8;
  padding: 12px 32px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
}

.control-btn:hover:enabled {
  background: rgba(56, 189, 248, 0.2);
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3);
}

.control-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  border-color: #475569;
  color: #64748b;
}

/* Waveform */
#waveformCanvas {
  width: 100%;
  height: 60px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

/* Footer */
.footer {
  font-size: 0.75rem;
  color: #475569;
  text-align: center;
  padding-top: 10px;
  flex-shrink: 0;
}