/* Liha Chatbot 4.0.0 — la couleur vient des réglages (variable --liha-primary). */
:root {
    --liha-primary: #007bff;
    --liha-radius: 14px;
}

.liha-chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 370px;
    height: 540px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: var(--liha-radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    z-index: 99999;
    font-size: 15px;
    line-height: 1.45;
}

.liha-chatbot-container.active {
    display: flex;
    animation: lihaFadeIn 0.25s ease-out;
}

/* Mode pleine page (shortcode [liha_chatbot]) : dans le flux de la page. */
.liha-chatbot-container.liha-chatbot-inline {
    position: static;
    display: flex;
    width: 100%;
    max-width: 720px;
    height: 70vh;
    margin: 0 auto;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
}

@keyframes lihaFadeIn {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}

/* ── En-tête ─────────────────────────────────────────────────────────────── */
.liha-chatbot-header {
    padding: 12px 15px;
    background: var(--liha-primary);
    color: #fff;
    border-radius: var(--liha-radius) var(--liha-radius) 0 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.liha-chatbot-logo {
    width: 28px;
    height: 28px;
    filter: brightness(0) invert(1);
}

.liha-chatbot-title {
    flex-grow: 1;
    font-weight: 600;
    font-size: 16px;
}

.liha-chatbot-toggle {
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    color: #fff;
    opacity: 0.85;
}

.liha-chatbot-toggle:hover,
.liha-chatbot-toggle:focus {
    opacity: 1;
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.liha-chatbot-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    background: #fbfcfd;
}

.liha-chatbot-conversation {
    display: flex;
    flex-direction: column;
}

.liha-chatbot-message {
    max-width: 85%;
    padding: 10px 14px;
    margin: 4px 0;
    border-radius: 14px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.liha-chatbot-message p {
    margin: 0 0 6px;
}

.liha-chatbot-message p:last-child {
    margin-bottom: 0;
}

.liha-chatbot-message ul {
    margin: 4px 0;
    padding-left: 20px;
}

.liha-chatbot-message.user {
    background: var(--liha-primary);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.liha-chatbot-message.bot {
    background: #eef1f4;
    color: #212529;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

/* Sources citées sous les réponses */
.liha-chatbot-sources {
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.85em;
}

.liha-chatbot-source a {
    color: var(--liha-primary);
    text-decoration: underline;
    word-break: break-word;
}

/* ── Saisie ──────────────────────────────────────────────────────────────── */
.liha-chatbot-input {
    padding: 12px 15px;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 8px;
    background: #fff;
}

#liha-chatbot-message {
    flex-grow: 1;
    padding: 9px 12px;
    border: 1px solid #ced4da;
    border-radius: 8px;
    font-size: 15px;
}

#liha-chatbot-message:focus {
    outline: 2px solid var(--liha-primary);
    outline-offset: -1px;
    border-color: var(--liha-primary);
}

#liha-chatbot-send {
    padding: 9px 16px;
    background: var(--liha-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
}

#liha-chatbot-send:hover:not(:disabled) {
    filter: brightness(0.9);
}

#liha-chatbot-send:disabled,
#liha-chatbot-message:disabled {
    opacity: 0.6;
    cursor: default;
}

.liha-chatbot-footer {
    padding: 6px 15px 10px;
    font-size: 11px;
    color: #868e96;
    text-align: center;
    background: #fff;
    border-radius: 0 0 var(--liha-radius) var(--liha-radius);
}

/* ── Bulle de déclenchement ──────────────────────────────────────────────── */
.liha-chatbot-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--liha-primary);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
    z-index: 99998;
    padding: 12px;
    transition: transform 0.15s ease;
}

.liha-chatbot-trigger:hover {
    transform: scale(1.07);
}

.liha-chatbot-trigger.hidden {
    display: none;
}

.liha-chatbot-trigger img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* ── Indicateur de frappe ────────────────────────────────────────────────── */
.liha-chatbot-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 4px 0;
    padding: 12px 14px;
    background: #eef1f4;
    border-radius: 14px;
    align-self: flex-start;
}

.liha-chatbot-typing span {
    width: 6px;
    height: 6px;
    background: var(--liha-primary);
    border-radius: 50%;
    animation: lihaBlink 1.4s infinite both;
}

.liha-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.liha-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lihaBlink {
    0%, 80%, 100% { opacity: 0; transform: scale(0.8); }
    40%           { opacity: 1; transform: scale(1); }
}

/* ── Mobile : panneau plein écran en bas ─────────────────────────────────── */
@media (max-width: 600px) {
    .liha-chatbot-container {
        width: 100vw;
        height: 80vh;
        right: 0;
        bottom: 0;
        border-radius: var(--liha-radius) var(--liha-radius) 0 0;
    }

    .liha-chatbot-footer {
        border-radius: 0;
    }

    .liha-chatbot-trigger {
        width: 54px;
        height: 54px;
        right: 12px;
        bottom: 12px;
    }
}

/* Respecte la préférence « réduire les animations » */
@media (prefers-reduced-motion: reduce) {
    .liha-chatbot-container.active { animation: none; }
    .liha-chatbot-trigger { transition: none; }
}
