/* Reset CSS pour WordPress */
.baudelet-chat-widget * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.baudelet-chat-widget {
    font-family: "Poppins", sans-serif;
    font-size: 16px;
    position: fixed;
    left: 50%;
    z-index: 999999;
    line-height: 1;
    opacity: 1;
    transform: translateY(0) translateX(-50%);
    transition: all 0.3s ease;
}
.baudelet-chat-widget.scrolled {
    left: auto;
    right: 20px;
    bottom: 20px;
}

/* Quand le chat est ouvert en mode scrolled, garder la position en bas à droite */
.baudelet-chat-widget.scrolled:has(.ben-content--visible) {
    left: auto;
    right: 20px;
    bottom: 20px;
    transform: translateX(0);
}

/* Le widget s'agrandit quand le chat est ouvert en mode scrolled */
.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben {
    width: 25.8125rem;
    height: auto;
    padding: 0.0625rem;
    border-radius: 1.875rem;
}

.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-frame {
    width: auto;
    height: auto;
    padding: 1.25rem;
    border-radius: 1.875rem;
    display: inline-flex;
    flex-direction: column;
}

.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-cta {
    height: auto;
    border-radius: 1.875rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    justify-content: start;
}

.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-cta__avatar {
    width: 3.375rem;
    height: 3.375rem;
    flex: 0 0 3.375rem;
}

.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-cta__label,
.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-cta__chevron,
.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-cta__close {
    display: inline-flex;
}

.baudelet-chat-widget.scrolled .ben {
    width: 4.5rem;
    height: 4.5rem;
    padding: 0.125rem;
    border-radius: 50%;
    transition: none;
}

.baudelet-chat-widget.scrolled .ben-frame {
    width: 100%;
    height: 100%;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
}

.baudelet-chat-widget.scrolled .ben-cta {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: none;
}

.baudelet-chat-widget.scrolled .ben-cta__avatar {
    width: 3.5rem;
    height: 3.5rem;
    flex: none;
    transition: none;
}

.baudelet-chat-widget.scrolled .ben-cta__label,
.baudelet-chat-widget.scrolled .ben-cta__chevron,
.baudelet-chat-widget.scrolled .ben-cta__close {
    display: none;
}

/* Le contenu du chat est masqué par défaut en mode scrolled */
.baudelet-chat-widget.scrolled .ben-content {
    display: none;
}

/* Mais il s'affiche quand le chat est ouvert en mode scrolled */
.baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-content {
    display: flex;
}

.ben {
    --border-gradient: linear-gradient(97deg, #C2F6BD 17.14%, #FE7F63 52.31%, #FFF0C9 88.17%);
    --surface: #F2F9F2;
    --baudelet-green-200: #C2F6BD;
    --baudelet-green-500: #80C77A;
    --baudelet-grey-300: #828282;
    --baudelet-grey-500: #454545;
    --baudelet-grey-600: #3F3F3F;
    --baudelet-yellow-50: #FFFAED;
    --text: var(--baudelet-grey-600);

    display: inline-flex;
    padding: 0.0625rem; /* espace pour la bordure gradient */
    border-radius: 1.875rem;
    color: var(--text);
    background: var(--border-gradient);
    box-shadow: 0 2.5rem 2rem -1.5rem rgba(15, 15, 15, 0.12);
    -webkit-backdrop-filter: blur(9px);
    backdrop-filter: blur(9px);
    width: 25.8125rem;
    transition: width 0.5s ease;
    max-height: 80vh;
}

/* Styles pour l'état normal (chat ouvert) */

.baudelet-chat-widget:has(.ben-content--visible) .ben {
    width: 25.8125rem;
    height: auto;
    padding: 0.0625rem;
    border-radius: 1.875rem;
}

.baudelet-chat-widget:not(.scrolled) .ben-frame {
    width: 100%;
    height: auto;
    padding: 1.25rem;
    border-radius: 1.875rem;
    display: inline-flex;
    flex-direction: column;
}

.baudelet-chat-widget:not(.scrolled) .ben-cta {
    width: auto;
    height: auto;
    border-radius: 1.875rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
}

.baudelet-chat-widget:not(.scrolled) .ben-cta__avatar {
    width: 3.375rem;
    height: 3.375rem;
    flex: 0 0 3.375rem;
}

.baudelet-chat-widget:not(.scrolled) .ben-cta__label,
.baudelet-chat-widget:not(.scrolled) .ben-cta__chevron,
.baudelet-chat-widget:not(.scrolled) .ben-cta__close {
    display: inline-flex;
}

.baudelet-chat-widget:not(.scrolled) .ben-content {
    display: flex;
}

.ben-frame {
    display: inline-flex;
    flex-direction: column;
    border-radius: 1.875rem;
    background: var(--surface);
    padding: 1.25rem;
}

.ben-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    border-radius: 1.875rem;
    color: var(--text);
    border: none;
    background: none;
    cursor: pointer;
    outline: none;
    transition: all 0.4s ease 0.2s;
    position: relative;
}
.baudelet-chat-widget.scrolled .ben:has(.ben-content--visible),
.baudelet-chat-widget .ben:has(.ben-content--visible) {
    width: 29.4375rem;
}

.baudelet-chat-widget .ben:has(.ben-content--visible) .ben-cta__chevron {
    display: none;
}

.ben-cta:focus-visible {
    outline: 0.1875rem solid rgba(194, 246, 189, 0.6);
    outline-offset: 0.125rem;
}

.ben-cta__avatar {
    width: 3.375rem;
    height: 3.375rem;
    flex: 0 0 3.375rem;
}

.ben-cta__label {
    white-space: nowrap;
    font-weight: 700;
    margin-right: 2rem;
}

.ben-cta__chevron {
    margin-left: auto;
    width: 2.5625rem;
    height: 2.5625rem;
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--baudelet-green-200);
    font-size: 1rem;
}

.ben-cta__close {
    opacity: 0;
    position: absolute;
    width: 1.5rem;
    height: 1.5rem;
    flex: none;
    right: 1.25rem;
    top: 1.25rem;
    border: none;
    background: none;
    cursor: pointer;
}

.ben:has(.ben-content--visible) .ben-cta__close {
    opacity: 1;
}

.ben-cta:focus-visible {
    outline: none;
    box-shadow: 0 0 0 0.1875rem rgba(194, 246, 189, 0.6), 0 2.5rem 2rem -1.5rem rgba(15, 15, 15, 0.12);
}

.ben-shortcuts {
    display: flex;
    align-items: center;
    margin-top: 0.625rem;
    gap: 1.375rem;
}

.ben-shortcut {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 0.9375rem;
    background-color: var(--baudelet-green-200);
    border-radius: 1.25rem;
    font-weight: 700;
    gap: 0.3125rem;
    line-height: 150%;
    color: var(--baudelet-grey-500);
    margin: 0 1px; /* fix outline overflow */
    border: none;
    cursor: pointer;
}

.ben-shortcut:focus-visible,
.ben-shortcut:hover {
    outline: 0.0625rem solid var(--baudelet-green-500);
}

.ben-shortcut__icon {
    flex: none;
}

.ben-content {
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    opacity: 0;
    transform: translateY(-1rem);
    pointer-events: none;
    transition: all 0.3s ease;
    max-height: 0;
    overflow: hidden;
}

.ben-content--visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    max-height: 50rem; /* Ajuster selon le contenu */
}

.ben-chat__input {
    display: flex;
    align-items: center;
    border: 1px solid var(--baudelet-grey-300);
    border-radius: 1.25rem;
    background-color: #FFF;
    overflow: hidden;
    padding: 1rem;
    height: 3rem;
    gap: 0.5rem;
}

.ben-chat__input input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 0.875rem;
    line-height: 125%;
}

.ben-shortcut:disabled,
.ben-chat__input button:disabled,
.ben-chat__input input:disabled,
.ben-chat__input:has(input:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

.ben-chat__input input::placeholder {
    color: var(--baudelet-grey-300);
}

.ben-chat__input button {
    width: 1.5rem;
    height: 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
}

.ben-chat__messages {
    max-height: 40rem;
    overflow-y: auto;
    transition: padding 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 1rem;
}

.ben-chat__messages:has(.ben-chat__message) {
    padding: 1.25rem 0;
}

.ben-chat__message {
    display: flex;
    justify-content: flex-start;
}

.ben-chat__message-bubble {
    padding: 0.625rem 1rem;
    border-radius: 1.25rem;
    background-color: var(--baudelet-grey-600);
    color: #FFF;
    line-height: 150%;
}

.ben-chat__message--user {
    justify-content: flex-end;
}

.ben-chat__message-bubble--user {
    background-color: var(--baudelet-yellow-50);
    color: var(--baudelet-grey-600);
}

/* Animation d'apparition des messages */
@keyframes message-slide-up {
    from {
        opacity: 0;
        transform: translateY(2rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ben-chat__message--animate {
    animation: message-slide-up 0.4s ease-out;
    animation-fill-mode: both;
}

/* Animation de chargement avec 3 points */
.ben-chat__loading {
    display: flex;
    justify-content: flex-start;
    padding: 1.25rem 0;
}

.ben-chat__loading-dots {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 1.25rem 1rem;
    background-color: var(--baudelet-grey-600);
    border-radius: 1.25rem;
    color: #FFF;
    line-height: 150%;
}

.ben-chat__loading-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
    background-color: #FFF;
    animation: loading-bounce 1.4s ease-in-out infinite both;
}

.ben-chat__loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.ben-chat__loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

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

@keyframes loading-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Styles personnalisés de la scrollbar pour le chat */
.ben-chat__messages {
    scrollbar-width: thin;
    scrollbar-color: var(--baudelet-grey-300) transparent;
}

/* Styles pour l'overlay de déconnexion */
.ben-disconnect-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 1.875rem;
}

.ben-disconnect-overlay__content {
    text-align: center;
    padding: 2rem;
    max-width: 300px;
}

.ben-disconnect-overlay__message {
    color: var(--baudelet-grey-600);
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    line-height: 1.4;
}

.ben-disconnect-overlay__restart-btn {
    background: linear-gradient(135deg, var(--baudelet-green-200), var(--baudelet-green-500));
    color: white;
    border: none;
    padding: 0.875rem 2rem;
    border-radius: 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0.25rem 0.5rem rgba(128, 199, 122, 0.3);
}

.ben-disconnect-overlay__restart-btn:hover {
    transform: translateY(-0.125rem);
    box-shadow: 0 0.375rem 0.75rem rgba(128, 199, 122, 0.4);
}

.ben-disconnect-overlay__restart-btn:active {
    transform: translateY(0);
}

/* Responsive */
@media (max-width: 480px) {
    .ben {
        max-height: none;
        width: 95vw;
    }
    .baudelet-chat-widget.scrolled {
        bottom: 10px;
        right: 10px;
        transform: translateX(0);
    }
    .baudelet-chat-widget.scrolled:has(.ben-content--visible) {
        bottom: 0px;
        right: 0;
    }
    .baudelet-chat-widget:has(.ben-content--visible) {
        top: 0;
    }
    .ben-shortcuts {
        gap: 0;
    }
    .ben-shortcut__label {
        font-size: 0.75rem;
    }
    .ben-frame {
        justify-content: space-between !important;
    }
    .baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben-frame {
        width: 100%;
    }
    .baudelet-chat-widget:has(.ben-content--visible) .ben,
    .baudelet-chat-widget.scrolled:has(.ben-content--visible) .ben {
        width: 100vw;
        height: 100vh;
    }
    .ben-cta__label {
        margin-right: 0;
        font-size: 0.75rem;
    }
}
