/*==================================================
    CHATBOT WIDGET — floating assistant
    Depends on variables.css tokens already defined
    in public.css (--primary, --primary-dark,
    --secondary, --heading, --white, --border,
    --light-grey, --transition)
==================================================*/

.ks-chat-fab{

    position:fixed;
    right:24px;
    bottom:24px;
    z-index:10040;

    width:60px;
    height:60px;
    border-radius:50%;

    background:var(--primary);
    color:var(--white);
    border:none;

    display:flex;
    align-items:center;
    justify-content:center;
    font-size:26px;

    box-shadow:0 10px 28px rgba(11,61,102,.35);
    cursor:pointer;
    transition:var(--transition);
}

.ks-chat-fab:hover{

    background:var(--primary-dark);
    transform:translateY(-2px) scale(1.04);
}

.ks-chat-fab .bi-x-lg{

    display:none;
}

.ks-chat-fab.is-open .bi-chat-dots-fill{

    display:none;
}

.ks-chat-fab.is-open .bi-x-lg{

    display:block;
}


/* -------------------- Panel -------------------- */

.ks-chat-panel{

    position:fixed;
    right:24px;
    bottom:96px;
    z-index:10039;

    width:380px;
    max-width:calc(100vw - 32px);
    height:min(600px,calc(100vh - 130px));

    background:var(--white);
    border-radius:18px;
    box-shadow:0 24px 60px rgba(15,23,42,.22);
    overflow:hidden;

    display:flex;
    flex-direction:column;

    opacity:0;
    visibility:hidden;
    transform:translateY(16px) scale(.98);
    transform-origin:bottom right;
    transition:opacity .22s ease, transform .22s ease, visibility .22s;
}

.ks-chat-panel.is-open{

    opacity:1;
    visibility:visible;
    transform:translateY(0) scale(1);
}


/* -------------------- Header -------------------- */

.ks-chat-header{

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

    padding:16px 16px 16px 18px;
    background:linear-gradient(135deg,var(--primary),var(--primary-dark));
    color:var(--white);
}

.ks-chat-avatar{

    width:48px;
    height:38px;
    border-radius:10px;
    flex:none;

    background:var(--white);
    display:flex;
    align-items:center;
    justify-content:center;
    padding:5px 6px;
}

.ks-chat-avatar img{

    width:100%;
    height:100%;
    object-fit:contain;
}

.ks-chat-header-text{

    flex:1;
    min-width:0;
}

.ks-chat-header-text h3{

    margin:0;
    font-size:15px;
    font-weight:700;
    color:var(--white);
}

.ks-chat-status{

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

    margin-top:2px;
    font-size:12px;
    color:rgba(255,255,255,.8);
}

.ks-chat-status-dot{

    width:7px;
    height:7px;
    border-radius:50%;
    background:#22c55e;
    flex:none;
}

.ks-chat-close{

    flex:none;
    width:30px;
    height:30px;
    border-radius:50%;

    background:rgba(255,255,255,.12);
    border:none;
    color:var(--white);
    font-size:15px;

    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    transition:var(--transition);
}

.ks-chat-close:hover{

    background:rgba(255,255,255,.25);
}


/* -------------------- Quick questions -------------------- */

.ks-chat-quick{

    flex:none;
    padding:14px 16px 4px;
    border-bottom:1px solid var(--border);
}

.ks-chat-quick-label{

    font-size:11px;
    font-weight:700;
    letter-spacing:.06em;
    text-transform:uppercase;
    color:#94a3b8;
    margin-bottom:10px;
}

.ks-chat-quick-grid{

    display:flex;
    flex-wrap:wrap;
    gap:8px;
    padding-bottom:14px;
}

.ks-chat-pill{

    border:1px solid var(--border);
    background:var(--white);
    color:var(--heading);

    font-size:12.5px;
    font-weight:500;
    padding:7px 13px;
    border-radius:999px;

    cursor:pointer;
    transition:var(--transition);
    white-space:nowrap;
}

.ks-chat-pill:hover{

    border-color:var(--primary);
    color:var(--primary);
    background:var(--light-grey);
}


/* -------------------- Message thread -------------------- */

.ks-chat-body{

    flex:1;
    overflow-y:auto;
    padding:16px;

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

    background:var(--light-grey);
}

.ks-chat-msg{

    display:flex;
    gap:8px;
    max-width:88%;
}

.ks-chat-msg.bot{

    align-self:flex-start;
}

.ks-chat-msg.user{

    align-self:flex-end;
    flex-direction:row-reverse;
}

.ks-chat-msg-avatar{

    flex:none;
    width:34px;
    height:26px;
    border-radius:7px;

    background:var(--white);
    border:1px solid var(--border);
    display:flex;
    align-items:center;
    justify-content:center;
    padding:3px 4px;
}

.ks-chat-msg-avatar img{

    width:100%;
    height:100%;
    object-fit:contain;
}

.ks-chat-bubble{

    background:var(--white);
    border:1px solid var(--border);
    border-radius:14px;
    padding:10px 14px;

    font-size:13.5px;
    line-height:1.55;
    color:var(--heading);
}

.ks-chat-msg.bot .ks-chat-bubble{

    border-top-left-radius:4px;
}

.ks-chat-msg.user .ks-chat-bubble{

    background:var(--primary);
    color:var(--white);
    border-color:var(--primary);
    border-top-right-radius:4px;
    border-top-left-radius:14px;
}

.ks-chat-msg-time{

    display:block;
    margin-top:6px;
    font-size:10.5px;
    color:#94a3b8;
    text-align:right;
}

.ks-chat-msg.user .ks-chat-msg-time{

    color:rgba(255,255,255,.7);
}

.ks-chat-actions{

    display:flex;
    flex-wrap:wrap;
    gap:8px;
    margin-top:10px;
}

.ks-chat-action-btn{

    display:inline-flex;
    align-items:center;
    gap:6px;

    font-size:12.5px;
    font-weight:600;
    padding:8px 14px;
    border-radius:999px;
    border:1px solid var(--primary);

    background:var(--white);
    color:var(--primary);
    text-decoration:none;
    cursor:pointer;
    transition:var(--transition);
}

.ks-chat-action-btn.solid{

    background:var(--primary);
    color:var(--white);
}

.ks-chat-action-btn:hover{

    background:var(--primary);
    color:var(--white);
}

.ks-chat-action-btn.whatsapp{

    border-color:#22c55e;
    color:#16a34a;
}

.ks-chat-action-btn.whatsapp:hover{

    background:#22c55e;
    border-color:#22c55e;
    color:var(--white);
}

.ks-chat-typing{

    display:inline-flex;
    gap:4px;
    padding:12px 14px;
}

.ks-chat-typing span{

    width:6px;
    height:6px;
    border-radius:50%;
    background:#94a3b8;
    animation:ksChatTyping 1s infinite ease-in-out;
}

.ks-chat-typing span:nth-child(2){ animation-delay:.15s; }
.ks-chat-typing span:nth-child(3){ animation-delay:.3s; }

@keyframes ksChatTyping{

    0%,60%,100%{ transform:translateY(0); opacity:.4; }
    30%{ transform:translateY(-4px); opacity:1; }
}


/* -------------------- Input row -------------------- */

.ks-chat-footer{

    flex:none;
    padding:12px 14px;
    background:var(--white);
    border-top:1px solid var(--border);
}

.ks-chat-input-row{

    display:flex;
    align-items:center;
    gap:8px;
}

.ks-chat-input-row input{

    flex:1;
    min-width:0;

    border:1px solid var(--border);
    border-radius:999px;
    padding:10px 16px;
    font-size:13px;
    color:var(--heading);
    outline:none;
    transition:var(--transition);
}

.ks-chat-input-row input:focus{

    border-color:var(--primary);
    box-shadow:0 0 0 3px rgba(11,61,102,.12);
}

.ks-chat-send{

    flex:none;
    width:38px;
    height:38px;
    border-radius:50%;
    border:none;

    background:var(--primary);
    color:var(--white);
    font-size:15px;

    display:flex;
    align-items:center;
    justify-content:center;
    cursor:pointer;
    transition:var(--transition);
}

.ks-chat-send:hover{

    background:var(--primary-dark);
}

.ks-chat-footer-caption{

    margin:8px 0 0;
    text-align:center;
    font-size:10.5px;
    color:#94a3b8;
}


/* -------------------- Responsive -------------------- */

@media (max-width:480px){

    .ks-chat-panel{

        right:16px;
        bottom:88px;
        width:calc(100vw - 32px);
    }

    .ks-chat-fab{

        right:16px;
        bottom:16px;
    }
}
