/* Voice overlay + modal */
.voice-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10010;
  display: none;
  align-items: center;
  justify-content: center;
}

.voice-overlay[aria-hidden="false"] {
  display: flex;
}

.voice-modal {
  background: var(--white);
  border-radius: 20px;
  width: 90vw;
  max-width: 420px;
  box-shadow: 0 24px 80px rgba(11, 31, 58, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.voice-modal header {
  background: var(--navy);
  color: var(--white);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.voice-modal header h3 {
  margin: 0;
  font-size: 1rem;
}

.voice-modal header button {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: var(--white);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  line-height: 1;
}

.voice-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 40px 20px 24px;
  gap: 20px;
}

/* Waveform bars */
.voice-waveform {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
}

.voice-waveform span {
  display: block;
  width: 4px;
  height: 8px;
  background: var(--teal);
  border-radius: 2px;
  opacity: 0.3;
  transition: height 0.15s, opacity 0.15s;
}

.voice-waveform.active span {
  opacity: 1;
  animation: waveform-bounce 0.8s ease-in-out infinite;
}

.voice-waveform.active span:nth-child(1) { animation-delay: 0s; }
.voice-waveform.active span:nth-child(2) { animation-delay: 0.1s; }
.voice-waveform.active span:nth-child(3) { animation-delay: 0.2s; }
.voice-waveform.active span:nth-child(4) { animation-delay: 0.3s; }
.voice-waveform.active span:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveform-bounce {
  0%, 100% { height: 8px; }
  50% { height: 32px; }
}

/* Listening pulse — gentle green glow on waveform */
.voice-waveform.listening-pulse span {
  opacity: 0.5;
  background: #27ae60;
  animation: listening-pulse 2s ease-in-out infinite;
}

.voice-waveform.listening-pulse span:nth-child(1) { animation-delay: 0s; }
.voice-waveform.listening-pulse span:nth-child(2) { animation-delay: 0.15s; }
.voice-waveform.listening-pulse span:nth-child(3) { animation-delay: 0.3s; }
.voice-waveform.listening-pulse span:nth-child(4) { animation-delay: 0.45s; }
.voice-waveform.listening-pulse span:nth-child(5) { animation-delay: 0.6s; }

@keyframes listening-pulse {
  0%, 100% { height: 8px; opacity: 0.3; }
  50% { height: 16px; opacity: 0.7; }
}

/* Mic button */
.voice-mic-btn {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--teal);
  color: var(--white);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(15, 108, 125, 0.3);
  position: relative;
}

.voice-mic-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 28px rgba(15, 108, 125, 0.4);
}

/* Recording state — red pulsing */
.voice-mic-btn.recording {
  background: #c0392b;
  animation: pulse-mic 1.5s infinite;
}

/* Disabled/processing state — pulsing animation, still clickable for barge-in */
.voice-mic-btn.disabled {
  opacity: 0.6;
  cursor: pointer;
  animation: pulse-processing 1.2s ease-in-out infinite;
}

@keyframes pulse-processing {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.05); }
}

/* Listening state — green glow */
.voice-mic-btn.listening {
  background: #27ae60;
  box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.4);
  animation: pulse-listening 2s infinite;
}

/* Muted state — gray with strikethrough */
.voice-mic-btn.muted {
  background: #95a5a6;
  box-shadow: 0 4px 20px rgba(149, 165, 166, 0.3);
  animation: none;
}

.voice-mic-btn.muted::after {
  content: "";
  position: absolute;
  width: 60%;
  height: 3px;
  background: var(--white);
  transform: rotate(-45deg);
  border-radius: 2px;
}

@keyframes pulse-mic {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192, 57, 43, 0.4); }
  50% { box-shadow: 0 0 0 16px rgba(192, 57, 43, 0); }
}

@keyframes pulse-listening {
  0%, 100% { box-shadow: 0 0 0 0 rgba(39, 174, 96, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(39, 174, 96, 0); }
}

/* Status text */
.voice-status {
  font-size: 0.85rem;
  color: rgba(11, 31, 58, 0.6);
  text-align: center;
  margin: 0;
  min-height: 1.4em;
}

/* Animated dots for processing */
.processing-dots::after {
  content: "";
  animation: processing-dots 1.5s steps(4, end) infinite;
}

@keyframes processing-dots {
  0%  { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

/* Mode toggle (PTT) */
.voice-mode-toggle {
  text-align: center;
  padding: 0 20px 4px;
}

.voice-ptt-btn {
  background: none;
  border: 1px solid rgba(11, 31, 58, 0.15);
  color: rgba(11, 31, 58, 0.5);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 12px;
  border-radius: 12px;
  transition: all 0.2s;
}

.voice-ptt-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.voice-ptt-btn.active {
  background: var(--teal);
  color: var(--white);
  border-color: var(--teal);
}

/* Transcript toggle */
.voice-transcript-toggle {
  text-align: center;
  padding: 0 20px 12px;
}

.voice-transcript-toggle button {
  background: none;
  border: none;
  color: var(--teal);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}

/* Transcript area */
.voice-transcript {
  max-height: 200px;
  overflow-y: auto;
  padding: 0 20px 20px;
  font-size: 0.85rem;
  line-height: 1.5;
}

.voice-transcript .vt-entry {
  padding: 6px 0;
  border-bottom: 1px solid rgba(11, 31, 58, 0.06);
}

.voice-transcript .vt-entry:last-child {
  border-bottom: none;
}

.voice-transcript .vt-role {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: rgba(11, 31, 58, 0.5);
  margin-bottom: 2px;
}

.voice-transcript .vt-role.user { color: var(--navy); }
.voice-transcript .vt-role.bot { color: var(--teal); }
