/* Assistant IA NafaTicket (web + mobile : gardez ce fichier identique dans NafaTicket.Mobile/wwwroot/css) */
:root {
    --nax-grad: linear-gradient(135deg, #7C3AED 0%, #C026D3 60%, #EC4899 100%);
    --nax-ink: #1a0636;
    --nax-muted: #6b7280;
    --nax-line: #ece7f7;
    --nax-bot: #f4f0fb;
}

/* ── Bulle flottante ── */
.nax-fab {
    position: fixed;
    right: 20px;
    bottom: calc(92px + env(safe-area-inset-bottom, 0px));
    z-index: 1000;
    height: 56px;
    min-width: 56px;
    padding: 0 18px 0 16px;
    border: 0;
    border-radius: 28px;
    background: var(--nax-grad);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: 700 .92rem/1 'DM Sans', sans-serif;
    box-shadow: 0 8px 26px rgba(124, 58, 237, .45);
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease;
    -webkit-tap-highlight-color: transparent;
}
.nax-fab i { font-size: 1.35rem; }
.nax-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(124, 58, 237, .55); }
.nax-fab:active { transform: scale(.96); }
.nax-fab:focus-visible, .nax-icon-btn:focus-visible, .nax-mic:focus-visible, .nax-send:focus-visible, .nax-chip:focus-visible {
    outline: 3px solid #fbbf24;
    outline-offset: 2px;
}
/* Sur téléphone la bulle se réduit à l'icône pour ne pas masquer le contenu */
@media (max-width: 576px) {
    .nax-fab { right: 14px; padding: 0; width: 54px; height: 54px; border-radius: 50%; }
    .nax-fab-label { display: none; }
}

/* ── Panneau ── */
.nax-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 2100;
    width: 392px;
    max-width: calc(100vw - 32px);
    height: min(640px, calc(100dvh - 48px));
    display: flex;
    flex-direction: column;
    background: #fff;
    color: var(--nax-ink);
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(26, 6, 54, .32), 0 0 0 1px rgba(124, 58, 237, .08);
    animation: naxIn .22s ease-out;
}
@keyframes naxIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

/* Téléphone : plein écran, hauteur = zone réellement visible (clavier ouvert compris) */
@media (max-width: 576px) {
    .nax-panel {
        top: var(--nax-top, 0px);
        left: 0;
        right: 0;
        bottom: auto;
        width: 100%;
        max-width: none;
        height: var(--nax-vh, 100dvh);
        border-radius: 0;
        box-shadow: none;
        animation: naxSheet .24s ease-out;
    }
    @keyframes naxSheet { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
}

.nax-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 12px 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    background: var(--nax-grad);
    color: #fff;
}
@media (min-width: 577px) { .nax-head { padding-top: 14px; } }
.nax-avatar {
    flex: 0 0 auto;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    margin-right: 6px;
}
.nax-head-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.nax-head-txt strong { font-size: 1.02rem; }
.nax-head-txt span { font-size: .78rem; opacity: .92; display: flex; align-items: center; gap: 6px; }
.nax-dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 3px rgba(74, 222, 128, .28); display: inline-block; }
.nax-icon-btn {
    flex: 0 0 auto;
    width: 36px; height: 36px;
    border: 0; border-radius: 50%;
    background: transparent; color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.05rem; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.nax-icon-btn:hover, .nax-icon-btn.on { background: rgba(255, 255, 255, .22); }

/* ── Messages ── */
.nax-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}
.nax-msg { display: flex; }
.nax-msg.nax-user { justify-content: flex-end; }
.nax-bubble {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: .93rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.nax-bot .nax-bubble { background: var(--nax-bot); color: var(--nax-ink); border-bottom-left-radius: 6px; }
.nax-user .nax-bubble { background: var(--nax-grad); color: #fff; border-bottom-right-radius: 6px; }
.nax-bubble.nax-error { background: #fef2f2; color: #991b1b; }
.nax-bubble p { margin: 0 0 6px; }
.nax-bubble p:last-child { margin-bottom: 0; }
.nax-bubble ul { margin: 4px 0 6px; padding-left: 18px; }
.nax-bubble li { margin-bottom: 2px; }
.nax-bubble a { color: #6d28d9; font-weight: 700; text-decoration: underline; }
.nax-bubble strong { font-weight: 700; }

.nax-typing { display: flex; gap: 5px; align-items: center; padding: 14px 16px; }
.nax-typing i { width: 7px; height: 7px; border-radius: 50%; background: #a78bfa; animation: naxBounce 1.1s infinite ease-in-out; }
.nax-typing i:nth-child(2) { animation-delay: .15s; }
.nax-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes naxBounce { 0%, 80%, 100% { transform: translateY(0); opacity: .5; } 40% { transform: translateY(-5px); opacity: 1; } }

.nax-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.nax-chip {
    border: 1.5px solid #ddd0f7;
    background: #fff;
    color: #5b21b6;
    border-radius: 999px;
    padding: 8px 14px;
    font: 600 .85rem/1.2 'DM Sans', sans-serif;
    cursor: pointer;
    text-align: left;
    transition: background .15s, border-color .15s;
    -webkit-tap-highlight-color: transparent;
}
.nax-chip:hover { background: #f5f0ff; border-color: #a78bfa; }

/* ── Saisie ── */
.nax-foot {
    flex: 0 0 auto;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--nax-line);
}
.nax-listening {
    display: flex; align-items: center; gap: 8px;
    font-size: .82rem; font-weight: 600; color: #b91c1c;
    padding: 0 4px 8px;
}
.nax-listening i { animation: naxPulse 1s infinite; }
@keyframes naxPulse { 50% { opacity: .35; } }
.nax-form { display: flex; align-items: center; gap: 8px; margin: 0; }
.nax-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 44px;
    border: 1.5px solid var(--nax-line);
    border-radius: 22px;
    padding: 0 16px;
    font: 400 16px/1 'DM Sans', sans-serif; /* 16 px : évite le zoom automatique d'iOS */
    color: var(--nax-ink);
    background: #faf8ff;
    outline: none;
}
.nax-input:focus { border-color: #a78bfa; background: #fff; }
.nax-mic, .nax-send {
    flex: 0 0 auto;
    width: 44px; height: 44px;
    border: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.nax-mic { background: #f1ebfd; color: #6d28d9; }
.nax-mic.on { background: #dc2626; color: #fff; animation: naxPulse 1s infinite; }
.nax-send { background: var(--nax-grad); color: #fff; }
.nax-send:disabled { opacity: .45; cursor: default; }
.nax-legal { margin: 8px 4px 0; font-size: .7rem; line-height: 1.35; color: var(--nax-muted); text-align: center; }
.nax-legal a { color: #6d28d9; font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
    .nax-panel, .nax-typing i, .nax-mic.on, .nax-listening i { animation: none; }
    .nax-fab { transition: none; }
}

/* Lecture vocale de la réponse */
.nax-speaking { color: #6d28d9; }
.nax-stop {
    margin-left: auto;
    border: 1.5px solid #ddd0f7;
    background: #fff;
    color: #6d28d9;
    border-radius: 999px;
    padding: 4px 12px;
    font: 700 .78rem/1 'DM Sans', sans-serif;
    cursor: pointer;
}
