/* Voice (ElevenLabs) — speak/mic buttons.
   Buttons pick up the surrounding agent color via --agent (set on .agent-scope).
   Outside an agent scope they fall back to the app brand. */
.voice-btn {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line-2);
  color: var(--text-1);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font);
  font-size: 12px; line-height: 1;
  padding: 0 10px;
  min-height: 30px;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.voice-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--agent, var(--brand)) 8%, var(--bg-3));
  color: var(--text-0);
  border-color: color-mix(in srgb, var(--agent, var(--brand)) 45%, var(--line-2));
}
.voice-btn:active:not(:disabled) { transform: scale(.96); }
.voice-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--agent, var(--brand)) 30%, transparent);
}
.voice-btn:disabled { opacity: 0.55; cursor: default; }
.voice-btn svg { display: block; }

/* Circular speak button under an AI bubble */
.voice-btn.speak-btn {
  width: 30px; height: 30px; padding: 0;
  color: color-mix(in srgb, var(--agent, var(--brand)) 75%, var(--text-1));
}
.voice-btn.speak-btn:hover:not(:disabled) {
  color: #fff;
  background: linear-gradient(180deg, var(--agent-2, var(--brand-2)), var(--agent, var(--brand)));
  border-color: color-mix(in srgb, var(--agent, var(--brand)) 60%, transparent);
}

/* Mic beside a plain form input — bigger circular target, agent-tinted */
.voice-btn.mic-btn {
  width: 40px; height: 40px; min-height: 40px; padding: 0;
  align-self: stretch;
  color: color-mix(in srgb, var(--agent, var(--brand)) 75%, var(--text-1));
  background: color-mix(in srgb, var(--agent, var(--brand)) 6%, var(--bg-2));
  border-color: color-mix(in srgb, var(--agent, var(--brand)) 35%, var(--line-2));
}
.voice-btn.mic-btn:hover:not(:disabled) {
  color: #fff;
  background: linear-gradient(180deg, var(--agent-2, var(--brand-2)), var(--agent, var(--brand)));
}

/* Speak button sits under an AI bubble; the bubble is white-space:pre-wrap,
   so this row must be a block element with no stray text nodes around it. */
.ai-msg-actions { display: flex; gap: 6px; margin-top: 8px; white-space: normal; }

.voice-btn.speaking {
  color: #fff;
  background: linear-gradient(180deg, var(--agent-2, var(--brand-2)), var(--agent, var(--brand)));
  border-color: color-mix(in srgb, var(--agent, var(--brand)) 60%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--agent, var(--brand)) 20%, transparent);
}
/* Recording is the one state the user must not miss - keep it obvious. */
.voice-btn.recording {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: voice-pulse 1.1s ease-in-out infinite;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--danger) 25%, transparent);
}
@keyframes voice-pulse {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.06); opacity: .85; }
}
.voice-btn.loading { color: transparent !important; }
.voice-btn.loading svg { visibility: hidden; }
.voice-btn.loading::after {
  content: '';
  position: absolute; inset: 0; margin: auto;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: voice-spin 0.7s linear infinite;
}
.voice-btn.loading { position: relative; }
@keyframes voice-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .voice-btn.recording, .voice-btn.loading::after { animation: none; }
}

/* Mic beside a plain form input (Agent Cornflower) */
.voice-input-row { display: flex; gap: 8px; align-items: stretch; }
.voice-input-row input { flex: 1; }

/* Per-customer read-aloud consent (Customer 360) */
.voice-consent {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-1); cursor: pointer;
}
.voice-consent input { accent-color: var(--brand); }
.voice-blocked-note { font-size: 11px; color: var(--text-2); line-height: 1.5; }
