/* AI Chat Widget Styles */
#ai-chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* Floating Toggle Button */
.ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    color: white;
    font-size: 1.75rem;
}

.ai-chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.5);
}

.ai-chat-toggle:active {
    transform: scale(0.95);
}

/* Chat Window */
.ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 550px;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.ai-chat-window.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.ai-chat-header {
    padding: 1rem 1.25rem;
    background: rgba(15, 23, 42, 0.6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-chat-logo {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.ai-chat-info h3 {
    margin: 0;
    font-size: 1rem;
    color: white;
    font-weight: 600;
}

.ai-chat-info p {
    margin: 0;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

.ai-chat-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s;
}

.ai-chat-close:hover {
    color: white;
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    padding: 1.25rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.ai-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.5;
}

.ai-message.bot {
    align-self: flex-start;
    background: rgba(51, 65, 85, 0.6);
    color: rgba(255, 255, 255, 0.9);
    border-bottom-left-radius: 4px;
}

.ai-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-typing-indicator {
    padding: 0.5rem 1rem;
    background: rgba(51, 65, 85, 0.6);
    border-radius: 12px;
    align-self: flex-start;
    display: none;
}

.ai-typing-indicator span {
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}

.ai-typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Input Area */
.ai-chat-input-area {
    padding: 1rem;
    background: rgba(15, 23, 42, 0.4);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.5rem;
}

#ai-chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 0.75rem 1rem;
    color: white;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

#ai-chat-input:focus {
    border-color: #6366f1;
}

.ai-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #6366f1;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-send:hover {
    background: #4f46e5;
}

.ai-chat-send:disabled {
    background: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
}

/* Microphone Button */
.ai-chat-mic {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.ai-chat-mic:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.ai-chat-mic.listening {
    background: #ef4444;
    /* Red color when listening */
    color: white;
    animation: mic-pulse 1.5s infinite;
}

@keyframes mic-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

/* Mobile Responsive */
/* Mobile Responsive */
/* Mobile Responsive */
@media (max-width: 480px) {
    .ai-chat-window {
        position: fixed !important;
        width: 100vw !important;
        height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        border-radius: 0 !important;
        background: #0f172a !important;
        z-index: 2147483647 !important;
        /* Max z-index to be safe */
        display: flex !important;
        flex-direction: column !important;
    }

    .ai-chat-window.open {
        transform: translateY(0) !important;
        opacity: 1 !important;
        pointer-events: all !important;
    }

    /* Hide toggle button when chat is open on mobile */
    body.chat-open .ai-chat-toggle {
        display: none !important;
    }

    .ai-chat-header {
        padding: 1rem;
        padding-top: env(safe-area-inset-top, 1rem);
        /* Safe area support */
        padding-top: max(1rem, env(safe-area-inset-top));
        /* Better syntax support */
    }

    .ai-chat-messages {
        padding-bottom: 80px;
        /* Space for input area */
    }

    .ai-chat-input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        padding-bottom: env(safe-area-inset-bottom, 1rem);
        /* Safe area support */
        background: #0f172a;
        z-index: 2147483647 !important;
    }
}