/* Assistant IA (DEMO) — section pleine page du panneau (inc/panel/assistant.php).
   Reprend les jetons du panneau (panel.css) : encre, laiton, papier. */
.mhb-page {
    position: relative;
    height: calc(100vh - 170px); min-height: 460px;
    display: flex;
}
.mhb-chat {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
    background: var(--card, #fff); color: var(--ink, #1B2740);
    border: 1px solid var(--line, #E4DCCC); border-radius: var(--r, 14px);
    box-shadow: var(--shadow, none);
}
.mhb-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 14px 18px; border-bottom: 1px solid var(--line, #E4DCCC);
}
.mhb-head strong { font-family: Fraunces, Georgia, serif; font-size: 1.06rem; }
.mhb-tag {
    margin-left: 8px; padding: 2px 7px; border-radius: 6px; font-size: 11px; font-weight: 700;
    background: var(--brass-soft, #F1E6CC); color: var(--brass, #B0812B); vertical-align: 2px;
}
.mhb-role { display: block; font-size: .8rem; color: var(--muted, #736C5F); margin-top: 3px; }
.mhb-log {
    flex: 1; overflow-y: auto; padding: 20px 18px;
    display: flex; flex-direction: column; gap: 12px;
    background: var(--card-2, #FAF8F3);
}
.mhb-msg { display: flex; flex-direction: column; max-width: min(720px, 86%); }
.mhb-user { align-self: flex-end; align-items: flex-end; }
.mhb-assistant { align-self: flex-start; }
.mhb-bubble {
    padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; line-height: 1.45;
    background: var(--card, #fff); border: 1px solid var(--line, #E4DCCC);
}
.mhb-user .mhb-bubble { background: var(--ink, #1B2740); border-color: transparent; color: #fff; }
.mhb-error .mhb-bubble { background: #fdecea; border-color: #f5c2bd; color: #8a1c13; }
.mhb-ok .mhb-bubble { background: #e6f4ea; border-color: #b7dfc3; color: #14532d; }
.mhb-table {
    margin-top: 6px; max-height: 340px; overflow: auto;
    border-radius: 10px; border: 1px solid var(--line, #E4DCCC); background: var(--card, #fff);
}
.mhb-table table { border-collapse: collapse; width: 100%; font-size: .86rem; }
.mhb-table th, .mhb-table td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--line, #E4DCCC); }
.mhb-table th { position: sticky; top: 0; background: var(--card-2, #FAF8F3); font-weight: 600; }
.mhb-typing { display: inline-flex; gap: 4px; padding: 13px 15px; }
.mhb-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted, #736C5F); animation: mhb-dot 1.2s infinite ease-in-out; }
.mhb-typing i:nth-child(2) { animation-delay: .15s; }
.mhb-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes mhb-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .mhb-typing i { animation: none; } }
.mhb-confirm { display: flex; gap: 10px; padding: 12px 18px 0; }
.mhb-confirm[hidden] { display: none; }
.mhb-confirm button { flex: 1; max-width: 240px; padding: 11px; border-radius: 10px; border: 0; cursor: pointer; font: inherit; font-weight: 700; }
.mhb-yes { background: var(--ink, #1B2740); color: #fff; }
.mhb-no { background: var(--paper, #EFEDE7); color: var(--ink, #1B2740); }
/* Demandes proposées en un clic, sous le message d'accueil. */
.mhb-suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: -2px; }
.mhb-suggest button {
    border: 1px solid var(--brass-line, rgba(176,129,43,.32)); background: var(--card, #fff); color: var(--ink, #1B2740);
    border-radius: 999px; padding: 7px 13px; font: inherit; font-size: .86rem; cursor: pointer;
}
.mhb-suggest button:hover { background: var(--brass-soft, #F1E6CC); }

/* ---- Voix : l'entrée principale, au-dessus du champ texte ---- */
.mhb-head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mhb-voice {
    --lvl: 0;
    display: flex; align-items: center; gap: 16px;
    margin: 14px 18px 0; padding: 12px 16px;
    border-radius: 18px; background: var(--brass-soft, #F1E6CC);
}
.mhb-voice[hidden] { display: none; }
.mhb-mic {
    position: relative; flex: none; width: 72px; height: 72px; border-radius: 50%; border: 0; cursor: pointer;
    display: grid; place-items: center;
    background: var(--brass, #B0812B); color: #fff;
    box-shadow: 0 6px 18px rgba(176, 129, 43, .35);
    transition: transform .15s ease, background .2s ease;
}
.mhb-mic:hover { transform: scale(1.05); }
.mhb-mic:focus-visible { outline: 3px solid var(--ink, #1B2740); outline-offset: 3px; }
.mhb-mic:disabled { opacity: .5; cursor: default; transform: none; }
.mhb-mic svg { position: relative; z-index: 1; }
.mhb-mic-ring {
    position: absolute; inset: 0; border-radius: 50%;
    background: currentColor; opacity: 0; transform: scale(1);
}
.mhb-voice.is-rec .mhb-mic { background: #c0392b; box-shadow: 0 6px 18px rgba(192, 57, 43, .35); }
/* L'anneau suit le volume de la voix : on voit que le micro entend. */
.mhb-voice.is-rec .mhb-mic-ring { background: #c0392b; opacity: .28; transform: scale(calc(1 + var(--lvl) * .45)); transition: transform .08s linear; }
.mhb-voice.is-busy .mhb-mic, .mhb-voice.is-wait .mhb-mic { animation: mhb-pulse 1.1s infinite ease-in-out; }
@keyframes mhb-pulse { 50% { opacity: .55; } }
.mhb-voice-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.mhb-voice-text strong { font-size: 1.05rem; }
.mhb-voice-text small { color: var(--muted, #736C5F); font-size: .84rem; }
.mhb-mic-cancel {
    flex: none; border: 1px solid var(--line, #E4DCCC); background: var(--card, #fff); color: inherit;
    border-radius: 10px; padding: 8px 12px; font: inherit; font-size: .85rem; cursor: pointer;
}
.mhb-mic-cancel[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
    .mhb-voice.is-busy .mhb-mic, .mhb-voice.is-wait .mhb-mic { animation: none; }
    .mhb-voice.is-rec .mhb-mic-ring { transition: none; }
}

/* Le champ texte reste disponible, en second plan. */
.mhb-form { display: flex; gap: 10px; padding: 12px 18px 16px; }
.mhb-voice:not([hidden]) + .mhb-form { padding-top: 10px; }
.mhb-voice:not([hidden]) + .mhb-form textarea { padding: 8px 12px; font-size: .9rem; background: var(--card-2, #FAF8F3); }
.mhb-voice:not([hidden]) + .mhb-form .mhb-send { width: 40px; background: var(--ink, #1B2740); font-size: 15px; }
.mhb-form textarea {
    flex: 1; resize: none; border: 1px solid var(--line, #E4DCCC); border-radius: 12px;
    padding: 11px 14px; font: inherit; max-height: 160px; background: var(--card, #fff); color: inherit;
}
.mhb-form textarea:focus { outline: 2px solid var(--brass-line, rgba(176,129,43,.32)); border-color: var(--brass, #B0812B); }
.mhb-send {
    width: 48px; border: 0; border-radius: 12px; cursor: pointer; font-size: 18px;
    background: var(--brass, #B0812B); color: #fff;
}
.mhb-send:disabled, .mhb-confirm button:disabled { opacity: .5; cursor: default; }

/* ---- Avertissement non accepté : conversation grisée, voile, carte ---- */
.mhb-locked .mhb-chat { filter: grayscale(1) blur(2px); opacity: .45; pointer-events: none; user-select: none; }
.mhb-veil {
    position: absolute; inset: 0; z-index: 5;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: rgba(27, 39, 64, .18); border-radius: var(--r, 14px);
}
.mhb-notice {
    max-width: 620px; max-height: 100%; overflow-y: auto;
    background: var(--card, #fff); color: var(--ink, #1B2740);
    border: 1px solid var(--brass-line, rgba(176,129,43,.32)); border-radius: 16px;
    padding: 24px 26px; box-shadow: 0 18px 50px rgba(27, 39, 64, .22);
}
.mhb-notice h2 { margin: 0 0 12px; font-family: Fraunces, Georgia, serif; font-size: 1.2rem; }
.mhb-notice p, .mhb-notice li { line-height: 1.5; font-size: .93rem; }
.mhb-notice ul { padding-left: 20px; margin: 10px 0; }
.mhb-notice li { margin-bottom: 7px; }
.mhb-notice a { color: var(--brass, #B0812B); }
.mhb-notice .mhb-notice-foot { color: var(--muted, #736C5F); font-size: .82rem; }
.mhb-notice-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.mhb-notice-err { color: #8a1c13; margin: 10px 0 0; }

@media (max-width: 720px) {
    .mhb-page { height: calc(100vh - 140px); }
    .mhb-head { flex-wrap: wrap; }
    .mhb-msg { max-width: 94%; }
    .mhb-notice { padding: 18px; }
    .mhb-voice { margin: 10px 12px 0; padding: 10px 12px; gap: 12px; }
    .mhb-mic { width: 64px; height: 64px; }
    .mhb-form { padding: 10px 12px 12px; }
}

/* Pièce jointe (Excel/CSV) */
.mhb-attach { display: grid; place-items: center; width: 44px; flex: 0 0 44px; border: 1px solid var(--line, #E4DFD3);
  border-radius: 12px; background: var(--card-2, #FAF8F3); cursor: pointer; font-size: 18px; user-select: none; }
.mhb-attach:hover { border-color: var(--brass, #B0812B); }
.mhb-attach:focus-within { outline: 2px solid var(--brass-line, rgba(176,129,43,.32)); }

/* Offre gratuite : encart d'import, une ligne en tête de conversation */
.mhb-import { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin: 10px 18px 0; padding: 8px 10px 8px 8px;
  border-radius: 12px; background: var(--brass-soft, #F6EEDC); border: 1px solid var(--brass-line, rgba(176,129,43,.32)); }
.mhb-import-btn { cursor: pointer; white-space: nowrap; font-weight: 600; font-size: .88rem; padding: 7px 12px; border-radius: 9px;
  background: var(--ink, #1B2740); color: #fff; }
.mhb-import-btn:hover { filter: brightness(1.15); }
.mhb-import-txt { font-size: .8rem; color: var(--muted, #6b7280); }
.mhb-import-txt a { color: inherit; text-decoration: underline; }

/* Réponses mises en forme (renderRich, chatbot.js) */
.mhb-bubble.mhb-rich { white-space: normal; }
.mhb-rich p { margin: 0 0 8px; }
.mhb-rich p:last-child, .mhb-rich .mhb-list:last-child { margin-bottom: 0; }
.mhb-rich .mhb-h { font-family: var(--font-display, Georgia, serif); font-weight: 700; font-size: 1.02rem; margin: 10px 0 4px; }
.mhb-rich .mhb-h:first-child { margin-top: 0; }
.mhb-rich .mhb-list { margin: 2px 0 8px; padding: 0; list-style: none; }
.mhb-rich .mhb-list li { position: relative; padding-left: 1.1em; margin: 3px 0; }
.mhb-rich .mhb-list li::before { content: ""; position: absolute; left: .2em; top: .62em; width: .38em; height: .38em;
  border-radius: 50%; background: var(--brass, #B0812B); }
.mhb-rich strong { font-weight: 700; }
