/**
 * Speech-to-Text Styles
 *
 * Styling for the microphone button and recording states.
 * Uses the existing --ai-chat-primary-color(-light) variables and
 * .campour-ai-chat-* class conventions from assets/css/chatbot.css so it
 * visually matches the rest of the chat widget.
 *
 * @package Campour_AI_Core
 * @since 1.0.0
 */

/* Mic button - positioned before send button */
.campour-ai-chat-mic-btn {
    position: absolute !important;
    right: 62px;
    top: 50%;
    transform: translateY(-50%);
    width: 34px !important;
    height: 34px !important;
    min-width: 34px !important;
    padding: 0 !important;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #929292;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

/* Hidden elements by default */
.mic-recording-ui {
    display: none;
}

.campour-ai-chat-mic-btn:hover {
    background: var(--ai-chat-primary-color-light, #dfdfdf);
    color: var(--ai-chat-primary-color, #666);
}

.campour-ai-chat-mic-btn:focus {
    outline: none;
    box-shadow: none;
}

.campour-ai-chat-mic-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Recording state */
.campour-ai-chat-mic-btn.recording {
    width: auto !important;
    min-width: 80px !important;
    padding: 0 10px !important;
    border-radius: 16px;
    background: #ffe5e7;
    border: none;
    color: #333;
}

.campour-ai-chat-mic-btn.recording:hover {
    background: #ffe0e3
}

.campour-ai-chat-mic-btn.recording .mic-icon {
    display: none !important;
}

.campour-ai-chat-mic-btn.recording .mic-recording-ui {
    display: flex !important;
    align-items: center;
    gap: 6px;
}

/* Recording dot with pulse animation */
.mic-recording-dot {
    width: 8px;
    height: 8px;
    background: #dc3545;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.mic-recording-dot::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: rgba(220, 53, 69, 0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: mic-pulse-expand 1.2s ease-out infinite;
}

@keyframes mic-pulse-expand {
    0% {
        width: 8px;
        height: 8px;
        opacity: 0.6;
    }
    100% {
        width: 24px;
        height: 24px;
        opacity: 0;
    }
}

/* Recording timer */
.mic-recording-timer {
    font-size: 13px;
    font-weight: 500;
    color: #dc3545;
    font-variant-numeric: tabular-nums;
    min-width: 28px;
}

/* Stop button */
.mic-recording-ui .stop-icon {
    width: 14px;
    height: 14px;
    color: #dc3545;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s ease;
    margin-left: -3px;
}

.mic-recording-ui .stop-icon:hover {
    color: #dc3545;
}

/* Transcribing state */
.campour-ai-chat-mic-btn.transcribing {
    background: #fff;
    color: #666;
    cursor: wait;
    pointer-events: none;
}

.campour-ai-chat-mic-btn.transcribing .mic-icon {
    display: none;
}

.campour-ai-chat-mic-btn.transcribing .mic-transcribing-loader {
    display: inline-block !important;
    position: relative;
    width: 14px;
    height: 14px;
    box-sizing: border-box;
    background: conic-gradient(
        from 90deg at 50% 50%,
        rgba(160, 160, 160, 0) 0deg,
        rgba(160, 160, 160, 0) 0.04deg,
        #707070 360deg
    );
    border-radius: 50%;
    animation: micSpinner 0.7s infinite linear;
}

.mic-transcribing-loader::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
}

@keyframes micSpinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* Adjust textarea padding to make room for mic button */
.campour-ai-chat-input-wrapper .campour-ai-chat-input {
    padding-right: 96px !important;
}

/* Disabled state */
.campour-ai-chat-mic-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Speech indicator icon on user messages sent via voice */
.campour-ai-chat-message-user.from-speech {
    position: relative;
}

.campour-ai-speech-indicator {
    position: absolute;
    bottom: 4px;
    right: 8px;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1;
    opacity: 0.8;
}

.campour-ai-speech-indicator svg {
    display: block;
}

/* Adjust for messages with padding */
.campour-ai-chat-message-user.from-speech .campour-ai-chat-message-content {
    padding-bottom: 18px;
}

/* ==========================================================================
   Dark mode
   ========================================================================== */

.campour-ai-chat-wrapper.dark-mode .campour-ai-chat-mic-btn {
    color: #bbb;
}

.campour-ai-chat-wrapper.dark-mode .campour-ai-chat-mic-btn:hover {
    background: var(--ai-chat-primary-color-light, rgba(255, 255, 255, 0.08));
    color: var(--ai-chat-primary-color, #fff);
}

.campour-ai-chat-wrapper.dark-mode .campour-ai-chat-mic-btn.transcribing {
    background: #333;
    color: #ccc;
}
