/* ══════════════════════════════════════════════════════════════════════════
   VOICE TAB STYLES — v2 with auto-routing
   ══════════════════════════════════════════════════════════════════════════ */

/* Layout */
.voice-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    gap: 0;
}

/* Agent selector bar */
.voice-agent-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-darker, #0a0f1a);
    border-bottom: 1px solid var(--border, #1e2a3a);
    overflow-x: auto;
    flex-shrink: 0;
}

.voice-agent-bar.auto-route-active .voice-agent-chip {
    opacity: 0.4;
}

.voice-agent-bar.auto-route-active .voice-agent-chip.routed {
    opacity: 1;
    border-color: #10b981;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.voice-agent-bar::-webkit-scrollbar { height: 3px; }
.voice-agent-bar::-webkit-scrollbar-thumb { background: var(--border, #1e2a3a); border-radius: 3px; }

.voice-agent-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border, #1e2a3a);
    background: transparent;
    color: var(--text-muted, #8892a4);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
}

.voice-agent-chip:hover {
    border-color: var(--primary, #3b82f6);
    color: var(--text, #e2e8f0);
}

.voice-agent-chip.active {
    background: var(--primary, #3b82f6);
    border-color: var(--primary, #3b82f6);
    color: #fff;
}

.voice-agent-chip.routed {
    border-color: #10b981;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.voice-agent-icon { font-size: 15px; }

/* Auto-route button */
.voice-autoroute-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #10b981;
    background: transparent;
    color: #10b981;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.3s;
}

.voice-autoroute-btn:hover {
    background: rgba(16, 185, 129, 0.1);
}

.voice-autoroute-btn.active {
    background: #10b981;
    color: #fff;
}

/* Conversation area */
.voice-conversation {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voice-conversation::-webkit-scrollbar { width: 6px; }
.voice-conversation::-webkit-scrollbar-thumb { background: var(--border, #1e2a3a); border-radius: 3px; }

/* Bubbles */
.voice-bubble {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    animation: voiceFadeIn 0.3s ease;
}

@keyframes voiceFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.voice-user {
    align-self: flex-end;
    background: var(--primary, #3b82f6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.voice-assistant {
    align-self: flex-start;
    background: var(--bg-card, #111827);
    color: var(--text, #e2e8f0);
    border: 1px solid var(--border, #1e2a3a);
    border-bottom-left-radius: 4px;
}

.voice-error {
    align-self: center;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 13px;
}

.voice-bubble-header {
    font-size: 11px;
    font-weight: 600;
    opacity: 0.7;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.voice-user .voice-bubble-header { text-align: right; justify-content: flex-end; }

.voice-bubble-text {
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.voice-bubble-text.md-content h1,
.voice-bubble-text.md-content h2,
.voice-bubble-text.md-content h3 { margin-top: 8px; }
.voice-bubble-text.md-content p { margin: 4px 0; }
.voice-bubble-text.md-content ul,
.voice-bubble-text.md-content ol { margin: 4px 0; padding-left: 20px; }
.voice-bubble-text.md-content table { font-size: 12px; margin: 6px 0; }
.voice-bubble-text.md-content pre { font-size: 12px; margin: 6px 0; }

/* Thinking dots */
.voice-thinking {
    align-self: flex-start;
    background: var(--bg-card, #111827);
    border: 1px solid var(--border, #1e2a3a);
    border-bottom-left-radius: 4px;
}

.voice-thinking-dots {
    display: flex;
    gap: 5px;
    padding: 4px 0;
}

.voice-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted, #8892a4);
    animation: voiceDotPulse 1.4s ease-in-out infinite;
}

.voice-dot:nth-child(2) { animation-delay: 0.2s; }
.voice-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes voiceDotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ── Control bar (bottom) ─────────────────────────────────────────────── */

.voice-control-bar {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 16px 16px;
    background: var(--bg-darker, #0a0f1a);
    border-top: 1px solid var(--border, #1e2a3a);
    gap: 10px;
}

/* Transcript display */
.voice-transcript-area {
    width: 100%;
    max-width: 700px;
    min-height: 40px;
    max-height: 100px;
    overflow-y: auto;
    padding: 10px 14px;
    background: var(--bg-card, #111827);
    border: 1px solid var(--border, #1e2a3a);
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text, #e2e8f0);
}

.voice-placeholder {
    color: var(--text-muted, #8892a4);
    font-style: italic;
}

.voice-final { color: var(--text, #e2e8f0); }

.voice-interim {
    color: var(--text-muted, #8892a4);
    font-style: italic;
}

/* Button row */
.voice-btn-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Microphone button */
.voice-mic-btn {
    position: relative;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 3px solid var(--primary, #3b82f6);
    background: transparent;
    color: var(--primary, #3b82f6);
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

.voice-mic-btn:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.05);
}

.voice-mic-btn.active {
    background: var(--primary, #3b82f6);
    color: #fff;
    border-color: var(--primary, #3b82f6);
    animation: voiceMicPulse 2s ease-in-out infinite;
}

@keyframes voiceMicPulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.5); }
    70% { box-shadow: 0 0 0 20px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

/* Pulse ring behind mic */
.voice-mic-ring {
    position: absolute;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: 2px solid var(--primary, #3b82f6);
    opacity: 0;
    pointer-events: none;
}

.voice-mic-ring.active {
    animation: voiceRingExpand 1.5s ease-out infinite;
}

@keyframes voiceRingExpand {
    0% { transform: scale(1); opacity: 0.6; }
    100% { transform: scale(2); opacity: 0; }
}

/* Secondary buttons */
.voice-action-btn {
    padding: 10px 20px;
    border-radius: 24px;
    border: 1px solid var(--border, #1e2a3a);
    background: var(--bg-card, #111827);
    color: var(--text, #e2e8f0);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.voice-action-btn:hover {
    border-color: var(--primary, #3b82f6);
    background: rgba(59, 130, 246, 0.08);
}

.voice-action-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.voice-action-btn.send {
    background: var(--primary, #3b82f6);
    border-color: var(--primary, #3b82f6);
    color: #fff;
}

.voice-action-btn.send:hover {
    background: #2563eb;
}

.voice-action-btn.stop-tts {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
    display: none;
}

/* Status + settings row */
.voice-footer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 700px;
}

.voice-status {
    font-size: 12px;
    color: var(--text-muted, #8892a4);
}

.voice-settings {
    display: flex;
    align-items: center;
    gap: 14px;
}

.voice-setting {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-muted, #8892a4);
}

.voice-setting input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary, #3b82f6);
    cursor: pointer;
}

/* Agent name display */
.voice-speaking-to {
    font-size: 12px;
    color: var(--text-muted, #8892a4);
    text-align: center;
}

.voice-speaking-to strong {
    color: var(--primary, #3b82f6);
}

.voice-speaking-to em {
    color: #10b981;
}

/* ── Responsive ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .voice-mic-btn {
        width: 64px;
        height: 64px;
        font-size: 24px;
    }
    .voice-mic-ring { width: 64px; height: 64px; }
    .voice-bubble { max-width: 92%; }
    .voice-agent-bar { padding: 8px 10px; }
    .voice-agent-chip { padding: 5px 10px; font-size: 12px; }
    .voice-transcript-area { min-height: 36px; font-size: 13px; }
}
