.chat-fab{
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1020;
    /* visible, not hidden - the <img> already clips itself to a circle via
       its own border-radius below, so the parent doesn't need to clip too.
       Needs to be visible so the online dot (positioned at this box's
       corner) doesn't get cut off by a circular overflow clip. */
    overflow: visible;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    transition: transform .25s ease, box-shadow .25s ease, opacity .25s ease, visibility .25s ease;
    animation: chatFabIn .5s var(--ease) both, chatFabPulse 3.4s ease-in-out 1.4s infinite;
}

.chat-fab img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.chat-fab-online{
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #22c55e;
    border: 2.5px solid #fff;
    z-index: 1;
}

.chat-fab:hover{
    transform: scale(1.08);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.24);
}

.chat-fab.hidden{
    animation: none;
    opacity:0;
    visibility:hidden;
    pointer-events:none;
    transform:scale(.7);
}

/* Entrance pop-in when the page first loads. */
@keyframes chatFabIn{
    from{
        opacity: 0;
        transform: scale(0.4);
    }
    to{
        opacity: 1;
        transform: scale(1);
    }
}

/* Soft, slow attention ring - draws the eye back to the FAB every few
   seconds without being a constant distraction. Runs on the box-shadow only
   (not transform/opacity), so it can't fight the entrance animation or the
   hover scale above. */
@keyframes chatFabPulse{
    0%, 100%{
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 0 0 0 rgba(var(--primary-rgb), 0.35);
    }
    50%{
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18), 0 0 0 10px rgba(var(--primary-rgb), 0);
    }
}

@media (prefers-reduced-motion: reduce){
    .chat-fab{
        animation: none;
    }
}

.chat-window{
    position:fixed;
    right:16px;
    bottom:0;
    width:380px;
    height:620px;
    background:#f7f8fa;
    border-radius: 14px 14px 2px 2px;
    overflow:hidden;
    box-shadow:0 20px 60px rgba(0,0,0,.2);
    display:flex;
    flex-direction:column;
    z-index:9998;

    opacity:0;
    transform:translateY(20px) scale(.9);
    pointer-events:none;

    transition: opacity .25s ease, transform .25s ease, top .25s var(--ease), height .25s var(--ease), width .25s var(--ease);
}

.chat-window.show{
    opacity:1;
    transform:translateY(0) scale(1);
    pointer-events:auto;
}

/* Full-height mode, toggled by .chat-expand-btn (chat.controller.js
   toggleChatMaximize()). Stays anchored to the same bottom-right corner
   (bottom:0 is already set above) - just grows upward by adding a top
   offset and letting height:auto fill the gap, and widens a bit, instead
   of hardcoding a 100vh height that wouldn't adapt to mobile browser
   chrome the way top+bottom auto-sizing does. */
.chat-window.maximized{
    top: 16px;
    height: auto;
    width: min(440px, calc(100vw - 32px));
}

.chat-header{
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color: #fff;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    position: relative;
}

.chat-header > div:nth-child(2){
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.chat-close-btn{
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
}

.chat-close-btn:hover{
    background: rgba(255,255,255,.28);
    transform: scale(1.05);
}

.chat-expand-btn{
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    color: #fff;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .2s ease;
}

.chat-expand-btn:hover{
    background: rgba(255,255,255,.28);
    transform: scale(1.05);
}

.chat-avatar{
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
}

.chat-content{
    flex:1;
    position:relative;
    overflow:hidden;
}

.chat-body{
    height:100%;
    overflow-y:auto;
    padding:16px;
    display:flex;
    gap:12px;
    flex-direction:column-reverse;
}

.message-row{
    display:flex;
    margin-bottom:12px;
}

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

.chat-bubble{
    max-width:90%;
    padding:12px 16px;
    line-height:1.4;
    word-break:break-word;
    animation:bubbleIn .2s ease;
    position:relative;
}

.chat-bot-bubble{
    background:white;
    border-radius:18px 18px 18px 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.chat-user-bubble{
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    color:white;
    border-radius:18px 18px 4px 18px;
    box-shadow: 0 2px 8px rgba(183, 255, 0, 0.2);
}

.chat-user-bubble:after{
    content:'';
    position:absolute;
    right:-6px;
    bottom:0;
    width:12px;
    height:12px;
    background: var(--primary-light);
    clip-path:polygon(0 0,100% 100%,0 100%);
}

.chat-bot-bubble:after{
    content:'';
    position:absolute;
    left:-6px;
    bottom:0;
    width:12px;
    height:12px;
    background:inherit;
    clip-path:polygon(100% 0,100% 100%,0 100%);
}

.chat-bot-bubble a{
    color: var(--primary-color);
    text-decoration: none;
}

.chat-bot-bubble h2{
    font-size: 18px;
}
.chat-bot-bubble h3{
    font-size: 16px;
}

.chat-bot-bubble p{
    margin:0 0 8px;
}

.chat-bot-bubble p:last-child{
    margin-bottom:0;
}

.chat-bot-bubble ul,
.chat-bot-bubble ol{
    margin:8px 0;
    padding-left:20px;
}

.chat-bot-bubble code{
    background:#f5f5f5;
    padding:2px 5px;
    border-radius:4px;
}

.chat-bot-bubble pre{
    background:#f5f5f5;
    padding:10px;
    border-radius:8px;
    overflow:auto;
}

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

.chat-input{
    border-top:1px solid #eee;
    background: #fff;
    padding:12px;
    display:flex;
    gap:10px;
    align-items:flex-end;
}

.chat-input textarea{
    flex:1;
    resize:none;
    border:1px solid #ddd;
    border-radius:24px;
    padding:10px 14px;
    max-height:120px;
    outline:none;
    font-family:inherit;
}

.chat-input button{
    border:none;
    background: linear-gradient(135deg, var(--primary-light), var(--primary-color));
    color:white;
    border-radius:24px;
    padding:10px 14px;
    cursor:pointer;
    box-shadow: 0 4px 8px rgb(103 136 19 / 50%);
}

.chat-suggestion-chips{
    display:flex;
    flex-wrap:nowrap;
    gap:8px;
    overflow-x:auto;
    overflow-y:hidden;
    padding:8px 16px;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
}

.chat-suggestion-chips::-webkit-scrollbar{
    display:none;
}

.chat-suggestion-chip{
    flex-shrink:0;
    cursor:pointer;
    padding:8px 14px;
    border-radius:999px;
    background:#fff;
    color: #5e8f3d;
    border: 1px solid rgba(113, 156, 63, 0.3);
    white-space:nowrap;
    font-size:13px;
    font-weight:500;
    transition:all .2s ease;
}

.chat-suggestion-chip:hover{
    transform: scale(1.05);
    box-shadow: 0 2px 4px rgba(113, 156, 63, 0.1);
}

.chat-suggestion-wrapper{
    position:relative;
}

.chat-suggestion-wrapper::after{
    content:'';
    position:absolute;
    right:0;
    top:0;
    bottom:0;
    width:30px;
    pointer-events:none;

    background:linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,1));
}

.welcome-card{
    height:100%;
    overflow-y:auto;
    padding:24px;
    box-sizing:border-box;
    display:flex;
    flex-direction:column;
}

.welcome-name{
    background: linear-gradient(135deg, var(--primary-light), #8B5CF6);
    -webkit-background-clip:text;
    -webkit-text-fill-color:transparent;
}

.quick-item{
    width:100%;
    display:flex;
    justify-content:space-between;
    align-items:center;
    padding:12px 0;
    border:none;
    border-top:1px solid #f4f4f4;
    background:none;
    cursor:pointer;
    font-size:14px;
    color:#333;
    transition:.2s;
}

.quick-item:first-of-type{
    border-top:none;
}

.quick-item:hover{
    color: var(--primary-light);
    transform:translateX(4px);
}

@keyframes fadeIn{
    from{
        opacity:0;
        transform:translateY(10px);
    }
    to{
        opacity:1;
        transform:none;
    }
}

.typing-bubble{
    display:flex;
    gap:5px;
    align-items:center;
    padding:12px 16px;
    min-width:60px;
}

.dot{
    width:7px;
    height:7px;
    border-radius:50%;
    background: var(--primary-light);
    animation:pulse 1.2s infinite ease-in-out;
}

.dot:nth-child(2){
    animation-delay:.15s;
}

.dot:nth-child(3){
    animation-delay:.3s;
}

@keyframes pulse{
    0%,80%,100%{
        transform:scale(.8);
        opacity:.3;
    }
    40%{
        transform:scale(1.3);
        opacity:1;
    }
}

.chat-loading{
    height:100%;

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

    gap:16px;
}

.chat-assistance-name {
    font-weight: bold;
    font-size: 1.1rem;

    background: linear-gradient(45deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-bottom: 6px;
}

@media only screen and (max-width: 760px) {
    /* .chat-window.maximized is listed here too, not just .chat-window -
       .maximized has higher specificity (two classes vs one) than a bare
       .chat-window, so without repeating it here the desktop .maximized
       rule's top:16px/width:min(440px,...) would win over this block for
       anyone who toggled maximize on desktop and then shrunk the window (or
       rotated a tablet) below 760px, leaving a stray 16px gap and a
       constrained width instead of true full-screen. The toggle button
       itself is hidden below, but that doesn't stop the state from
       carrying over from a wider viewport. */
    .chat-window,
    .chat-window.maximized{
        left:0;
        right:0;
        top:0;
        bottom:0;
        width:auto;
        height:auto;
        border-radius:0;
    }

    /* Already full-screen at this width, so the maximize toggle would have
       nothing to do - hide it rather than show a control that does nothing. */
    .chat-expand-btn{
        display: none;
    }
}