/* RC Power Portal — Voice input (microphone button) styles.
 * The wrapper is positioned so the mic button overlays the right edge of the
 * field without changing the field's own box, keeping existing layouts intact.
 */

.voice-input-wrapper {
    position: relative;
    display: inline-block;
}
.voice-input-wrapper.vw-block {
    display: block;
    width: 100%;
}

/* Reserve space on the right so typed text never sits under the button. */
.has-voice-btn {
    padding-right: 38px !important;
}

.voice-input-btn {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    line-height: 1;
    color: #6c757d;
    opacity: 0.75;
    transition: opacity 0.15s ease, background 0.15s ease;
    z-index: 3;
}
.voice-input-btn:hover { opacity: 1; background: rgba(0, 0, 0, 0.06); }
.voice-input-btn:focus-visible { outline: 2px solid var(--accent-color, #f39c12); outline-offset: 1px; }

/* For textareas, pin the button to the top-right corner instead of centering. */
.voice-input-wrapper.vw-textarea .voice-input-btn {
    top: 6px;
    transform: none;
}

.voice-input-btn .vi-spinner { display: none; }

/* Recording state — red, pulsing. */
.voice-input-btn.vi-recording {
    color: #fff;
    background: #dc3545;
    opacity: 1;
    animation: vi-pulse 1.2s ease-in-out infinite;
}
@keyframes vi-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.55); }
    70%  { box-shadow: 0 0 0 8px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

/* Transcribing state — spinner replaces the icon. */
.voice-input-btn.vi-transcribing .vi-icon { display: none; }
.voice-input-btn.vi-transcribing .vi-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(108, 117, 125, 0.35);
    border-top-color: var(--accent-color, #f39c12);
    border-radius: 50%;
    animation: vi-spin 0.7s linear infinite;
}
@keyframes vi-spin { to { transform: rotate(360deg); } }

/* Error state — red mic. */
.voice-input-btn.vi-error { color: #dc3545; opacity: 1; }

/* Floating recording banner (top of screen). */
.voice-rec-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 11000;
    display: none;
    text-align: center;
    background: #dc3545;
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 10px 14px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}
.voice-rec-banner.show { display: block; }

/* One-time permission / info toast. */
.voice-toast {
    position: fixed;
    left: 50%;
    bottom: 96px;
    transform: translateX(-50%) translateY(12px);
    z-index: 11000;
    max-width: 92vw;
    width: 360px;
    background: #1F3864;
    color: #fff;
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 0.88rem;
    line-height: 1.35;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.voice-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Persistent transcription progress indicator (spinner + escalating text). */
.voice-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}
.voice-progress-spinner {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: voiceProgressSpin 0.7s linear infinite;
}
@keyframes voiceProgressSpin { to { transform: rotate(360deg); } }

/* Mobile: larger touch targets. */
@media (max-width: 768px) {
    .voice-input-btn {
        width: 44px;
        height: 44px;
        right: 2px;
        font-size: 18px;
    }
    .has-voice-btn { padding-right: 50px !important; }
    .voice-input-wrapper.vw-textarea .voice-input-btn { top: 4px; }
    .voice-input-btn.vi-transcribing .vi-spinner { width: 18px; height: 18px; }
}
