/* ============================================================
   Châteaux Select - assistant de dialogue immobilier
   ------------------------------------------------------------
   Reprend les variables de site.css, qui est toujours chargé avant.
   Aucune police n'est chargée depuis un CDN.
   ============================================================ */

.cs-bot {
    position: fixed;
    right: clamp(0.75rem, 3vw, 1.5rem);
    bottom: clamp(0.75rem, 3vw, 1.5rem);
    z-index: 60;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    font-family: var(--sans);
}

/* --- Le declencheur --- */

.cs-bot-declencheur {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.8rem 1.4rem;
    border: 1px solid var(--or);
    border-radius: 2rem;
    background: var(--nuit);
    color: var(--or-clair);
    font-family: var(--sans);
    font-size: 0.85rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(33, 35, 58, 0.26);
}

.cs-bot-declencheur:hover {
    background: var(--nuit-profond);
}

.cs-bot-declencheur::before {
    content: "";
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: var(--or);
}

/* --- Le panneau --- */

.cs-bot-panneau {
    display: flex;
    flex-direction: column;
    width: min(23rem, calc(100vw - 1.5rem));
    max-height: min(32rem, calc(100vh - 6rem));
    border: 1px solid var(--filet-or);
    background: var(--papier);
    box-shadow: 0 18px 48px rgba(33, 35, 58, 0.28);
}

.cs-bot-panneau[hidden] {
    display: none;
}

.cs-bot-entete {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    background: var(--nuit);
    color: var(--parchemin);
}

.cs-bot-titre {
    margin: 0;
    font-family: var(--serif);
    font-size: 0.98rem;
    color: var(--or-clair);
}

.cs-bot-sous-titre {
    margin: 0.15rem 0 0;
    font-size: 0.72rem;
    line-height: 1.35;
    color: rgba(244, 241, 233, 0.72);
}

.cs-bot-fermer {
    flex: none;
    width: 1.9rem;
    height: 1.9rem;
    border: 0;
    background: none;
    color: var(--parchemin);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}

.cs-bot-fermer:hover {
    color: var(--or-clair);
}

/* --- Le fil de la conversation --- */

.cs-bot-fil {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 1rem;
    background: var(--papier);
}

.cs-bot-message {
    display: flex;
    margin-bottom: 0.7rem;
}

.cs-bot-message-visiteur {
    justify-content: flex-end;
}

.cs-bot-bulle {
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    font-size: 0.87rem;
    line-height: 1.5;
    overflow-wrap: break-word;
}

.cs-bot-message-assistant .cs-bot-bulle {
    border-left: 2px solid var(--filet-or);
    background: var(--parchemin);
    color: var(--encre);
}

.cs-bot-message-visiteur .cs-bot-bulle {
    background: var(--nuit);
    color: var(--parchemin);
}

.cs-bot-message-erreur .cs-bot-bulle {
    border-left: 2px solid var(--alerte);
    background: var(--alerte-fond);
    color: var(--alerte);
}

.cs-bot-bulle a {
    color: inherit;
    text-decoration-color: currentColor;
    text-underline-offset: 0.2em;
    overflow-wrap: anywhere;
}

/* --- Questions proposees --- */

.cs-bot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: flex-start;
    margin-top: 0.4rem;
}

.cs-bot-suggestion {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--filet-or);
    background: transparent;
    color: var(--or-fonce);
    font-family: var(--sans);
    font-size: 0.78rem;
    text-align: left;
    cursor: pointer;
}

.cs-bot-suggestion:hover {
    background: var(--parchemin);
}

/* --- Attente, avis de confidentialite, saisie et mention --- */

.cs-bot-attente {
    margin: 0;
    padding: 0 1rem 0.6rem;
    font-size: 0.76rem;
    font-style: italic;
    color: var(--gris);
}

/* Le filet du haut separait l'avis du fil ; il tient maintenant la zone de
   saisie, qui est devenue le premier element sous les messages. */
.cs-bot-saisie {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--filet);
}

.cs-bot-saisie input {
    flex: 1 1 auto;
    min-width: 0;
    padding: 0.55rem 0.65rem;
    border: 1px solid var(--filet);
    background: #fff;
    color: inherit;
    font-family: var(--sans);
    font-size: 0.85rem;
}

.cs-bot-saisie input:focus {
    border-color: var(--or-fonce);
}

.cs-bot-envoyer {
    flex: none;
    padding: 0.55rem 1rem;
    border: 1px solid var(--nuit);
    background: var(--nuit);
    color: var(--parchemin);
    font-family: var(--sans);
    font-size: 0.82rem;
    cursor: pointer;
}

.cs-bot-envoyer:disabled,
.cs-bot-saisie input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.cs-bot-mention {
    margin: 0;
    padding: 0 1rem 0.85rem;
    font-size: 0.68rem;
    line-height: 1.4;
    color: var(--gris);
}

/* --- Telephone --- */

@media (max-width: 30rem) {
    .cs-bot {
        right: 0.5rem;
        bottom: 0.5rem;
        left: 0.5rem;
        align-items: stretch;
    }

    .cs-bot-panneau {
        width: 100%;
        max-height: calc(100vh - 5.5rem);
    }

    .cs-bot-declencheur {
        align-self: flex-end;
    }
}

@media (prefers-reduced-motion: no-preference) {
    .cs-bot-panneau {
        animation: cs-bot-apparition 160ms ease-out;
    }

    @keyframes cs-bot-apparition {
        from {
            opacity: 0;
            transform: translateY(0.5rem);
        }
    }
}
