/* Voice input mic button — shown on assessment and simulation products.
   Visibility is toggled by static/js/voice-input.js
   after it reads productType from /api/products/frontend-config.

   The button lives inside .input-wrapper next to the file-upload
   button so it sits visually balanced with the existing chat
   affordances and inherits the pill's height/padding rhythm. */

.voice-mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 6px;
  margin: 0;
  background: transparent;
  border: none;
  color: #6b7280;
  cursor: pointer;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
  position: relative;
}

.voice-mic-btn:hover:not(:disabled) {
  background: #f3f4f6;
  color: #111827;
}

.voice-mic-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.voice-mic-btn.voice-mic-btn--disabled {
  color: var(--gray-mid, #6b7280);
  opacity: 0.42;
}

/* The free Saying No simulation is intentionally text-only. Keep the mic
   visible as a clear capability cue, but mark it unavailable. */
.voice-mic-btn.voice-mic-btn--disabled::after {
  content: '';
  position: absolute;
  width: 23px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transform: rotate(-45deg);
  pointer-events: none;
}

.voice-mic-btn.hidden {
  display: none !important;
}

.voice-menu-toggle {
  width: 18px;
  height: 28px;
  padding: 0;
  margin: 0 2px 0 -5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #9ca3af;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  flex: 0 0 auto;
}

.voice-menu-toggle:hover,
.voice-menu-toggle[aria-expanded="true"] {
  color: #374151;
  background: #f3f4f6;
}

.voice-menu-toggle.hidden {
  display: none !important;
}

.voice-options-menu {
  position: absolute;
  inset-inline-end: 48px;
  top: calc(100% + 8px);
  width: 220px;
  padding: 8px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(15, 30, 65, 0.16);
  z-index: 30;
}

.voice-options-menu[hidden] {
  display: none;
}

.voice-options-item {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  color: #111827;
  background: transparent;
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-size: 14px;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.voice-options-item:hover,
.voice-options-item:focus-visible {
  background: #f3f4f6;
  outline: none;
}

.voice-options-item + .voice-options-item {
  border-top: 1px solid #e5e7eb;
  border-radius: 0 0 10px 10px;
}

.voice-options-item-icon {
  font-size: 17px;
  text-align: center;
}

.voice-options-state,
.voice-options-chevron {
  color: #6b7280;
  font-size: 13px;
}

.autoplay-toggle-btn.voice-menu-owned {
  display: none !important;
}

.voice-mic-btn .voice-mic-icon,
.voice-mic-btn .voice-mic-recording,
.voice-mic-btn .voice-mic-spinner,
.voice-mic-btn .voice-mic-timer {
  display: none;
}

/* IDLE state — only the mic icon shows. */
.voice-mic-btn[data-state="idle"] .voice-mic-icon { display: inline-flex; }

/* RECORDING — red pulsing stop square + elapsed timer. */
.voice-mic-btn[data-state="recording"] {
  color: #dc2626;
  background: #fef2f2;
}
.voice-mic-btn[data-state="recording"]:hover {
  background: #fee2e2;
  color: #b91c1c;
}
.voice-mic-btn[data-state="recording"] .voice-mic-recording {
  display: inline-flex;
  animation: voice-mic-pulse 1.2s ease-in-out infinite;
}
.voice-mic-btn[data-state="recording"] .voice-mic-timer {
  display: inline;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

/* TRANSCRIBING — spinner + dimmed colour, button disabled. */
.voice-mic-btn[data-state="starting"],
.voice-mic-btn[data-state="transcribing"] {
  color: #6366f1;
  cursor: progress;
}
.voice-mic-btn[data-state="starting"] .voice-mic-spinner,
.voice-mic-btn[data-state="transcribing"] .voice-mic-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: voice-mic-spin 0.7s linear infinite;
}

@keyframes voice-mic-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

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

/* Tiny inline error/info pill that floats above the input on
   transcription failures and the one-time privacy disclosure. */
.voice-input-toast {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: 520px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.4;
  background: #fff7ed;
  color: #7c2d12;
  border: 1px solid #fed7aa;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  z-index: 5;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.voice-input-toast--info {
  background: #f0f9ff;
  color: #075985;
  border-color: #bae6fd;
}

.voice-input-toast button {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 4px;
}

/* Position the toast relative to the input area, not the button. */
.input-wrapper { position: relative; }

@media (max-width: 480px) {
  .voice-mic-btn[data-state="recording"] .voice-mic-timer {
    display: none;
  }
}
