/* Text Question "Convert voice to text": the mic button beside the answer box (voice-to-text.js). */

/* "Select language to speak" (as in Quick Action). */
.sf-voice-wrap {
  width: 100%;
}

.sf-voice-language-row {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-bottom: 8px;
  color: #64748b;
  font-size: 13px;
  font-weight: 600;
}

/* The trigger: the picked language and a caret, in the form's own font. */
.voice-language-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  max-width: 100%;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  font: inherit;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.voice-language-trigger:hover {
  border-color: #cbd5e1;
}

.voice-language-trigger[aria-expanded="true"] {
  border-color: var(--sf-accent, #03a9f4);
  box-shadow: 0 0 0 3px rgba(3, 169, 244, 0.15);
}

.voice-language-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.voice-language-caret {
  display: inline-flex;
  flex: none;
  color: #64748b;
}

.voice-language-trigger[aria-expanded="true"] .voice-language-caret {
  transform: rotate(180deg);
}

.sf-voice-language {
  width: 200px;
  height: 34px;
  padding: 0 8px 0 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
}

/* Chat: a small picker in the message bar, beside the mic. */
.chat-voice-language {
  flex: none;
  width: 104px;
  height: 30px;
  padding: 0 4px 0 10px;
  border-radius: 999px;
  font-size: 12px;
}

.voice-language-trigger:focus-visible {
  outline: 2px solid var(--sf-accent, #03a9f4);
  outline-offset: 2px;
}

/* The list: on <body>, under the trigger (above it in the chat bar), short with a thin scrollbar. */
.voice-language-panel {
  position: fixed;
  z-index: 2147483000;
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
  color: #0f172a;
  font-size: 13px;
}

.voice-language-search {
  box-sizing: border-box;
  width: 100%;
  height: 32px;
  margin-bottom: 6px;
  padding: 0 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: inherit;
  font: inherit;
  outline: none;
}

.voice-language-search:focus {
  border-color: var(--sf-accent, #03a9f4);
  background: #fff;
}

.voice-language-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

.voice-language-list::-webkit-scrollbar {
  width: 6px;
}

.voice-language-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cbd5e1;
}

.voice-language-group {
  padding: 8px 8px 4px;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.voice-language-option {
  display: block;
  box-sizing: border-box;
  width: 100%;
  padding: 7px 10px 7px 16px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.voice-language-option:hover,
.voice-language-option.is-focused {
  background: #f1f5f9;
}

.voice-language-option.is-selected {
  background: rgba(3, 169, 244, 0.12);
  color: #0369a1;
  font-weight: 600;
}

.voice-language-empty {
  padding: 10px;
  color: #64748b;
}

/* Survey page: the button sits in the textarea's bottom-right corner. */
.sf-voice-field {
  position: relative;
  width: 100%;
}

.sf-voice-field .sf-area {
  padding-right: 52px;
}

.sf-dictate-btn,
.chat-dictate-btn {
  display: grid;
  place-items: center;
  flex: none;
  padding: 0;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.sf-dictate-btn {
  position: absolute;
  right: 10px;
  bottom: 12px;
  width: 36px;
  height: 36px;
  background: var(--sf-accent, #03a9f4);
  color: #fff;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

.chat-dictate-btn {
  width: 34px;
  height: 34px;
  background: transparent;
  color: #64748b;
}

.sf-dictate-btn:focus-visible,
.chat-dictate-btn:focus-visible {
  outline: 2px solid var(--sf-accent, #03a9f4);
  outline-offset: 2px;
}

/* Listening: red, with a soft pulse (none for visitors who ask for less motion). */
.sf-dictate-btn.is-listening,
.chat-dictate-btn.is-listening {
  background: #ef4444;
  color: #fff;
  animation: voice-to-text-pulse 1.4s ease-out infinite;
}

@keyframes voice-to-text-pulse {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  100% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .sf-dictate-btn.is-listening,
  .chat-dictate-btn.is-listening {
    animation: none;
  }
}
