/* chatbot.css — widget assistant (popup bas-droite).
   S'appuie sur les variables de theme.css (or #FFB800 / marine), avec valeurs
   de repli au cas où une page ne charge pas le thème. */

.lr-chatbot {
    --lrc-primary: var(--c-primary, #FFB800);
    --lrc-primary-dark: var(--c-primary-dark, #CC9200);
    --lrc-bg: var(--c-surface, #0F2035);
    --lrc-bg2: var(--c-surface2, #152840);
    --lrc-text: var(--c-text, #f4f4f5);
    --lrc-text2: var(--c-text-2, #c6c6ce);
    --lrc-muted: var(--c-text-muted, #8a8a94);
    --lrc-border: rgba(255, 255, 255, 0.09);
    position: fixed;
    right: clamp(14px, 3vw, 26px);
    bottom: clamp(14px, 3vw, 26px);
    z-index: 9400;
    font-family: inherit;
}

/* ── Bouton flottant ─────────────────────────────────────────── */
.lr-chatbot-fab {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #1a1205;
    background: linear-gradient(145deg, var(--lrc-primary), var(--lrc-primary-dark));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45),
                0 0 0 1px rgba(255, 184, 0, 0.35),
                0 6px 18px rgba(255, 184, 0, 0.25);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
    margin-left: auto;
}
.lr-chatbot-fab:hover { transform: translateY(-2px) scale(1.04); }
.lr-chatbot-fab:active { transform: scale(0.96); }
.lr-chatbot-fab:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.lr-chatbot-fab .lr-chatbot-fab-close { display: none; }
.lr-chatbot[data-open="true"] .lr-chatbot-fab .lr-chatbot-fab-open { display: none; }
.lr-chatbot[data-open="true"] .lr-chatbot-fab .lr-chatbot-fab-close { display: block; }

/* ── Panneau ─────────────────────────────────────────────────── */
.lr-chatbot-panel {
    position: absolute;
    right: 0;
    bottom: 72px;
    width: min(370px, calc(100vw - 28px));
    height: min(560px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    background: var(--lrc-bg);
    border: 1px solid var(--lrc-border);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    overflow: hidden;
    transform-origin: bottom right;
    animation: lrcPanelIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.lr-chatbot-panel[hidden] { display: none; }
@keyframes lrcPanelIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ──────────────────────────────────────────────────── */
.lr-chatbot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 14px;
    background: linear-gradient(120deg, rgba(255, 184, 0, 0.16), rgba(255, 184, 0, 0.04));
    border-bottom: 1px solid var(--lrc-border);
}
.lr-chatbot-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    color: #1a1205;
    background: linear-gradient(145deg, var(--lrc-primary), var(--lrc-primary-dark));
    flex: none;
}
.lr-chatbot-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.lr-chatbot-title strong { color: var(--lrc-text); font-size: 0.95rem; }
.lr-chatbot-sub { color: var(--lrc-muted); font-size: 0.72rem; }
.lr-chatbot-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--lrc-text2);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    transition: background 0.15s ease, color 0.15s ease;
}
.lr-chatbot-close:hover { background: rgba(255, 255, 255, 0.08); color: var(--lrc-text); }

/* ── Messages ────────────────────────────────────────────────── */
.lr-chatbot-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}
.lr-chatbot-messages::-webkit-scrollbar { width: 7px; }
.lr-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16); border-radius: 4px;
}

.lr-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 14px;
    font-size: 0.875rem;
    line-height: 1.42;
    white-space: pre-wrap;
    word-wrap: break-word;
    animation: lrcMsgIn 0.18s ease;
}
@keyframes lrcMsgIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
.lr-msg-bot {
    align-self: flex-start;
    background: var(--lrc-bg2);
    color: var(--lrc-text);
    border-bottom-left-radius: 5px;
}
.lr-msg-user {
    align-self: flex-end;
    background: linear-gradient(145deg, var(--lrc-primary), var(--lrc-primary-dark));
    color: #1a1205;
    font-weight: 500;
    border-bottom-right-radius: 5px;
}

/* Liens internes attachés à une réponse du bot */
.lr-msg-links {
    align-self: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    max-width: 90%;
}
.lr-msg-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--lrc-primary);
    background: rgba(255, 184, 0, 0.10);
    border: 1px solid rgba(255, 184, 0, 0.35);
    padding: 6px 11px;
    border-radius: 999px;
    transition: background 0.15s ease, transform 0.12s ease;
}
.lr-msg-link:hover { background: rgba(255, 184, 0, 0.20); transform: translateY(-1px); }
.lr-msg-link::before { content: "→"; opacity: 0.7; }

/* Indicateur de saisie */
.lr-msg-typing { display: inline-flex; gap: 4px; align-items: center; }
.lr-msg-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--lrc-muted);
    animation: lrcTyping 1.1s infinite ease-in-out;
}
.lr-msg-typing span:nth-child(2) { animation-delay: 0.16s; }
.lr-msg-typing span:nth-child(3) { animation-delay: 0.32s; }
@keyframes lrcTyping { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ── Quick replies ───────────────────────────────────────────── */
.lr-chatbot-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    padding: 0 14px 8px;
}
.lr-chatbot-quick:empty { display: none; }
.lr-quick-btn {
    font: inherit;
    font-size: 0.8rem;
    color: var(--lrc-text);
    background: var(--lrc-bg2);
    border: 1px solid var(--lrc-border);
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.15s ease, transform 0.12s ease, background 0.15s ease;
}
.lr-quick-btn:hover {
    border-color: var(--lrc-primary);
    background: rgba(255, 184, 0, 0.10);
    transform: translateY(-1px);
}
/* Échappatoire « écrire » : se distingue des vraies options (style discret). */
.lr-quick-write {
    color: var(--lrc-text2);
    background: transparent;
    border-style: dashed;
}
.lr-quick-write:hover {
    color: var(--lrc-text);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--lrc-text2);
}

/* ── Formulaire ──────────────────────────────────────────────── */
.lr-chatbot-form[hidden] { display: none; }
.lr-chatbot-form {
    border-top: 1px solid var(--lrc-border);
    padding: 10px 12px 12px;
    background: var(--lrc-bg);
}
.lr-chatbot-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--lrc-bg2);
    border: 1px solid var(--lrc-border);
    border-radius: 14px;
    padding: 6px 6px 6px 12px;
    transition: border-color 0.15s ease;
}
.lr-chatbot-input-wrap:focus-within { border-color: var(--lrc-primary); }
.lr-chatbot-input {
    flex: 1 1 auto;
    background: transparent;
    border: none;
    color: var(--lrc-text);
    font: inherit;
    font-size: 0.875rem;
    resize: none;
    max-height: 96px;
    line-height: 1.4;
    padding: 5px 0;
}
.lr-chatbot-input:focus { outline: none; }
.lr-chatbot-input::placeholder { color: var(--lrc-muted); }
.lr-chatbot-send {
    flex: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: #1a1205;
    background: linear-gradient(145deg, var(--lrc-primary), var(--lrc-primary-dark));
    transition: opacity 0.15s ease, transform 0.12s ease;
}
.lr-chatbot-send:hover { transform: scale(1.05); }
.lr-chatbot-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.lr-chatbot-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    padding: 0 4px;
    font-size: 0.7rem;
    color: var(--lrc-muted);
}
.lr-chatbot-count.is-limit { color: var(--c-danger, #ef4444); }
.lr-chatbot-quota.is-empty { color: var(--c-danger, #ef4444); }

/* ── Invitation à se connecter (visiteurs déconnectés) ───────── */
.lr-chatbot-auth {
    border-top: 1px solid var(--lrc-border);
    padding: 14px 14px 16px;
    background: var(--lrc-bg);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
}
.lr-chatbot-auth[hidden] { display: none; }
.lr-chatbot-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    text-decoration: none;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background: #5865F2;
    border-radius: 12px;
    padding: 11px 14px;
    transition: background 0.15s ease, transform 0.12s ease;
}
.lr-chatbot-login-btn:hover { background: #4752c4; transform: translateY(-1px); }
.lr-chatbot-login-btn:active { transform: scale(0.98); }
.lr-chatbot-login-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lr-chatbot-auth-note {
    margin: 0;
    text-align: center;
    font-size: 0.76rem;
    line-height: 1.4;
    color: var(--lrc-muted);
}

/* ── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .lr-chatbot { right: 12px; bottom: 12px; }
    .lr-chatbot-panel {
        position: fixed;
        right: 0; left: 0; bottom: 0; top: 0;
        width: 100vw;
        height: 100dvh;
        border-radius: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lr-chatbot-panel, .lr-msg, .lr-msg-typing span { animation: none; }
    .lr-chatbot-fab, .lr-chatbot-send, .lr-msg-link, .lr-quick-btn { transition: none; }
}

/* ── Cibles tactiles ≥44px sur mobile (audit UI/UX 06/2026) ── */
@media (max-width: 480px) {
    .lr-quick-btn,
    .lr-msg-link {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}
