/* ============================================
   AI Chatbot Widget - Complete Stylesheet
   ============================================ */

/* Widget Container */
#ai-chatbot-widget {
    position: fixed;
    bottom: 90px;
    right: 25px;
    z-index: 200000;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Toggle Button */
#chatbot-toggle {
    width: 65px;
    height: 65px;
    border: none;
    border-radius: 50%;
    position: relative;
    z-index: 9999;
    background: linear-gradient(135deg, var(--chat-primary, #6366f1), #ec4899) !important;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    animation: chatbotFloat 3.5s ease-in-out infinite,
        chatbotPulseWave 2.5s ease-out infinite !important;
}

#chatbot-toggle i {
    position: relative;
    z-index: 10;
    animation: micWobble 4s infinite;
}

/* 
 * Pulse-ring and pulse-wave-layer are inside a <button>.
 * Browsers clip transform:scale() children of <button> elements
 * even with overflow:visible. Hide them and use box-shadow instead.
 */
.pulse-ring,
.pulse-wave-layer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}

/* ============================================
   Keyframe Animations
   ============================================ */

/* Gentle floating bounce */
@keyframes chatbotFloat {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* 
 * Multi-ring expanding box-shadow pulse.
 * box-shadow is NEVER clipped by overflow:hidden on any ancestor.
 * 3 concentric rings: indigo → pink → teal
 */
@keyframes chatbotPulseWave {
    0% {
        box-shadow:
            0 8px 25px rgba(0, 0, 0, 0.25),
            0 0 0 0px rgba(99, 102, 241, 0.7),
            0 0 0 0px rgba(236, 72, 153, 0.5),
            0 0 0 0px rgba(20, 184, 166, 0.35);
    }

    70% {
        box-shadow:
            0 8px 25px rgba(0, 0, 0, 0.25),
            0 0 0 18px rgba(99, 102, 241, 0.15),
            0 0 0 32px rgba(236, 72, 153, 0.08),
            0 0 0 46px rgba(20, 184, 166, 0.02);
    }

    100% {
        box-shadow:
            0 8px 25px rgba(0, 0, 0, 0.25),
            0 0 0 22px rgba(99, 102, 241, 0),
            0 0 0 40px rgba(236, 72, 153, 0),
            0 0 0 55px rgba(20, 184, 166, 0);
    }
}

/* Microphone icon wobble */
@keyframes micWobble {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    10% {
        transform: scale(1.1) rotate(-10deg);
    }

    20% {
        transform: scale(1.1) rotate(10deg);
    }

    30% {
        transform: scale(1.1) rotate(-10deg);
    }

    40% {
        transform: scale(1) rotate(0deg);
    }
}

/* ============================================
   Hover State
   ============================================ */
#chatbot-toggle:hover {
    animation: pulse-wave 1s infinite linear alternate;
    transform: scale(1.15) translateY(-5px) !important;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(236, 72, 153, 0.5) !important;
}

/* ============================================
   Chatbot Open State
   ============================================ */
.ai-chatbot-open #chatbot-toggle {
    animation: none !important;
    background: #475569 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
}

.ai-chatbot-open #chatbot-toggle i {
    animation: none !important;
    transform: rotate(180deg);
}

/* ============================================
   Chat Window
   ============================================ */
#chatbot-window {
    position: absolute;
    bottom: 0px;
    right: 0;
    width: 380px;
    height: 480px;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    transform-origin: bottom right;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
}

.ai-chatbot-open #chatbot-window {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: auto;
}

/* ============================================
   Chat Elements
   ============================================ */
.chatbot-avatar {
    width: 40px;
    height: 40px;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: #22c55e;
    border-radius: 50%;
    display: inline-block;
}

#chatbot-messages {
    flex-grow: 1;
    background: #f8fafc;
}

.message-content {
    max-width: 85%;
    line-height: 1.5;
}

.ai-message .message-content {
    color: #1e293b;
    border-bottom-left-radius: 4px !important;
}

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

.user-message .message-content {
    color: white !important;
    border-bottom-right-radius: 4px !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ============================================
   Voice Wave Animation
   ============================================ */
.ai-wave-container {
    position: relative;
    width: 140px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clickable-avatar {
    cursor: pointer;
    transition: transform 0.2s;
}

.clickable-avatar:hover {
    transform: scale(1.05);
}

.clickable-avatar:hover .ai-avatar-circle {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.5);
}

.ai-wave {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    opacity: 0.3;
    display: none;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.4) 0%, rgba(14, 165, 233, 0.2) 70%, transparent 100%);
}

.ai-wave-container.active .ai-wave {
    display: block;
    animation: pulse-wave 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.wave-2 {
    animation-delay: 0.6s;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.3) 0%, rgba(16, 185, 129, 0.1) 70%, transparent 100%);
}

.wave-3 {
    animation-delay: 1.2s;
}

@keyframes pulse-wave {
    0% {
        transform: scale(0.6);
        opacity: 0.8;
    }

    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

.ai-avatar-circle {
    position: relative;
    width: 75px;
    height: 75px;
    background: linear-gradient(135deg, #10b981, #0ea5e9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 40px rgba(16, 185, 129, 0.4);
    z-index: 2;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   Utility Classes
   ============================================ */
.letter-spacing-1 {
    letter-spacing: 1px;
}

.uppercase {
    text-transform: uppercase;
}

/* ============================================
   Typing Indicator
   ============================================ */
.typing .message-content {
    padding: 10px 15px !important;
}

.dot-flashing {
    position: relative;
    width: 6px;
    height: 6px;
    border-radius: 5px;
    background-color: #94a3b8;
    color: #94a3b8;
    animation: dotFlashing 1s infinite linear alternate;
    animation-delay: .5s;
    display: inline-block;
    margin: 0 10px;
}

.dot-flashing::before,
.dot-flashing::after {
    content: '';
    display: inline-block;
    position: absolute;
    top: 0;
}

.dot-flashing::before {
    left: -12px;
    width: 6px;
    height: 6px;
    border-radius: 5px;
    background-color: #94a3b8;
    color: #94a3b8;
    animation: dotFlashing 1s infinite linear alternate;
    animation-delay: 0s;
}

.dot-flashing::after {
    left: 12px;
    width: 6px;
    height: 6px;
    border-radius: 5px;
    background-color: #94a3b8;
    color: #94a3b8;
    animation: dotFlashing 1s infinite linear alternate;
    animation-delay: 1s;
}

@keyframes dotFlashing {
    0% {
        background-color: #94a3b8;
    }

    50%,
    100% {
        background-color: #cbd5e1;
    }
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 500px) {
    #chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 120px);
        bottom: -60px;
        right: 0px;
    }
}