/* ==========================================================================
   ONC-ORG AI ONCOLOGY NAVIGATOR - CLEAN, MODERN CHAT WIDGET STYLING
   ========================================================================== */

:root {
    --ai-primary: #0284c7;
    --ai-primary-dark: #0369a1;
    --ai-navy: #0b2238;
    --ai-bg-light: #f8fafc;
    --ai-border: #e2e8f0;
    --ai-text-main: #0f172a;
    --ai-text-muted: #64748b;
    --ai-user-bubble: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    --ai-bot-bubble: #ffffff;
}

/* Floating Launcher Trigger */
.ai-chat-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    background: linear-gradient(135deg, #0b2238 0%, #0369a1 60%, #0284c7 100%);
    color: #ffffff;
    padding: 10px 18px 10px 14px;
    border-radius: 50px;
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.35);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255, 255, 255, 0.3);
    user-select: none;
}

.ai-chat-launcher:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(2, 132, 199, 0.45);
    border-color: #ffffff;
}

.ai-launcher-icon-wrap {
    position: relative;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.ai-launcher-pulse {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    animation: aiPulse 2s infinite;
}

@keyframes aiPulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.ai-launcher-text {
    display: flex;
    flex-direction: column;
}

.ai-launcher-title {
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
}

.ai-launcher-sub {
    font-size: 10px;
    color: #bae6fd;
    line-height: 1;
}

/* Chat Drawer Container */
.ai-chat-drawer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 420px;
    height: 620px;
    max-height: calc(100vh - 40px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(11, 34, 56, 0.25), 0 0 0 1px rgba(226, 232, 240, 0.8);
    display: flex;
    flex-direction: column;
    z-index: 100000;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ai-chat-drawer.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat Header */
.ai-chat-header {
    background: linear-gradient(135deg, #0b2238 0%, #0369a1 100%);
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.18);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.ai-header-text h4 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-status-indicator {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #10b981;
    border-radius: 50%;
}

.ai-header-text span {
    font-size: 10.5px;
    color: #bae6fd;
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-btn-icon {
    background: rgba(255, 255, 255, 0.12);
    border: none;
    color: #ffffff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
}

.ai-btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
}

.ai-btn-icon.active-voice {
    background: #10b981 !important;
}

/* Chat Messages Area */
.ai-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Message Bubbles */
.ai-message {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: messageSlide 0.25s ease-out;
}

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

.ai-message.user {
    align-self: flex-end;
}

.ai-message.bot {
    align-self: flex-start;
}

.ai-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.45;
    word-break: break-word;
}

.ai-message.user .ai-bubble {
    background: var(--ai-user-bubble);
    color: #ffffff;
    border-bottom-right-radius: 2px;
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.2);
}

.ai-message.bot .ai-bubble {
    background: #ffffff;
    color: var(--ai-text-main);
    border: 1px solid var(--ai-border);
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.ai-bubble p {
    margin: 0 0 6px 0;
}
.ai-bubble p:last-child {
    margin: 0;
}

.ai-bubble ul, .ai-bubble ol {
    margin: 4px 0;
    padding-left: 18px;
}

.ai-bubble a {
    color: #0284c7;
    text-decoration: underline;
    font-weight: 600;
}

.ai-message.user .ai-bubble a {
    color: #ffffff;
}

.ai-meta {
    font-size: 10px;
    color: var(--ai-text-muted);
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-message.user .ai-meta {
    justify-content: flex-end;
}

.ai-speak-btn {
    background: none;
    border: none;
    color: #0284c7;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.2s;
}

.ai-speak-btn:hover {
    background: #e0f2fe;
    color: #0369a1;
}

/* Typing Indicator */
.ai-typing-indicator {
    display: none;
    align-self: flex-start;
    background: #ffffff;
    border: 1px solid var(--ai-border);
    padding: 10px 14px;
    border-radius: 14px;
    border-bottom-left-radius: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

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

.ai-typing-dot {
    width: 6px;
    height: 6px;
    background: #0284c7;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}
.ai-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.ai-typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Bottom Status */
.ai-live-bottom-status {
    background: #0b2238;
    color: #81c995;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid #1e293b;
}

.ai-live-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background: #81c995;
    border-radius: 50%;
    margin-right: 5px;
    animation: liveDotPulse 1.5s infinite;
}

@keyframes liveDotPulse {
    0%, 100% { transform: scale(0.9); opacity: 0.7; }
    50% { transform: scale(1.3); opacity: 1; }
}

/* Suggestions Bar */
.ai-suggestions-bar {
    padding: 8px 12px;
    background: #ffffff;
    border-top: 1px solid var(--ai-border);
    display: flex;
    gap: 6px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}

.ai-suggestions-bar::-webkit-scrollbar {
    display: none;
}

.ai-pill-btn {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0369a1;
    font-size: 11px;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-pill-btn:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

/* Chat Input Footer */
.ai-chat-footer {
    padding: 10px 12px;
    background: #ffffff;
    border-top: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.ai-input-wrap {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.ai-input-field {
    width: 100%;
    border: 1px solid var(--ai-border);
    border-radius: 24px;
    padding: 9px 38px 9px 14px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
}

.ai-input-field:focus {
    border-color: #0284c7;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.ai-mic-btn {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--ai-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.ai-mic-btn:hover {
    color: #0284c7;
    background: #e0f2fe;
}

.ai-mic-btn.recording {
    color: #ffffff;
    background: #ef4444;
    animation: micPulse 1.2s infinite;
}

@keyframes micPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

.ai-send-btn {
    background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    border: none;
    color: #ffffff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);
    transition: transform 0.2s;
    flex-shrink: 0;
}

.ai-send-btn:hover {
    transform: scale(1.06);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-chat-drawer {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .ai-chat-launcher {
        bottom: 16px;
        right: 16px;
        padding: 8px 14px 8px 10px;
    }
}

/* ==========================================================================
   LIVE VOICE CHAT — Go Live Button + Overlay + Waveform
   ========================================================================== */

/* Go Live / End Live Buttons */
.ai-go-live-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 16px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    animation: ai-live-glow 2s ease-in-out infinite;
}
.ai-go-live-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.5);
}
.ai-end-live-btn {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%) !important;
    color: #fff !important;
    border: none !important;
    border-radius: 16px !important;
    padding: 4px 10px !important;
    font-size: 11px !important;
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
}
.ai-live-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

@keyframes ai-live-glow {
    0%, 100% { box-shadow: 0 0 4px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 0 16px rgba(239, 68, 68, 0.6); }
}

/* Live Voice Overlay */
.ai-live-voice-overlay {
    position: absolute;
    inset: 48px 0 0 0;
    background: linear-gradient(170deg, #0b1a2e 0%, #0f2847 40%, #132e4f 100%);
    z-index: 100;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 0 0 16px 16px;
    overflow: hidden;
}
.ai-live-voice-overlay.active {
    display: flex;
}

.ai-live-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 30px 20px;
    width: 100%;
}

.ai-live-model-badge {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    text-transform: uppercase;
    font-weight: 600;
}

/* Waveform Bars */
.ai-live-waveform {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 80px;
}

.ai-wave-bar {
    width: 6px;
    border-radius: 100px;
    background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
    transition: height 0.15s ease;
}

/* Idle state */
.ai-live-waveform.idle .ai-wave-bar {
    height: 8px;
    opacity: 0.4;
}

/* Connecting state */
.ai-live-waveform.connecting .ai-wave-bar {
    height: 14px;
    animation: ai-wave-connect 1.2s ease-in-out infinite;
    opacity: 0.7;
}
.ai-live-waveform.connecting .ai-wave-bar:nth-child(1) { animation-delay: 0s; }
.ai-live-waveform.connecting .ai-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.ai-live-waveform.connecting .ai-wave-bar:nth-child(3) { animation-delay: 0.2s; }
.ai-live-waveform.connecting .ai-wave-bar:nth-child(4) { animation-delay: 0.3s; }
.ai-live-waveform.connecting .ai-wave-bar:nth-child(5) { animation-delay: 0.4s; }
.ai-live-waveform.connecting .ai-wave-bar:nth-child(6) { animation-delay: 0.5s; }
.ai-live-waveform.connecting .ai-wave-bar:nth-child(7) { animation-delay: 0.6s; }

@keyframes ai-wave-connect {
    0%, 100% { height: 10px; }
    50% { height: 28px; }
}

/* Listening state (mic active, waiting for user speech) */
.ai-live-waveform.listening .ai-wave-bar {
    animation: ai-wave-listen 0.8s ease-in-out infinite;
    opacity: 1;
}
.ai-live-waveform.listening .ai-wave-bar:nth-child(1) { animation-delay: 0.0s; }
.ai-live-waveform.listening .ai-wave-bar:nth-child(2) { animation-delay: 0.1s; }
.ai-live-waveform.listening .ai-wave-bar:nth-child(3) { animation-delay: 0.15s; }
.ai-live-waveform.listening .ai-wave-bar:nth-child(4) { animation-delay: 0.2s; }
.ai-live-waveform.listening .ai-wave-bar:nth-child(5) { animation-delay: 0.25s; }
.ai-live-waveform.listening .ai-wave-bar:nth-child(6) { animation-delay: 0.3s; }
.ai-live-waveform.listening .ai-wave-bar:nth-child(7) { animation-delay: 0.35s; }

@keyframes ai-wave-listen {
    0%, 100% { height: 12px; }
    50% { height: 36px; }
}

/* Speaking state (AI responding with voice) */
.ai-live-waveform.speaking .ai-wave-bar {
    background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
    animation: ai-wave-speak 0.4s ease-in-out infinite;
    opacity: 1;
}
.ai-live-waveform.speaking .ai-wave-bar:nth-child(1) { animation-delay: 0.0s; height: 40px; }
.ai-live-waveform.speaking .ai-wave-bar:nth-child(2) { animation-delay: 0.05s; height: 56px; }
.ai-live-waveform.speaking .ai-wave-bar:nth-child(3) { animation-delay: 0.1s; height: 72px; }
.ai-live-waveform.speaking .ai-wave-bar:nth-child(4) { animation-delay: 0.15s; height: 60px; }
.ai-live-waveform.speaking .ai-wave-bar:nth-child(5) { animation-delay: 0.2s; height: 48px; }
.ai-live-waveform.speaking .ai-wave-bar:nth-child(6) { animation-delay: 0.25s; height: 36px; }
.ai-live-waveform.speaking .ai-wave-bar:nth-child(7) { animation-delay: 0.3s; height: 24px; }

@keyframes ai-wave-speak {
    0%, 100% { transform: scaleY(0.7); }
    50% { transform: scaleY(1.3); }
}

/* Status Label */
.ai-live-status-label {
    color: #94a3b8;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-align: center;
}

/* Transcript Display */
.ai-live-transcript {
    color: rgba(255, 255, 255, 0.75);
    font-size: 13px;
    text-align: center;
    max-height: 120px;
    overflow-y: auto;
    padding: 8px 16px;
    line-height: 1.5;
    width: 100%;
}
