/* Shared voice recorder and voice-message card for theme/chatgpt/claude modes. */

#character-chat-screen .az-voice-trigger {
    flex: 0 0 auto;
}

#character-chat-screen .az-voice-trigger svg {
    width: 21px;
    height: 21px;
}

#character-chat-screen .input-row .az-voice-trigger-hidden,
#character-chat-screen .az-voice-trigger-hidden {
    display: none !important;
}

#character-chat-screen.chat-ui-mode-claude .az-voice-base-trigger,
#character-chat-screen.chat-ui-mode-chatgpt .az-voice-base-trigger {
    display: none !important;
}

#character-chat-screen:not(.chat-ui-mode-claude):not(.chat-ui-mode-chatgpt) .az-voice-base-trigger {
    border: 1px solid rgba(var(--accent-rgb), 0.24) !important;
    background: var(--card-bg) !important;
    color: var(--accent) !important;
    box-shadow: 0 2px 7px rgba(0, 0, 0, 0.08) !important;
}

.az-voice-composer {
    display: none;
    padding: 11px 12px;
    border-bottom: 1px solid rgba(var(--accent-rgb), 0.12);
    background: var(--card-bg);
}

.az-voice-composer.is-recording,
.az-voice-composer.is-preview {
    display: block;
}

.az-voice-composer-active > .input-row {
    display: none !important;
}

.az-voice-recording-view,
.az-voice-preview-view {
    min-height: 46px;
    display: none;
    align-items: center;
    gap: 10px;
}

.az-voice-composer.is-recording .az-voice-recording-view,
.az-voice-composer.is-preview .az-voice-preview-view {
    display: flex;
}

.az-voice-recording-dot {
    width: 10px;
    height: 10px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #d94343;
    box-shadow: 0 0 0 5px rgba(217, 67, 67, 0.12);
    animation: az-voice-pulse 1.15s ease-in-out infinite;
}

.az-voice-live-wave,
.az-voice-preview-wave,
.az-voice-card-wave {
    flex: 1 1 auto;
    min-width: 70px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.az-voice-live-bar,
.az-voice-preview-bar,
.az-voice-card-bar {
    display: block;
    width: 3px;
    min-height: 3px;
    max-height: 100%;
    border-radius: 999px;
    background: currentColor;
    opacity: 0.35;
    transition: height 80ms linear, opacity 120ms ease;
}

.az-voice-live-bar {
    color: #d94343;
    opacity: 0.62;
}

.az-voice-preview-bar {
    color: var(--accent);
}

.az-voice-recording-time,
.az-voice-preview-time,
.az-voice-card-time {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-size: 0.78rem;
    opacity: 0.72;
}

.az-voice-preview-status {
    white-space: nowrap;
    color: var(--accent);
    font-size: 0.75rem;
}

#character-chat-screen .az-voice-composer button {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(var(--accent-rgb), 0.22) !important;
    background: rgba(var(--accent-rgb), 0.08) !important;
    color: var(--text) !important;
    box-shadow: none !important;
}

#character-chat-screen .az-voice-composer .az-voice-stop-record {
    color: #fff !important;
    background: #d94343 !important;
    border-color: #d94343 !important;
}

#character-chat-screen .az-voice-composer .az-voice-send-draft {
    color: var(--bg) !important;
    background: var(--accent) !important;
    border-color: var(--accent) !important;
}

#character-chat-screen .az-voice-composer button:disabled {
    opacity: 0.46 !important;
    cursor: wait !important;
}

.az-voice-card {
    min-width: min(300px, 66vw);
    max-width: 360px;
}

.az-voice-card > summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 38px;
    cursor: pointer;
    user-select: none;
}

.az-voice-card > summary::-webkit-details-marker {
    display: none;
}

#character-chat-screen .az-voice-card-play {
    width: 31px !important;
    height: 31px !important;
    min-width: 31px !important;
    flex: 0 0 auto;
    border: 1px solid currentColor !important;
    border-radius: 999px !important;
    background: rgba(255, 255, 255, 0.12) !important;
    color: inherit !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
}

.az-voice-card-wave {
    height: 28px;
    cursor: default;
}

.az-voice-card-bar {
    color: currentColor;
    opacity: 0.34;
}

.az-voice-card-bar.is-played {
    opacity: 0.9;
}

.az-voice-text-toggle {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid currentColor;
    border-radius: 999px;
    font-size: 0.68rem;
    opacity: 0.62;
}

.az-voice-card[open] .az-voice-text-toggle {
    opacity: 1;
    background: rgba(255, 255, 255, 0.12);
}

.az-voice-transcript {
    margin-top: 9px;
    padding-top: 9px;
    border-top: 1px solid currentColor;
    border-color: rgba(255, 255, 255, 0.22);
    font-size: 0.88em;
    line-height: 1.55;
}

.az-voice-transcript-state {
    opacity: 0.72;
}

.az-voice-truncated {
    margin-left: 4px;
    opacity: 0.65;
    font-size: 0.82em;
}

#character-chat-screen .az-voice-retry {
    width: auto !important;
    height: 30px !important;
    min-width: 0 !important;
    margin-top: 8px;
    padding: 0 12px !important;
    border: 1px solid currentColor !important;
    border-radius: 999px !important;
    color: inherit !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 0.75rem;
}

.az-voice-unavailable {
    opacity: 0.66;
    font-size: 0.82rem;
}

.chat-ui-mode-chatgpt .az-voice-composer,
.chat-ui-mode-claude .az-voice-composer {
    background: transparent;
    border-bottom-color: rgba(127, 127, 127, 0.16);
}

.chat-ui-mode-chatgpt .az-voice-card,
.chat-ui-mode-claude .az-voice-card {
    color: inherit;
}

@keyframes az-voice-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.82); opacity: 0.52; }
}

@media (max-width: 520px) {
    .az-voice-composer {
        padding: 9px 10px calc(9px + env(safe-area-inset-bottom));
    }

    .az-voice-recording-view,
    .az-voice-preview-view {
        gap: 7px;
    }

    .az-voice-live-wave,
    .az-voice-preview-wave {
        gap: 1.5px;
    }

    .az-voice-preview-status {
        position: absolute;
        left: 12px;
        bottom: 2px;
    }

    .az-voice-card {
        min-width: min(260px, 72vw);
    }
}

@media (prefers-reduced-motion: reduce) {
    .az-voice-recording-dot {
        animation: none;
    }

    .az-voice-live-bar,
    .az-voice-preview-bar,
    .az-voice-card-bar {
        transition: none;
    }
}
