/* ============================================================
   FESTLIFT AI CHAT WIDGET
   Premium dark-themed chat assistant
   ============================================================ */

:root {
    --ai-accent: #00e5ff;
    --ai-accent-glow: rgba(0, 229, 255, 0.4);
    --ai-dark: #0a0a12;
    --ai-surface: rgba(15, 18, 35, 0.85); /* Slightly more transparent */
    --ai-surface-2: rgba(30, 35, 65, 0.8);
    --ai-border: rgba(0, 229, 255, 0.25);
    --ai-text: #ffffff;
    --ai-text-secondary: #b0b8d0;
    --ai-primary: #0a2c5e;
    --ai-radius: 24px;
    --ai-transition: all 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

/* ============ TOGGLE BUTTON ============ */
#festlift-ai-toggle {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9998;
    width: 66px;
    height: 66px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a2c5e, #051632);
    border: 2px solid var(--ai-accent);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 0 var(--ai-accent-glow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ai-transition);
    animation: ai-pulse 3s infinite;
}

#festlift-ai-toggle:hover {
    transform: scale(1.1) rotate(5deg);
    box-shadow: 0 12px 40px rgba(0,0,0,0.6), 0 0 20px var(--ai-accent-glow);
}

#festlift-ai-toggle svg {
    width: 30px;
    height: 30px;
    transition: var(--ai-transition);
}

#festlift-ai-toggle.open {
    transform: rotate(90deg) scale(0.9);
    background: #1a1a2e;
}

#festlift-ai-toggle.open svg.icon-chat { display: none; }
#festlift-ai-toggle.open svg.icon-close { display: block !important; }
#festlift-ai-toggle svg.icon-close { display: none; }

#festlift-ai-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    background: #ff3b30;
    border-radius: 50%;
    border: 2px solid var(--ai-dark);
    font-size: 10px;
    color: white;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    box-shadow: 0 2px 8px rgba(255, 59, 48, 0.4);
}

@keyframes ai-pulse {
    0% { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 0 var(--ai-accent-glow); }
    70% { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 15px rgba(0, 229, 255, 0); }
    100% { box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 0 rgba(0, 229, 255, 0); }
}

/* ============ CHAT WINDOW ============ */
#festlift-ai-window {
    position: fixed;
    bottom: 110px;
    right: 32px;
    width: 390px;
    height: 620px;
    max-height: calc(100vh - 150px);
    z-index: 9999;
    background: var(--ai-surface);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.6), 0 0 40px rgba(0, 229, 255, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(30px) scale(0.9);
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    backdrop-filter: blur(25px) saturate(180%);
}

#festlift-ai-window.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ============ HEADER (WhatsApp Style) ============ */
#ai-header {
    background: linear-gradient(135deg, #0a2c5e, #051632);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.9rem;
    border-bottom: 1px solid rgba(0, 229, 255, 0.15);
    flex-shrink: 0;
    position: relative;
}

#ai-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--ai-accent), transparent);
    opacity: 0.3;
}

#ai-header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--ai-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
}

#ai-header-avatar svg {
    width: 26px;
    height: 26px;
    color: var(--ai-accent);
}

#ai-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4ade80;
    border-radius: 50%;
    border: 2px solid #051632;
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.5);
}

#ai-header-info {
    flex: 1;
}

#ai-header-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.05rem;
    color: white;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

#ai-header-name::after {
    content: '✓';
    background: var(--ai-accent);
    color: #051632;
    font-size: 0.6rem;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
}

#ai-header-status {
    font-size: 0.78rem;
    color: #4ade80;
    opacity: 0.9;
    margin-top: 2px;
}

#ai-header-close {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: var(--ai-text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ai-transition);
}

#ai-header-close:hover {
    background: rgba(255, 59, 48, 0.15);
    color: white;
    border-color: rgba(255, 59, 48, 0.3);
}

/* ============ MESSAGES ============ */
#ai-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    min-height: 0;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    background-image: radial-gradient(rgba(0, 229, 255, 0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}

#ai-messages::-webkit-scrollbar {
    width: 12px;
}

#ai-messages::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.06);
    border-radius: 10px;
    margin: 4px 0;
}

#ai-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 229, 255, 0.5);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
    min-height: 50px;
}

#ai-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 229, 255, 0.85);
    background-clip: padding-box;
}

/* Message groups */
.ai-msg {
    display: flex;
    gap: 0.75rem;
    max-width: 90%;
    animation: ai-msg-in 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(15px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ai-msg.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.ai-msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.9rem;
    color: var(--ai-accent);
    align-self: flex-end;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.ai-msg.user .ai-msg-avatar {
    background: rgba(10, 44, 94, 0.8);
    border-color: rgba(0, 229, 255, 0.3);
    color: white;
}

.ai-msg-content {
    display: flex;
    flex-direction: column;
}

.ai-msg-bubble {
    padding: 0.85rem 1.15rem;
    border-radius: 20px;
    font-size: 0.92rem;
    line-height: 1.6;
    font-family: 'Inter', sans-serif;
    position: relative;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.ai-msg.bot .ai-msg-bubble {
    background: var(--ai-surface-2);
    border: 1px solid rgba(0, 229, 255, 0.15);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
}

.ai-msg.user .ai-msg-bubble {
    background: linear-gradient(135deg, #0a2c5e, #1a4a8f);
    color: white;
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-bottom-right-radius: 4px;
}

.ai-msg-time {
    font-size: 0.68rem;
    color: var(--ai-text-secondary);
    margin-top: 0.35rem;
    opacity: 0.55;
    display: block;
}

.ai-msg.user .ai-msg-time { text-align: right; }

/* Lead Form inside Bubble */
.ai-lead-form {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    background: rgba(0,0,0,0.2);
    padding: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 229, 255, 0.1);
}

.ai-lead-form input {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 0.6rem 0.8rem;
    color: white;
    font-size: 0.85rem;
    outline: none;
    transition: var(--ai-transition);
}

.ai-lead-form input:focus {
    border-color: var(--ai-accent);
    background: rgba(255,255,255,0.08);
}

.ai-lead-submit {
    background: var(--ai-accent);
    color: #051632;
    border: none;
    border-radius: 8px;
    padding: 0.6rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--ai-transition);
    margin-top: 0.4rem;
    font-size: 0.85rem;
}

.ai-lead-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--ai-accent-glow);
}

/* Typing indicator */
#ai-typing {
    display: none;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    margin-bottom: 0.8rem;
}

#ai-typing.visible { display: flex; }

.ai-typing-dots {
    display: flex;
    gap: 5px;
    background: var(--ai-surface-2);
    border: 1px solid rgba(0, 229, 255, 0.15);
    padding: 0.75rem 1rem;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--ai-accent);
    border-radius: 50%;
    animation: ai-dot 1.4s infinite ease-in-out;
    opacity: 0.4;
}

@keyframes ai-dot {
    0%, 100% { opacity: 0.4; transform: translateY(0); }
    50% { opacity: 1; transform: translateY(-4px); }
}

/* Quick replies */
#ai-quick-replies {
    padding: 0 1.25rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-height: 120px;
    overflow-y: hidden;
}

.ai-quick-btn {
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.25);
    border-radius: 20px;
    color: var(--ai-accent);
    font-size: 0.8rem;
    font-family: 'Space Grotesk', sans-serif;
    padding: 0.45rem 1rem;
    cursor: pointer;
    transition: var(--ai-transition);
    white-space: nowrap;
}

.ai-quick-btn:hover {
    background: rgba(0, 229, 255, 0.15);
    border-color: var(--ai-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 229, 255, 0.15);
}

/* ============ INPUT AREA ============ */
#ai-input-area {
    padding: 1.25rem;
    border-top: 1px solid rgba(0, 229, 255, 0.1);
    background: rgba(10, 10, 18, 0.4);
    backdrop-filter: blur(10px);
    flex-shrink: 0;
}

#ai-input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ai-border);
    border-radius: 18px;
    padding: 0.6rem 0.75rem 0.6rem 1.15rem;
    transition: var(--ai-transition);
}

#ai-input-row:focus-within {
    border-color: var(--ai-accent);
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 0 4px rgba(0, 229, 255, 0.1);
}

#ai-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--ai-text);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    max-height: 120px;
    min-height: 24px;
    line-height: 1.5;
    padding: 4px 0;
}

#ai-input::placeholder { color: var(--ai-text-secondary); opacity: 0.5; }

#ai-send {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #0a2c5e, var(--ai-accent));
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--ai-transition);
    flex-shrink: 0;
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#ai-send:hover:not(:disabled) { 
    transform: scale(1.08) rotate(-5deg); 
    box-shadow: 0 6px 15px var(--ai-accent-glow); 
}

#ai-send:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }
#ai-send svg { width: 18px; height: 18px; }

#ai-footer-note {
    text-align: center;
    font-size: 0.72rem;
    color: var(--ai-text-secondary);
    opacity: 0.5;
    margin-top: 0.75rem;
    font-family: 'Inter', sans-serif;
    letter-spacing: 0.02em;
}

/* ============ MOBILE OPTIMIZATION ============ */
@media (max-width: 480px) {
    #festlift-ai-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }
    
    #festlift-ai-window.open {
        transform: none;
    }

    #festlift-ai-toggle {
        bottom: 20px;
        right: 20px;
        width: 60px;
        height: 60px;
    }

    #ai-header { padding: 1.25rem; }
    #ai-input-area { padding-bottom: calc(1.25rem + env(safe-area-inset-bottom)); }
}
