/* =========================================================
   LEGEND AIR HVAC — PREMIUM AI CHATBOT
   Clean Floating Support Widget (Bottom Left)
========================================================= */

/* =========================================
   FLOATING POSITION - BOTTOM LEFT
========================================= */
#a1-chat-widget{
    position:fixed;
    left:24px;
    bottom:24px;
    z-index:99999;

    display:flex;
    flex-direction:column;
    align-items:flex-start;
}

/* =========================================
   CHAT TOGGLE BUTTON
========================================= */
#a1-chat-toggle{
    width:72px;
    height:72px;

    border:none;
    border-radius:999px;

    display:flex;
    align-items:center;
    justify-content:center;

    cursor:pointer;

    color:#fff;
    font-size:1.9rem;

    background:
        linear-gradient(
            135deg,
            var(--primary),
            #c40000
        );

    box-shadow:
        0 16px 42px rgba(155,0,0,0.42),
        0 4px 14px rgba(0,0,0,0.18);

    transition:
        transform .25s ease,
        box-shadow .25s ease,
        opacity .25s ease;

    animation:legend-chat-pulse 2.6s infinite;
}

#a1-chat-toggle:hover{
    transform:translateY(-3px) scale(1.05);

    box-shadow:
        0 20px 50px rgba(155,0,0,0.55),
        0 6px 18px rgba(0,0,0,0.22);
}

#a1-chat-toggle:active{
    transform:scale(.96);
}

@keyframes legend-chat-pulse{
    0%,100%{
        box-shadow:
            0 16px 42px rgba(155,0,0,0.42),
            0 4px 14px rgba(0,0,0,0.18);
    }
    50%{
        box-shadow:
            0 22px 60px rgba(155,0,0,0.62),
            0 10px 24px rgba(0,0,0,0.24);
    }
}

/* =========================================
   CHAT WINDOW - Bottom Left
========================================= */
#a1-chat-window{
    position:fixed;

    left:24px;
    bottom:112px;

    width:390px;
    height:640px;

    background:#fff;

    border-radius:28px;

    overflow:hidden;

    display:none;
    flex-direction:column;

    box-shadow:
        0 28px 80px rgba(0,0,0,0.24),
        0 12px 34px rgba(155,0,0,0.14);

    z-index:99998;
}

#a1-chat-window.active{
    display:flex;
}

/* =========================================
   HEADER
========================================= */
.chat-header{
    background:#0f172a;

    min-height:78px;

    padding:18px 22px;

    display:flex;
    align-items:center;
    justify-content:space-between;

    border-bottom:
        1px solid rgba(255,255,255,0.08);

    flex-shrink:0;
}

.chat-header span{
    color:#fff;

    font-size:1.08rem;
    font-weight:800;

    letter-spacing:.2px;
}

/* =========================================
   CLOSE BUTTON
========================================= */
#a1-chat-close{
    width:42px;
    height:42px;

    border:none;
    border-radius:12px;

    background:rgba(255,255,255,0.08);

    color:#fff;

    display:flex;
    align-items:center;
    justify-content:center;

    font-size:1.35rem;
    font-weight:700;

    cursor:pointer;

    transition:all .25s ease;
}

#a1-chat-close:hover{
    background:rgba(255,255,255,0.18);
    transform:rotate(90deg);
}

/* =========================================
   MESSAGE AREA
========================================= */
.chat-messages{
    flex:1;

    overflow-y:auto;

    padding:22px;

    display:flex;
    flex-direction:column;
    gap:16px;

    background:
        linear-gradient(
            to bottom,
            #f8fafc,
            #eef3f7
        );

    scroll-behavior:smooth;
}

/* SCROLLBAR */
.chat-messages::-webkit-scrollbar{
    width:8px;
}

.chat-messages::-webkit-scrollbar-thumb{
    background:rgba(155,0,0,0.22);
    border-radius:999px;
}

/* =========================================
   MESSAGE BUBBLES
========================================= */
.chat-message{
    max-width:84%;

    padding:14px 18px;

    border-radius:18px;

    font-size:.97rem;
    line-height:1.6;

    word-break:break-word;

    animation:legendFadeUp .28s ease;
}

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

/* USER */
.user-message{
    align-self:flex-end;

    color:#fff;

    background:
        linear-gradient(
            135deg,
            var(--primary),
            #c40000
        );

    border-bottom-right-radius:6px;

    box-shadow:
        0 8px 20px rgba(155,0,0,0.22);
}

/* AI */
.ai-message{
    align-self:flex-start;

    background:#fff;
    color:var(--navy);

    border:
        1px solid rgba(0,0,0,0.06);

    border-left:
        4px solid var(--primary);

    border-bottom-left-radius:6px;

    box-shadow:
        0 6px 16px rgba(0,0,0,0.06);
}

/* =========================================
   INPUT AREA
========================================= */
.chat-input-area{
    padding:18px;

    display:flex;
    align-items:center;
    gap:12px;

    background:#fff;

    border-top:
        1px solid rgba(0,0,0,0.06);

    flex-shrink:0;
}

/* INPUT */
#a1-chat-input{
    flex:1;

    height:54px;

    border:none;
    border-radius:999px;

    padding:0 20px;

    background:#f5f7fa;

    color:var(--navy);

    font-size:.96rem;

    transition:all .2s ease;
}

#a1-chat-input::placeholder{
    color:#7b8794;
}

#a1-chat-input:focus{
    outline:none;

    background:#fff;

    box-shadow:
        0 0 0 2px var(--primary),
        0 0 0 6px rgba(155,0,0,0.08);
}

/* SEND BUTTON */
#a1-chat-send{
    width:54px;
    height:54px;

    border:none;
    border-radius:999px;

    display:flex;
    align-items:center;
    justify-content:center;

    cursor:pointer;

    color:#fff;
    font-weight:800;

    background:
        linear-gradient(
            135deg,
            var(--primary),
            #c40000
        );

    box-shadow:
        0 10px 22px rgba(155,0,0,0.22);

    transition:
        transform .2s ease,
        opacity .2s ease;
}

#a1-chat-send:hover{
    transform:translateY(-2px);
    opacity:.94;
}

#a1-chat-send:active{
    transform:scale(.96);
}

/* =========================================
   MOBILE RESPONSIVE - Bottom Left
========================================= */
@media (max-width:768px){

    #a1-chat-widget{
        left:16px;
        bottom:16px;
    }

    #a1-chat-window{
        width:calc(100vw - 24px);
        height:78vh;

        left:12px;
        bottom:94px;

        border-radius:24px;
    }

    #a1-chat-toggle{
        width:66px;
        height:66px;

        font-size:1.75rem;
    }

    .chat-header{
        min-height:72px;
        padding:16px 18px;
    }

    .chat-header span{
        font-size:1rem;
    }

    .chat-messages{
        padding:18px;
    }

    .chat-message{
        max-width:90%;
    }

    .chat-input-area{
        padding:14px;
    }

    #a1-chat-input{
        height:50px;
        font-size:.92rem;
    }

    #a1-chat-send{
        width:50px;
        height:50px;
    }
}
/* =========================================
   MAXIMIZE CHAT WINDOW
========================================= */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.25s ease;
}

.chat-header-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: scale(1.1);
}

.chat-window {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-window.maximized {
    width: 92% !important;
    height: 92% !important;
    top: 4% !important;
    left: 4% !important;
    border-radius: 24px !important;
    box-shadow: 0 0 80px rgba(155,0,0,0.5) !important;
}