/* Widget "Nous contacter" de la page d'accueil (visiteurs non connectés) — même logique de
   panneau/chat que l'assistant IA du tableau de bord, mais dans la palette de la page d'accueil
   (bleu nuit + amber) puisque chatbot.css n'est pas chargé ici. */

#contact-widget-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 997;
    background: linear-gradient(135deg, #ffca28, #ffa000) !important;
    color: #1b3446;
    box-shadow: 0 10px 24px -8px rgba(0, 0, 0, .45);
    transition: transform .18s ease, box-shadow .18s ease;
}

#contact-widget-fab:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 14px 28px -8px rgba(0, 0, 0, .5);
}

#contact-widget-fab.is-open i {
    transform: rotate(180deg);
}

#contact-widget-fab i {
    transition: transform .25s ease;
}

/* ── Panneau ───────────────────────────────────────────────────────── */

#contact-widget-panel {
    display: none;
    position: fixed;
    right: 24px;
    /* Clears both stacked FABs (the "Nous contacter" toggle plus "Les modules BTP Box" above it),
       not just the toggle it's anchored to. */
    bottom: 172px;
    z-index: 997;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: min(560px, 75dvh);
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 24px 60px -16px rgba(16, 32, 48, .35), 0 4px 16px rgba(16, 32, 48, .1);
    font-family: "Poppins", sans-serif;
}

#contact-widget-panel.is-open {
    display: flex;
    animation: cwPanelIn .22s cubic-bezier(.2, .8, .3, 1.1);
}

@keyframes cwPanelIn {
    from {
        opacity: 0;
        transform: translateY(18px) scale(.96);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@media only screen and (max-width: 600px) {
    #contact-widget-panel {
        right: 16px;
        bottom: 160px;
        width: calc(100vw - 32px);
    }
}

/* ── En-tête ───────────────────────────────────────────────────────── */

#contact-widget-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1b3446, #2f6f8f);
    color: #fff;
}

#contact-widget-header-text {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

#contact-widget-title {
    font-size: .95rem;
    font-weight: 700;
}

.hp-contact-status-flag {
    width: 13px;
    height: 9px;
    margin-right: 4px;
    vertical-align: middle;
}

#contact-widget-status {
    font-size: 10.5px;
    color: rgba(255, 255, 255, .75);
}

#contact-widget-close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    transition: background .12s;
}

#contact-widget-close:hover {
    background: rgba(255, 255, 255, .16);
}

#contact-widget-close i {
    font-size: 19px;
}

/* ── Historique ────────────────────────────────────────────────────── */

#contact-widget-history {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafb;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.cw-msg {
    display: flex;
    animation: cwMsgIn .2s ease;
}

@keyframes cwMsgIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.cw-msg--bot {
    justify-content: flex-start;
}

.cw-msg--user {
    justify-content: flex-end;
}

.cw-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: .85rem;
    line-height: 1.45;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.cw-msg--bot .cw-bubble {
    background: #fff;
    color: #26323b;
    border: 1px solid #e3e8ed;
    border-bottom-left-radius: 5px;
}

.cw-msg--user .cw-bubble {
    background: linear-gradient(135deg, #1b3446, #2f6f8f);
    color: #fff;
    border-bottom-right-radius: 5px;
}

/* ── Zone de saisie ────────────────────────────────────────────────── */

#contact-widget-input-area {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #e3e8ed;
    background: #fff;
}

#contact-widget-input {
    flex: 1;
    resize: none;
    max-height: 100px;
    border: 1px solid #d7e0e6;
    border-radius: 14px;
    padding: 9px 12px;
    font-family: inherit;
    font-size: .85rem;
    background: #f7fafc;
}

#contact-widget-input:focus {
    outline: none;
    border-color: #2f6f8f;
    background: #fff;
}

#contact-widget-send {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ffca28, #ffa000);
    color: #1b3446;
    cursor: pointer;
    transition: transform .12s, opacity .12s;
}

#contact-widget-send:hover {
    transform: scale(1.05);
}

#contact-widget-send:disabled {
    opacity: .5;
    cursor: default;
    transform: none;
}

#contact-widget-send i {
    font-size: 18px;
}

#contact-widget-input-area.hidden {
    display: none;
}

#contact-widget-cancel {
    display: block;
    text-align: center;
    padding: 0 12px 10px;
    font-size: 11.5px;
    color: #90a0aa;
    background: #fff;
}

#contact-widget-cancel:hover {
    color: #566573;
    text-decoration: underline;
}
