/* Assistant Bensalemways : bouton flottant + panneau de chat */
:root {
    --bw-chat-ease: cubic-bezier(0.22, 0.8, 0.3, 1);
}

/* ---------- Bouton (au-dessus du bouton WhatsApp) ---------- */
.bw-chat-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 9991;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--bw-black, #171717);
    color: var(--bw-gold, #a88447);
    box-shadow: 0 10px 28px rgba(23, 23, 23, 0.28);
    cursor: pointer;
    transition: transform 0.3s var(--bw-chat-ease), background-color 0.3s ease;
    animation: bw-chat-pop 0.6s var(--bw-chat-ease) 1.4s both;
    -webkit-tap-highlight-color: transparent;
}

.bw-chat-launcher:hover {
    transform: scale(1.06);
}

.bw-chat-launcher .bw-ico-close {
    display: none;
    color: var(--bw-ivory, #fcfaf5);
}

html.bw-chat-open .bw-chat-launcher .bw-ico-chat,
html.bw-chat-open .bw-chat-launcher html.bw-chat-open .bw-chat-launcher .bw-ico-close {
    display: block;
}

/* Bulle d'invitation */
.bw-chat-teaser {
    position: fixed;
    right: 96px;
    bottom: 30px;
    z-index: 9991;
    max-width: 240px;
    padding: 12px 16px;
    border: 0;
    border-radius: 16px 16px 4px 16px;
    background: var(--bw-ivory, #fcfaf5);
    box-shadow: 0 10px 30px rgba(23, 23, 23, 0.16);
    color: #3a3732;
    font-size: 14px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    opacity: 0;
    transform: translateY(8px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.35s ease, transform 0.35s var(--bw-chat-ease);
}

.bw-chat-teaser strong {
    display: block;
    color: var(--bw-black, #171717);
}

html.bw-chat-tease .bw-chat-teaser {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

/* ---------- Panneau ---------- */
.bw-chat {
    position: fixed;
    right: 22px;
    bottom: 96px;
    z-index: 9992;
    display: flex;
    flex-direction: column;
    width: 390px;
    height: min(640px, calc(100vh - 130px));
    overflow: hidden;
    border-radius: 22px;
    background: var(--bw-ivory, #fcfaf5);
    box-shadow: 0 24px 70px rgba(23, 23, 23, 0.25), 0 0 0 1px rgba(168, 132, 71, 0.15);
    opacity: 0;
    transform: translateY(16px) scale(0.97);
    transform-origin: bottom right;
    visibility: hidden;
    transition: opacity 0.28s ease, transform 0.35s var(--bw-chat-ease), visibility 0.35s;
}

html.bw-chat-open .bw-chat {
    opacity: 1;
    transform: none;
    visibility: visible;
}

.bw-chat-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(168, 132, 71, 0.18);
    background: #fff;
}

.bw-chat-head img {
    height: 28px;
    width: auto;
}

.bw-chat-name {
    display: grid;
    gap: 2px;
    margin-left: 2px;
    padding-left: 12px;
    border-left: 1px solid rgba(168, 132, 71, 0.25);
    line-height: 1.2;
}

.bw-chat-name strong {
    color: var(--bw-black, #171717);
    font-size: 14px;
    font-weight: 600;
}

.bw-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #8e887c;
    font-size: 12px;
}

.bw-chat-x {
    margin-left: auto;
}

.bw-chat-status span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3ab446;
    box-shadow: 0 0 0 3px rgba(58, 180, 70, 0.18);
}

.bw-chat-x {
    position: relative;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(23, 23, 23, 0.1);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.bw-chat-x i {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 1.6px;
    margin: -0.8px 0 0 -7px;
    background: var(--bw-black, #171717);
    transform: rotate(45deg);
}

.bw-chat-x i + i {
    transform: rotate(-45deg);
}

/* Messages */
.bw-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 8px;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

.bw-msg {
    display: flex;
    flex-direction: column;
    margin-bottom: 12px;
}

.bw-msg.bw-in {
    animation: bw-msg-in 0.35s var(--bw-chat-ease) both;
}

.bw-msg-user {
    align-items: flex-end;
}

.bw-bubble {
    max-width: 86%;
    padding: 11px 14px;
    border-radius: 18px 18px 18px 6px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(23, 23, 23, 0.06);
    color: #2b2925;
    font-size: 14.5px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.bw-msg-user .bw-bubble {
    border-radius: 18px 18px 6px 18px;
    background: var(--bw-black, #171717);
    color: var(--bw-ivory, #fcfaf5);
}

.bw-bubble p {
    margin: 0 0 6px;
}

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

.bw-bubble ul {
    margin: 4px 0 6px;
    padding-left: 18px;
}

.bw-bubble a {
    color: var(--bw-gold, #a88447);
    text-decoration: underline;
    word-break: break-all;
}

/* Indicateur « en train d'écrire » */
.bw-typing .bw-bubble {
    display: flex;
    gap: 4px;
    padding: 14px 16px;
}

.bw-typing i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--bw-gold, #a88447);
    animation: bw-dot 1.2s infinite ease-in-out;
}

.bw-typing i:nth-child(2) { animation-delay: 0.15s; }
.bw-typing i:nth-child(3) { animation-delay: 0.3s; }

/* Cartes de packs (défilement horizontal) */
.bw-cards {
    display: flex;
    gap: 10px;
    width: calc(100% + 32px);
    margin: 8px -16px 0;
    padding: 2px 16px 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
}

.bw-cards::-webkit-scrollbar {
    display: none;
}

.bw-card {
    flex: 0 0 220px;
    overflow: hidden;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(23, 23, 23, 0.08);
    scroll-snap-align: start;
}

.bw-card-img {
    display: block;
    height: 120px;
    overflow: hidden;
}

.bw-card-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.8s var(--bw-chat-ease);
}

.bw-card:hover .bw-card-img img {
    transform: scale(1.06);
}

.bw-card-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px 12px;
}

.bw-card-place {
    color: var(--bw-gold, #a88447);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.bw-card-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--bw-black, #171717) !important;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
}

.bw-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    color: #8e887c;
    font-size: 12.5px;
}

.bw-card-meta strong {
    color: var(--bw-black, #171717);
}

.bw-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
}

.bw-btn,
.bw-btn-ghost {
    display: inline-flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none !important;
    cursor: pointer;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.bw-btn {
    background: var(--bw-orange, #f46b32);
    color: var(--bw-black, #171717) !important;
}

.bw-btn:hover {
    background: var(--bw-black, #171717);
    color: var(--bw-ivory, #fcfaf5) !important;
}

.bw-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.bw-btn-ghost {
    border-color: rgba(23, 23, 23, 0.2);
    color: var(--bw-black, #171717) !important;
}

/* Confirmation de réservation */
.bw-confirm {
    display: grid;
    gap: 10px;
    max-width: 86%;
    margin-top: 8px;
    padding: 12px 14px;
    border: 1px solid rgba(168, 132, 71, 0.3);
    border-radius: 16px;
    background: #fff;
    font-size: 14px;
}

.bw-btn-wa {
    background: var(--bw-gold, #a88447);
    color: var(--bw-ivory, #fcfaf5) !important;
}

/* Formulaire de réservation */
.bw-book {
    display: grid;
    gap: 10px;
    padding: 14px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(23, 23, 23, 0.08);
}

.bw-book-title {
    font-size: 14.5px;
}

.bw-book label {
    display: grid;
    gap: 4px;
    color: #57534b;
    font-size: 12.5px;
}

.bw-book input,
.bw-book textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid #e8e1d3;
    border-radius: 12px;
    background: var(--bw-ivory, #fcfaf5);
    color: var(--bw-black, #171717);
    font: inherit;
    font-size: 15px;
}

.bw-book-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.bw-book .bw-btn {
    min-height: 44px;
    font-size: 15px;
}

.bw-book-note {
    margin: 0;
    color: #8e887c;
    font-size: 12px;
    text-align: center;
}

.bw-book-err {
    margin: 0;
    color: #c0392b;
    font-size: 13px;
}

.bw-hp {
    position: absolute !important;
    left: -9999px !important;
}

/* Suggestions */
.bw-chat-sugg {
    display: flex;
    gap: 8px;
    padding: 8px 16px 10px;
    overflow-x: auto;
    scrollbar-width: none;
    transition: opacity 0.2s ease;
}

.bw-chat-sugg::-webkit-scrollbar {
    display: none;
}

.bw-chat-sugg.bw-hide {
    opacity: 0.4;
    pointer-events: none;
}

.bw-chip {
    flex: none;
    padding: 8px 14px;
    border: 1px solid rgba(168, 132, 71, 0.35);
    border-radius: 999px;
    background: #fff;
    color: #3a3732;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.bw-chip:hover {
    border-color: var(--bw-gold, #a88447);
    background: rgba(168, 132, 71, 0.08);
}

/* Saisie */
.bw-chat-input {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin: 0;
    padding: 10px 12px 12px;
    border-top: 1px solid rgba(168, 132, 71, 0.15);
    background: #fff;
}

.bw-chat-input textarea {
    flex: 1;
    min-height: 44px;
    max-height: 110px;
    padding: 11px 14px;
    border: 1px solid #e8e1d3;
    border-radius: 22px;
    background: var(--bw-ivory, #fcfaf5);
    color: var(--bw-black, #171717);
    font: inherit;
    font-size: 15px;
    line-height: 1.35;
    resize: none;
}

.bw-chat-input textarea:focus {
    outline: none;
    border-color: var(--bw-gold, #a88447);
    box-shadow: none !important;
}

.bw-chat-input button {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--bw-orange, #f46b32);
    color: var(--bw-black, #171717);
    cursor: pointer;
}

/* ---------- Mobile : plein écran ---------- */
@media (max-width: 767px) {
    .bw-chat-launcher {
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom));
        width: 56px;
        height: 56px;
    }

    .bw-chat-teaser {
        right: 84px;
        bottom: calc(22px + env(safe-area-inset-bottom));
        max-width: 210px;
    }

    .bw-chat {
        inset: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        transform: translateY(24px);
    }

    html.bw-chat-open,
    html.bw-chat-open body {
        overflow: hidden;
    }

    /* Panneau ouvert : la croix du panneau suffit */
    html.bw-chat-open .bw-chat-launcher,
    html.bw-chat-open .bw-wa {
        opacity: 0;
        pointer-events: none;
    }

    .bw-chat-input {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
}

/* Fiche de pack sur mobile : au-dessus de la barre « Check availability » */
@media (max-width: 1024px) {
    body.single-togo_trip .bw-chat-launcher {
        bottom: calc(96px + env(safe-area-inset-bottom));
    }
}

html.bw-menu-open .bw-chat-launcher,
html.bw-menu-open .bw-chat-teaser {
    opacity: 0;
    pointer-events: none;
}

@keyframes bw-chat-pop {
    from { opacity: 0; transform: translateY(16px) scale(0.8); }
    to { opacity: 1; transform: none; }
}

@keyframes bw-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

@keyframes bw-dot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
    40% { transform: translateY(-4px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .bw-chat,
    .bw-chat-launcher,
    .bw-msg.bw-in,
    .bw-typing i {
        animation: none !important;
        transition: none !important;
    }
}
