/* ── Bouton FAB ─────────────────────────────────────────── */
.chatbox-fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--color-primary, hsl(207, 65%, 45%));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(30, 95, 138, .4);
    z-index: 1100;
    transition: transform .25s cubic-bezier(.34, 1.56, .64, 1),
                box-shadow .25s ease,
                background .2s ease;
    border: none;
    outline: none;
}

.chatbox-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(30, 95, 138, .5);
    background: var(--color-primary-dark, hsl(207, 65%, 35%));
}

.chatbox-fab:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 3px;
}

/* Icônes ouvert / fermé */
.chatbox-fab-icon {
    width: 28px;
    height: 28px;
    position: absolute;
    transition: opacity .22s ease, transform .22s ease;
    filter: brightness(0) invert(1);
}

.chatbox-fab-icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(.7);
}

.chatbox-fab.is-open .chatbox-fab-icon--open {
    opacity: 0;
    transform: rotate(90deg) scale(.7);
}

.chatbox-fab.is-open .chatbox-fab-icon--close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Badge notification */
.chatbox-fab-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--color-tertiary, hsl(45, 100%, 51%));
    color: #333;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: var(--font-family-base, 'Poppins', sans-serif);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    transition: opacity .2s ease, transform .2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.chatbox-fab-badge.hidden {
    opacity: 0;
    transform: scale(0);
    pointer-events: none;
}

/* ── Panneau ─────────────────────────────────────────────── */
.chatbox-panel {
    position: fixed;
    bottom: calc(2rem + 70px);
    right: 2rem;
    width: 380px;
    max-width: calc(100vw - 32px);
    max-height: 600px;
    background: var(--color-background, #fff);
    border-radius: 16px;
    box-shadow:
        0 4px 6px rgba(0,0,0,.05),
        0 12px 40px rgba(0,0,0,.14),
        0 0 0 1px rgba(0,0,0,.04);
    z-index: 1099;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(.96);
    opacity: 0;
    pointer-events: none;
    transition: transform .3s cubic-bezier(.34, 1.56, .64, 1),
                opacity .22s ease;
}

.chatbox-panel.is-open {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────── */
.chatbox-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    background: linear-gradient(135deg,
        var(--color-primary, hsl(207,65%,45%)) 0%,
        var(--color-primary-light, hsl(207,65%,55%)) 100%);
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.chatbox-header::before {
    content: '';
    position: absolute;
    top: -50%; right: -20%;
    width: 150%; height: 200%;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,.08));
    transform: rotate(-15deg);
    pointer-events: none;
}

.chatbox-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
}

/* Avatar */
.chatbox-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
    border: 2px solid rgba(255,255,255,.35);
    box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

.chatbox-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chatbox-avatar-fallback {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    position: absolute;
    font-family: var(--font-family-base, 'Poppins', sans-serif);
    letter-spacing: .02em;
}

.chatbox-header-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Titre*/
.chatbox-header-info strong {
    font-size: 1.6rem;
    font-weight: 700;
    color: #fff;
    font-family: var(--font-family-base, 'Poppins', sans-serif);
    letter-spacing: .01em;
}

/* Statut */
.chatbox-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.2rem;
    color: rgba(255,255,255,.85);
    font-family: var(--font-family-base, 'Poppins', sans-serif);
}

.chatbox-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    animation: pulse-dot 2.2s ease-in-out infinite;
    box-shadow: 0 0 0 0 rgba(74,222,128,.5);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(74,222,128,.5); }
    50%       { opacity: .6; box-shadow: 0 0 0 4px rgba(74,222,128,0); }
}

/* Bouton fermer */
.chatbox-header-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.chatbox-header-close svg { width: 20px; height: 20px; }

.chatbox-header-close:hover {
    background: rgba(255,255,255,.28);
    transform: rotate(90deg);
}

/* ── Messages ────────────────────────────────────────────── */
.chatbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: var(--color-background, #fff);
}

.chatbox-messages::-webkit-scrollbar { width: 4px; }
.chatbox-messages::-webkit-scrollbar-track { background: transparent; }
.chatbox-messages::-webkit-scrollbar-thumb {
    background: var(--color-border, hsl(0,0%,90%));
    border-radius: 4px;
}

/* Bulles  */
.chatbox-bubble {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 1.4rem;
    line-height: 1.6;
    animation: bubbleIn .22s ease forwards;
    font-family: var(--font-family-base, 'Poppins', sans-serif);
}

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

.chatbox-bubble--bot {
    background: var(--color-boxground, hsl(0,0%,93%));
    color: var(--color-text, hsl(0,0%,20%));
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    border-left: 3px solid var(--color-primary, hsl(207,65%,45%));
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.chatbox-bubble--bot a {
    color: var(--color-primary, hsl(207,65%,45%));
    font-weight: 600;
    text-decoration: underline;
    transition: color .2s;
}

.chatbox-bubble--bot a:hover {
    color: var(--color-primary-dark, hsl(207,65%,35%));
}

.chatbox-bubble--user {
    background: linear-gradient(135deg,
        var(--color-primary, hsl(207,65%,45%)) 0%,
        var(--color-primary-light, hsl(207,65%,55%)) 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
    box-shadow: 0 2px 8px rgba(37,99,168,.25);
}

/* Indicateur de frappe */
.chatbox-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--color-boxground, hsl(0,0%,93%));
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border-left: 3px solid var(--color-primary, hsl(207,65%,45%));
    width: fit-content;
    animation: bubbleIn .22s ease forwards;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
}

.chatbox-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-primary, hsl(207,65%,45%));
    opacity: .4;
    animation: typingDot 1.2s ease-in-out infinite;
}

.chatbox-typing span:nth-child(2) { animation-delay: .2s; }
.chatbox-typing span:nth-child(3) { animation-delay: .4s; }

@keyframes typingDot {
    0%, 80%, 100% { transform: scale(1);   opacity: .4; }
    40%            { transform: scale(1.4); opacity: 1; }
}

/* ── Suggestions ─────────────────────────────────────────── */
.chatbox-suggestions {
    padding: 12px 16px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    border-top: 1px solid var(--color-border, hsl(0,0%,90%));
    max-height: 180px;
    overflow-y: auto;
    background: var(--color-background, #fff);
}

.chatbox-suggestions::-webkit-scrollbar { width: 3px; }
.chatbox-suggestions::-webkit-scrollbar-thumb {
    background: var(--color-border, hsl(0,0%,90%));
    border-radius: 2px;
}

/* Boutons */
.chatbox-suggestion-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: var(--color-background, #fff);
    color: var(--color-primary, hsl(207,65%,45%));
    border: 1.5px solid var(--color-primary, hsl(207,65%,45%));
    border-radius: 8px;
    padding: 0.6rem 1rem;
    font-size: 1.3rem;
    font-weight: 600;
    font-family: var(--font-family-base, 'Poppins', sans-serif);
    cursor: pointer;
    transition: background .2s ease,
                color .2s ease,
                transform .15s ease,
                box-shadow .2s ease;
    white-space: nowrap;
    text-align: left;
}

.chatbox-suggestion-btn:hover {
    background: var(--color-primary, hsl(207,65%,45%));
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30,95,138,.3);
}

/* Icônes SVG dans les boutons */
.chatbox-suggestion-btn .chat-icon,
.chatbox-suggestion-btn img {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    object-fit: contain;
    vertical-align: middle;
    display: inline-block;
}

/* Inverser l'icône au hover
.chatbox-suggestion-btn:hover .chat-icon,
.chatbox-suggestion-btn:hover img {
    filter: brightness(0) invert(1);
}*/

/* Icônes dans les bulles bot */
.chatbox-bubble--bot .chat-icon,
.chatbox-bubble--bot img.chat-icon {
    width: 16px;
    height: 16px;
    vertical-align: -3px;
    margin-right: 3px;
    flex-shrink: 0;
    display: inline;
}

/* Mode sombre : icônes dans les suggestions */
.dark .chatbox-suggestion-btn .chat-icon,
.dark .chatbox-suggestion-btn img {
    filter: brightness(0) invert(0.8);
}
/*
.dark .chatbox-suggestion-btn:hover .chat-icon,
.dark .chatbox-suggestion-btn:hover img {
    filter: brightness(0) invert(1);
}*/

/* ── Footer ─────────────────────────────────────────────── */
.chatbox-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.2rem;
    border-top: 1px solid var(--color-border, hsl(0,0%,90%));
    flex-shrink: 0;
    min-height: 44px;
    background: var(--color-background-alt, hsl(0,0%,97%));
}

/* Bouton retour  */
.chatbox-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: var(--color-primary, hsl(207,65%,45%));
    font-size: 1.2rem;
    font-weight: 600;
    font-family: var(--font-family-base, 'Poppins', sans-serif);
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: background .18s ease, transform .15s ease;
}

.chatbox-back-btn svg { width: 16px; height: 16px; }

.chatbox-back-btn:hover {
    background: var(--color-boxground, hsl(0,0%,93%));
    transform: translateX(-2px);
}

/* Marque footer */
.chatbox-footer-brand {
    font-size: 1.2rem;
    color: var(--color-text-light, hsl(0,0%,40%));
    font-style: italic;
    font-family: var(--font-family-base, 'Poppins', sans-serif);
}

/* ── Mode sombre ─────────────────────────────────────────── */
.dark .chatbox-panel {
    background: var(--color-background, hsl(210,15%,12%));
    box-shadow:
        0 4px 6px rgba(0,0,0,.2),
        0 12px 40px rgba(0,0,0,.4),
        0 0 0 1px rgba(255,255,255,.05);
}

.dark .chatbox-bubble--bot {
    background: var(--color-boxground, hsl(210,6%,15%));
    color: var(--color-text, hsl(0,0%,90%));
}

.dark .chatbox-typing         { background: var(--color-boxground, hsl(210,6%,15%)); }
.dark .chatbox-suggestion-btn { background: var(--color-background, hsl(210,15%,12%)); }
.dark .chatbox-footer         { background: var(--color-boxground, hsl(210,6%,15%)); }
.dark .chatbox-messages,
.dark .chatbox-suggestions    { background: var(--color-background, hsl(210,15%,12%)); }

/* ── Overlay mobile — bloque scroll arrière-plan ─────────── */
.chatbox-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1098;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: chatOverlayIn .25s ease forwards;
    cursor: pointer;
}

@keyframes chatOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@media (max-width: 600px) {
    .chatbox-overlay.is-open { display: block; }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1000px) {
    .chatbox-fab   { bottom: 2rem; right: 2rem; }
    .chatbox-panel { bottom: calc(2rem + 70px); right: 2rem; width: 350px; }
}

@media (max-width: 600px) {
    .chatbox-fab {
        bottom: 1.2rem;
        right: 1.2rem;
        width: 54px;
        height: 54px;
    }
    .chatbox-panel {
        bottom: calc(1.2rem + 64px);
        right: 8px;
        left: 8px;
        width: auto;
        max-width: calc(100vw - 16px);
        max-height: calc(100dvh - 130px);
        border-radius: 16px;
    }
    /* Boutons wrappables sur mobile */
    .chatbox-suggestion-btn { white-space: normal; }
}