/* =====================================================
   AVM WEBSITE – CHATBOT UI
   PREMIUM GLASS + PHYSICS ANIMATION
   FINAL LOCK VERSION
===================================================== */

/* =====================================================
   GLOBAL SAFE OFFSET (DESKTOP + MOBILE)
===================================================== */
:root {
    --chatbot-safe-bottom: max(140px, env(safe-area-inset-bottom));
    --chatbot-safe-right: max(22px, env(safe-area-inset-right));
}

/* =====================================================
   CHATBOT TOGGLE (FLOATING GLASS BUTTON)
===================================================== */

#chatbotToggle {
    position: fixed;
    right: var(--chatbot-safe-right);
    bottom: var(--chatbot-safe-bottom);

    width: 60px;
    height: 60px;

    border-radius: 50%;
    border: none;

    background:
        linear-gradient(135deg, rgba(11,60,93,0.95), rgba(14,75,115,0.95));

    color: #ffffff;
    font-size: 26px;
    cursor: pointer;

    display: flex;
    align-items: center;
    justify-content: center;

    box-shadow:
        0 30px 70px rgba(11, 60, 93, 0.55),
        inset 0 1px 0 rgba(255,255,255,0.35);

    z-index: 10000;

    transition:
        transform 0.3s cubic-bezier(.34,1.56,.64,1),
        box-shadow 0.3s ease;

    transform: translateZ(0);
    will-change: transform;
}

#chatbotToggle:hover {
    transform: translateY(-6px) scale(1.08);
    box-shadow:
        0 40px 90px rgba(11, 60, 93, 0.7),
        inset 0 1px 0 rgba(255,255,255,0.45);
}

#chatbotToggle:active {
    transform: scale(0.92);
}

/* =====================================================
   CHATBOT WINDOW – TRUE GLASS CARD
===================================================== */

#chatbotBox {
    position: fixed;
    right: var(--chatbot-safe-right);
    bottom: calc(var(--chatbot-safe-bottom) + 84px);

    width: 360px;
    max-height: 540px;

    background: rgba(255, 255, 255, 0.16);
    backdrop-filter: blur(32px) saturate(180%);
    -webkit-backdrop-filter: blur(32px) saturate(180%);

    border-radius: 22px;
    border: 1px solid rgba(255,255,255,0.35);

    box-shadow:
        0 60px 120px rgba(0,0,0,0.45),
        inset 0 1px 0 rgba(255,255,255,0.55);

    display: flex;
    flex-direction: column;

    overflow: hidden;
    z-index: 9999;

    visibility: hidden;
    pointer-events: none;

    opacity: 0;
    transform: translateY(80px) scale(0.82);

    transition:
        opacity 0.25s ease,
        transform 0.65s cubic-bezier(.34,1.56,.64,1);

    contain: layout paint;
    will-change: transform, opacity;
}

#chatbotBox.active {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transform: translateY(0) scale(1);
}

#chatbotBox:not(.active) {
    transition:
        opacity 0.25s ease,
        transform 0.4s ease;
}

/* =====================================================
   HEADER – GLASS BAR WITH DEPTH
===================================================== */

.chatbot-header {
    background:
        linear-gradient(
            135deg,
            rgba(11,60,93,0.75),
            rgba(14,75,115,0.75)
        );

    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);

    color: #ffffff;
    padding: 14px 16px;
    font-size: 15px;
    font-weight: 600;

    display: flex;
    justify-content: space-between;
    align-items: center;

    box-shadow:
        inset 0 -1px 0 rgba(255,255,255,0.18);
}

#chatbotClose {
    background: none;
    border: none;
    color: #ffffff;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.75;

    transition:
        opacity 0.25s ease,
        transform 0.35s cubic-bezier(.34,1.56,.64,1);
}

#chatbotClose:hover {
    opacity: 1;
    transform: rotate(90deg) scale(1.15);
}

/* =====================================================
   MESSAGES AREA (FROSTED)
===================================================== */

#chatbotMessages {
    flex: 1;
    padding: 14px;
    overflow-y: auto;

    background: rgba(245, 247, 250, 0.55);
    backdrop-filter: blur(6px);
}

#chatbotMessages::-webkit-scrollbar {
    width: 6px;
}

#chatbotMessages::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.25);
    border-radius: 6px;
}

.chatbot-message {
    max-width: 80%;
    padding: 11px 15px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.45;

    animation: bubbleIn 0.38s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.chatbot-message.bot {
    background: rgba(226, 232, 240, 0.95);
    color: #1a202c;
    border-radius: 16px 16px 16px 6px;
}

.chatbot-message.user {
    background:
        linear-gradient(135deg, #0b3c5d, #0e4b73);
    color: #ffffff;
    border-radius: 16px 16px 6px 16px;
    margin-left: auto;
}

/* =====================================================
   TYPING – FLOATING DOTS
===================================================== */

#chatbotTyping {
    display: none;
    padding: 10px 14px;
    background: rgba(255,255,255,0.35);
    backdrop-filter: blur(8px);
}

.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-right: 4px;
    background: #718096;
    border-radius: 50%;
    animation: typingBounce 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes typingBounce {
    0%   { opacity: 0.3; transform: translateY(0); }
    50%  { opacity: 1;   transform: translateY(-6px); }
    100% { opacity: 0.3; transform: translateY(0); }
}

/* =====================================================
   INTENTS – LIFT ON HOVER
===================================================== */

#chatbotIntents {
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

#chatbotIntents button {
    padding: 12px;
    font-size: 13px;
    border-radius: 12px;
    border: 1px solid rgba(11,60,93,0.6);
    background: rgba(255,255,255,0.65);
    color: #0b3c5d;
    cursor: pointer;

    transition:
        transform 0.25s ease,
        background 0.25s ease,
        box-shadow 0.25s ease;
}

#chatbotIntents button:hover {
    background: #0b3c5d;
    color: #ffffff;
    transform: translateY(-3px);
    box-shadow: 0 12px 24px rgba(11,60,93,0.35);
}

/* =====================================================
   INPUT – FOCUS GLOW
===================================================== */

.chatbot-input {
    display: flex;
    padding: 12px;
    background: rgba(255,255,255,0.55);
    backdrop-filter: blur(6px);
    border-top: 1px solid rgba(255,255,255,0.35);
}

#chatbotInput {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.15);
}

#chatbotInput:focus {
    border-color: #0b3c5d;
    box-shadow: 0 0 0 2px rgba(11,60,93,0.2);
}

#chatbotSend {
    margin-left: 8px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #0b3c5d, #0e4b73);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    cursor: pointer;

    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

#chatbotSend:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 18px rgba(11,60,93,0.4);
}

/* =====================================================
   AGENT CTA – SOFT TAP
===================================================== */

#chatbotAgentBtn {
    margin: 12px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.65);
    color: #0b3c5d;
    font-size: 13px;
    text-align: center;
    cursor: pointer;

    transition:
        transform 0.25s ease,
        background 0.25s ease;
}

#chatbotAgentBtn:hover {
    background: #0b3c5d;
    color: #ffffff;
    transform: translateY(-3px);
}

/* =====================================================
   MOBILE
===================================================== */

@media (max-width: 768px) {
    :root {
        --chatbot-safe-bottom: max(110px, env(safe-area-inset-bottom));
    }

    #chatbotBox {
        left: 12px;
        right: 12px;
        width: auto;
        max-height: 82vh;
    }

    #chatbotToggle {
        width: 56px;
        height: 56px;
        font-size: 24px;
    }

    #chatbotIntents {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   ISOLATION (NO GLOBAL DAMAGE)
===================================================== */

body.chatbot-open {
    overflow-x: hidden;
}

.top-to-bottom {
    contain: layout paint;
    will-change: transform;
}

.chatbot-option {
    position: relative;
    overflow: hidden;
}

.chatbot-option .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(11, 60, 93, 0.25);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(3);
        opacity: 0;
    }
}

html {
    scrollbar-gutter: stable;
}
