/* =====================================================
   AI Voice Assistant — Conversation UI Styles
   ===================================================== */

/* Conversation Panel */
.conversation-panel {
    display: none;
    flex-direction: column;
    height: 500px;
    border: 1px solid var(--border-color, #333);
    border-radius: 12px;
    background: var(--card-bg, #1a1a2e);
    overflow: hidden;
    margin-top: 1rem;
}

.conversation-panel.active {
    display: flex;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    scroll-behavior: smooth;
}

/* Chat Bubbles */
.chat-bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.5;
    animation: bubbleIn 0.3s ease-out;
    word-wrap: break-word;
}

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

/* Assistant bubble — left aligned */
.chat-bubble.assistant {
    align-self: flex-start;
    background: var(--accent-color, #4a9eff);
    color: #fff;
    border-bottom-left-radius: 4px;
}

/* User bubble — right aligned */
.chat-bubble.user {
    align-self: flex-end;
    background: var(--surface-color, #2a2a3e);
    color: var(--text-color, #e0e0e0);
    border-bottom-right-radius: 4px;
}

/* Emergency bubble */
.chat-bubble.emergency {
    background: #dc3545;
    color: #fff;
    border: 2px solid #ff4757;
}

/* RAG-grounded badge */
.chat-bubble .rag-badge {
    display: inline-block;
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.15rem 0.4rem;
    border-radius: 8px;
    margin-top: 0.4rem;
}

/* Typing indicator */
.typing-indicator {
    align-self: flex-start;
    padding: 0.75rem 1rem;
    display: none;
}

.typing-indicator.active {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-indicator .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-color, #4a9eff);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Conversation Controls */
.conversation-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #333);
    background: var(--surface-color, #2a2a3e);
}

.conversation-controls .conv-mic-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--accent-color, #4a9eff);
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.conversation-controls .conv-mic-btn:hover {
    transform: scale(1.05);
    filter: brightness(1.1);
}

.conversation-controls .conv-mic-btn.recording {
    background: #dc3545;
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(220, 53, 69, 0);
    }
}

.conversation-controls .conv-text-input {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 24px;
    border: 1px solid var(--border-color, #333);
    background: var(--card-bg, #1a1a2e);
    color: var(--text-color, #e0e0e0);
    font-size: 0.9rem;
    outline: none;
}

.conversation-controls .conv-text-input:focus {
    border-color: var(--accent-color, #4a9eff);
}

.conversation-controls .conv-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent-color, #4a9eff);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Status Bar */
.conversation-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    font-size: 0.8rem;
    color: var(--text-muted, #888);
    border-top: 1px solid var(--border-color, #333);
}

.conversation-status .status-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.conversation-status .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #28a745;
}

.conversation-status .status-dot.speaking {
    background: var(--accent-color, #4a9eff);
    animation: speakingPulse 0.8s infinite alternate;
}

.conversation-status .status-dot.listening {
    background: #28a745;
    animation: speakingPulse 1s infinite alternate;
}

@keyframes speakingPulse {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

/* Voice Activity Indicator */
.voice-activity-ring {
    display: none;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px solid var(--accent-color, #4a9eff);
    animation: voiceRing 1.5s infinite;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.voice-activity-ring.active {
    display: block;
}

@keyframes voiceRing {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1.5);
        opacity: 0;
    }
}

/* Conversation Mode Toggle */
.conversation-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color, #333);
    background: var(--surface-color, #2a2a3e);
    color: var(--text-color, #e0e0e0);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.conversation-toggle:hover {
    border-color: var(--accent-color, #4a9eff);
}

.conversation-toggle.active {
    background: var(--accent-color, #4a9eff);
    color: #fff;
    border-color: var(--accent-color, #4a9eff);
}

/* Mode Selector */
.conversation-mode-select {
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    border: 1px solid var(--border-color, #333);
    background: var(--card-bg, #1a1a2e);
    color: var(--text-color, #e0e0e0);
    font-size: 0.85rem;
}

/* Entities sidebar in conversation */
.conversation-entities {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color, #333);
    max-height: 120px;
    overflow-y: auto;
    font-size: 0.8rem;
}

.conversation-entities .entity-tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    margin: 0.15rem;
    border-radius: 12px;
    font-size: 0.75rem;
}

.conversation-entities .entity-tag.condition {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

.conversation-entities .entity-tag.medication {
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
}
