/**
 * Vocalect Audio Input Frontend Stylesheet
 * 
 * Elegant overlay microphone positioning, custom animations,
 * high-contrast compatibility, and responsive styling.
 *
 * @package Vocalect_Audio_Input
 */

/* Container wrapping the input/textarea to handle relative positioning */
.vocalect-field-wrapper {
  position: relative;
  display: block;
  width: 100%;
}

/* Base microphone button style */
.vocalect-mic-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  cursor: pointer;
  z-index: 10;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  margin: 0;
  outline: none;
}

/* Standard positions */
.vocalect-mic-btn.vocalect-pos-right {
  right: 12px;
}

.vocalect-mic-btn.vocalect-pos-left {
  left: 12px;
}

/* When mic is in a textarea, pin it to the top-right or top-left instead of vertical middle */
textarea + .vocalect-mic-btn,
.vocalect-field-wrapper.textarea-wrapper .vocalect-mic-btn {
  top: 14px;
  transform: none;
}

/* Style options */
/* Minimal flat icon */
.vocalect-mic-btn.style-minimal {
  color: #64748b;
  width: 24px;
  height: 24px;
  border-radius: 4px;
}
.vocalect-mic-btn.style-minimal:hover {
  color: #1e293b;
  background-color: rgba(15, 23, 42, 0.05);
}

/* Circle button style (Premium Default) */
.vocalect-mic-btn.style-circle {
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.vocalect-mic-btn.style-circle:hover {
  color: #0f172a;
  background: #e2e8f0;
  border-color: #94a3b8;
  transform: translateY(-50%) scale(1.05);
}
/* Handle textareas scale */
textarea + .vocalect-mic-btn.style-circle:hover,
.vocalect-field-wrapper.textarea-wrapper .vocalect-mic-btn.style-circle:hover {
  transform: scale(1.05);
}

/* Inactive State */
.vocalect-mic-btn svg {
  width: 16px;
  height: 16px;
  pointer-events: none;
}

/* Listening State with beautiful pulsing ring */
.vocalect-mic-btn.state-listening {
  color: #ffffff !important;
  background: #ef4444 !important;
  border-color: #ef4444 !important;
  animation: vocalect-pulse 1.8s infinite;
}

/* Processing State */
.vocalect-mic-btn.state-processing {
  color: #ffffff !important;
  background: #3b82f6 !important;
  border-color: #3b82f6 !important;
}
.vocalect-mic-btn.state-processing svg {
  animation: vocalect-spin 1.2s linear infinite;
}

/* Error State */
.vocalect-mic-btn.state-error {
  color: #ffffff !important;
  background: #f59e0b !important;
  border-color: #f59e0b !important;
}

/* Make sure inputs have sufficient padding to not overlap text with the mic button */
.vocalect-input-padded-right {
  padding-right: 44px !important;
}
.vocalect-input-padded-left {
  padding-left: 44px !important;
}

/* Floating Voice Capture Dashboard Overlay */
.vocalect-voice-overlay {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  animation: vocalect-slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: none;
}

@keyframes vocalect-slide-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.vocalect-voice-card {
  position: relative;
  background: rgba(42, 45, 55, 0.90);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 28px;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: visible;
  box-sizing: border-box;
}

.vocalect-ambient-glow {
  position: absolute;
  right: -32px;
  bottom: -32px;
  width: 192px;
  height: 192px;
  background: rgba(244, 63, 94, 0.2);
  border-radius: 50%;
  filter: blur(48px);
  pointer-events: none;
  z-index: -1;
}

.vocalect-voice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vocalect-app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.vocalect-app-icon {
  width: 36px;
  height: 36px;
  background: #ffffff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  flex-shrink: 0;
}

.vocalect-app-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.vocalect-app-info {
  display: flex;
  flex-direction: column;
}

.vocalect-app-title {
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.vocalect-target-label {
  color: #94a3b8;
  font-size: 10px;
  font-weight: 500;
  margin-top: 2px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vocalect-brand-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.8);
}

.vocalect-brand-badge svg {
  width: 16px;
  height: 16px;
  color: #818cf8;
}

.vocalect-badge-text {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.vocalect-wave-container {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 8px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vocalect-voice-wave {
  width: 100%;
  height: 40px;
  display: block;
  background: transparent;
}

.vocalect-voice-text-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 14px;
  max-height: 90px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.5;
  min-height: 54px;
  color: #f1f5f9;
  box-sizing: border-box;
}

.vocalect-voice-final {
  color: #ffffff;
  font-weight: 500;
}

.vocalect-voice-interim {
  color: #818cf8;
  font-style: italic;
  font-weight: 300;
}

.vocalect-language-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 6px 12px;
  font-size: 11px;
  color: #d1d5db;
  margin-top: -2px;
  box-sizing: border-box;
}

.vocalect-language-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  font-weight: 500;
}

.vocalect-language-label svg {
  width: 14px;
  height: 14px;
  color: #818cf8;
}

.vocalect-language-select {
  background: transparent !important;
  border: none !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  cursor: pointer !important;
  outline: none !important;
  padding: 0 4px !important;
  margin: 0 !important;
  height: auto !important;
  box-shadow: none !important;
  -webkit-appearance: menulist !important;
  -moz-appearance: menulist !important;
  appearance: menulist !important;
}

.vocalect-language-select option {
  background: #242630 !important;
  color: #f1f5f9 !important;
}

.vocalect-voice-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-t: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 12px;
  margin-top: 4px;
}

.vocalect-keyboard-tip {
  display: flex;
  align-items: center;
  gap: 4px;
  color: rgba(156, 163, 175, 0.6);
  font-size: 11px;
  font-weight: 500;
}

.vocalect-keyboard-tip kbd {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0 4px;
  border-radius: 4px;
  font-size: 10px;
  font-family: inherit;
  font-weight: bold;
  color: #94a3b8;
}

.vocalect-action-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.vocalect-action-buttons button {
  border: none;
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vocalect-btn-discard {
  background: rgba(255, 255, 255, 0.05) !important;
  color: #cbd5e1 !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
}
.vocalect-btn-discard:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #fca5a5 !important;
  border-color: rgba(239, 68, 68, 0.2) !important;
}

.vocalect-btn-apply {
  background: #4f46e5 !important;
  color: #ffffff !important;
  border: 1px solid rgba(79, 70, 229, 0.25) !important;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}
.vocalect-btn-apply:hover {
  background: #4338ca !important;
}

/* Tooltip on Hover / State description */
.vocalect-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  background: #0f172a;
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  white-space: nowrap;
  z-index: 999;
}
.vocalect-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px;
  border-style: solid;
  border-color: #0f172a transparent transparent transparent;
}
.vocalect-mic-btn:hover .vocalect-tooltip {
  opacity: 1;
  visibility: visible;
}

/* Animations */
@keyframes vocalect-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes vocalect-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes vocalect-blink {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

@keyframes vocalect-fade-in {
  from { opacity: 0; transform: translate(-50%, 4px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* Keyboard accessibility outline */
.vocalect-mic-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* High Contrast Mode Adjustments */
@media (forced-colors: active) {
  .vocalect-mic-btn {
    border: 1px solid CanvasText !important;
  }
  .vocalect-mic-btn.state-listening {
    background-color: Highlight !important;
  }
}
