/* ConfiaVET — Voice Recorder UI styles
   Aligned with the project's color palette and visual identity. */

.voice-input {
  position: relative;
}

.voice-input textarea {
  /* Leave room for the mic button on the right edge */
  padding-right: 56px;
}

/* The microphone button */
.mic-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid #e8e2d4;
  background: #ffffff;
  color: #1d3a8a;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 0.2s ease,
              background-color 0.2s ease,
              color 0.2s ease,
              border-color 0.2s ease;
  padding: 0;
  z-index: 2;
  box-shadow: 0 1px 2px rgba(20, 42, 99, 0.05);
}

.mic-btn svg {
  width: 18px;
  height: 18px;
}

.mic-btn:hover {
  background: #f0f4fc;
  border-color: #c5d3f0;
  color: #142a63;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(20, 42, 99, 0.08);
}

.mic-btn:active {
  transform: translateY(0) scale(0.96);
}

.mic-btn:focus-visible {
  outline: 2px solid #4f70d8;
  outline-offset: 2px;
}

/* Recording state */
.mic-btn[data-state="recording"] {
  background: #c44b3d;
  border-color: #c44b3d;
  color: #ffffff;
  animation: mic-pulse 1.4s ease-in-out infinite;
}

.mic-btn[data-state="recording"]:hover {
  background: #a83a2e;
  border-color: #a83a2e;
}

@keyframes mic-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(196, 75, 61, 0.45),
                0 1px 2px rgba(20, 42, 99, 0.05);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(196, 75, 61, 0),
                0 1px 2px rgba(20, 42, 99, 0.05);
  }
}

/* Processing state */
.mic-btn[data-state="processing"] {
  background: #e6ecfa;
  border-color: #c5d3f0;
  color: #1d3a8a;
  cursor: wait;
}

.mic-btn[data-state="processing"] svg {
  animation: mic-spin 0.9s linear infinite;
}

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

/* Live timer shown under the button while recording */
.mic-timer {
  position: absolute;
  top: 52px;
  right: 10px;
  background: #1d3a8a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 3px 8px;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 2;
}

.mic-timer.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Inline toast (success/error message) */
.mic-toast {
  position: absolute;
  top: -34px;
  right: 0;
  background: #1a1a1f;
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 3;
  box-shadow: 0 6px 18px rgba(20, 42, 99, 0.12);
}

.mic-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.mic-toast[data-kind="success"] {
  background: #0d8f6b;
}

.mic-toast[data-kind="error"] {
  background: #c44b3d;
}

/* Small caption explaining the feature, used once per form */
.voice-caption {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #7d7d8a;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: #f0f4fc;
  border-radius: 10px;
  border: 1px solid #e6ecfa;
}

.voice-caption svg {
  width: 16px;
  height: 16px;
  color: #4f70d8;
  flex-shrink: 0;
}

.voice-caption strong {
  color: #1d3a8a;
  font-weight: 600;
}

/* Mobile tweaks */
@media (max-width: 640px) {
  .voice-input textarea {
    padding-right: 52px;
  }
  .mic-btn {
    width: 34px;
    height: 34px;
    top: 8px;
    right: 8px;
  }
  .mic-btn svg {
    width: 16px;
    height: 16px;
  }
}

/* ============================================================
   Variant: chat input (inline, alongside a send button)
   Positioned inside a position:relative form, to the LEFT of
   the send button. Smaller and rounder than the textarea version.
   ============================================================ */

.mic-btn--chat {
  position: absolute;
  top: 50%;
  right: 50px;                /* sits just left of the 38px send button at right:5px */
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border-radius: 999px;       /* fully circular to match the send button */
  border: 1px solid var(--border, #e8e2d4);
  background: #ffffff;
  color: #1d3a8a;
  z-index: 2;
}

.mic-btn--chat:hover {
  transform: translateY(-50%) translateY(-1px);
  background: #f0f4fc;
}

.mic-btn--chat:active {
  transform: translateY(-50%) scale(0.94);
}

.mic-btn--chat[data-state="recording"] {
  background: #c44b3d;
  border-color: #c44b3d;
  color: #ffffff;
  animation: mic-pulse-chat 1.4s ease-in-out infinite;
}

.mic-btn--chat[data-state="processing"] {
  background: #e6ecfa;
  border-color: #c5d3f0;
}

@keyframes mic-pulse-chat {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(196, 75, 61, 0.45),
                0 1px 2px rgba(20, 42, 99, 0.05);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(196, 75, 61, 0),
                0 1px 2px rgba(20, 42, 99, 0.05);
  }
}

/* Timer for the chat variant: floats above the input, centered */
.chat-input-form .mic-timer {
  top: auto;
  bottom: 100%;
  right: 50%;
  transform: translateX(50%) translateY(-6px);
}

.chat-input-form .mic-timer.visible {
  transform: translateX(50%) translateY(-2px);
}

/* Toast: position above the form (not above just the button) */
.chat-input-form .mic-toast {
  top: -38px;
  right: 0;
}

@media (max-width: 640px) {
  .mic-btn--chat {
    width: 34px;
    height: 34px;
    right: 48px;
  }
}
