/* ===================================================================
   Chatbot Widget — bulle flottante + fenêtre de conversation
   =================================================================== */

.chatbot-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    color: #fff;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 24px rgba(99, 102, 241, .4);
    transition: all .25s;
}
.chatbot-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 8px 32px rgba(99, 102, 241, .55);
}
.chatbot-fab .badge-dot {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}
.chatbot-fab.open { border-radius: 50%; }
.chatbot-fab.open .bi-chat-dots-fill { display: none; }
.chatbot-fab.open .bi-x-lg { display: inline-block; }
.chatbot-fab .bi-x-lg { display: none; font-size: 1.3rem; }

/* Fenêtre chat */
.chatbot-window {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    max-height: 520px;
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 12px 48px rgba(0, 0, 0, .15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: cbSlideUp .25s ease-out;
}
@keyframes cbSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chatbot-window.show { display: flex; }

/* Header */
.cb-header {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    padding: .85rem 1.15rem;
    display: flex;
    align-items: center;
    gap: .65rem;
    flex-shrink: 0;
}
.cb-header .cb-avatar {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}
.cb-header .cb-title { font-weight: 700; font-size: .95rem; }
.cb-header .cb-subtitle { font-size: .75rem; opacity: .8; }
.cb-header .cb-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #fff;
    opacity: .7;
    font-size: 1.1rem;
    cursor: pointer;
    transition: opacity .15s;
}
.cb-header .cb-close:hover { opacity: 1; }

/* Messages area */
.cb-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .65rem;
    min-height: 200px;
    max-height: 340px;
    background: #f8fafc;
}

.cb-msg {
    max-width: 85%;
    padding: .7rem .95rem;
    border-radius: 14px;
    font-size: .9rem;
    line-height: 1.5;
    word-wrap: break-word;
}
.cb-msg.bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}
.cb-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #6366f1, #818cf8);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.cb-msg.system {
    align-self: center;
    background: #fef3c7;
    color: #92400e;
    font-size: .82rem;
    border-radius: 10px;
    text-align: center;
}

/* Typing indicator */
.cb-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: .65rem 1rem;
    align-self: flex-start;
}
.cb-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a5b4fc;
    animation: cbDot 1.2s infinite;
}
.cb-typing span:nth-child(2) { animation-delay: .2s; }
.cb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes cbDot {
    0%, 60%, 100% { opacity: .3; transform: scale(.8); }
    30% { opacity: 1; transform: scale(1.1); }
}

/* Input area */
.cb-input-area {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1rem;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}
.cb-input-area input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: .6rem .85rem;
    font-size: .9rem;
    outline: none;
    transition: border-color .2s;
}
.cb-input-area input:focus { border-color: #818cf8; }
.cb-input-area button {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
    flex-shrink: 0;
}
.cb-input-area button:disabled { opacity: .5; cursor: not-allowed; }

/* Footer tag */
.cb-footer {
    text-align: center;
    padding: .35rem;
    font-size: .7rem;
    color: #94a3b8;
    background: #fff;
}

/* Responsive */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 16px);
        right: 8px;
        bottom: 80px;
        max-height: 70vh;
        border-radius: 16px;
    }
    .chatbot-fab { bottom: 16px; right: 16px; }
}
