/* Assistant REGINE (lot A1) : panneau latéral. Charte : #1A365D, #00C8FF, #40E0D0 ; textes ≥ 4,5:1 ; cibles ≥ 40 px. */
:root { --assistant-largeur: 400px; }

.assistant-ic { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.assistant-declencheur { display: inline-flex; align-items: center; gap: .5rem; min-height: 40px; min-width: 40px; justify-content: center; padding: 0 .75rem;
    border-radius: .5rem; background: #1A365D; color: #fff; font-size: .875rem; font-weight: 600; }
.assistant-declencheur:hover { background: #12263F; }
.assistant-declencheur[aria-expanded="true"] { background: #00C8FF; color: #1A365D; }
.assistant-kbd { font: 500 11px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 2px 6px; border-radius: 4px; background: rgba(255, 255, 255, .2); }
.assistant-declencheur[aria-expanded="true"] .assistant-kbd { background: rgba(26, 54, 93, .15); }
.assistant-declencheur:focus-visible, .assistant-panneau :focus-visible { outline: 2px solid #00C8FF; outline-offset: 2px; }

/* Panneau : pousse le contenu (≥ 900 px), superposé en dessous */
.assistant-panneau { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: var(--assistant-largeur); max-width: 100vw;
    display: flex; flex-direction: column; background: #fff; border-left: 1px solid #e5e7eb; color: #1f2937; font-size: .875rem; }
.assistant-panneau[hidden] { display: none; }
@media (min-width: 900px) {
    body.assistant-ouvert > main { margin-right: var(--assistant-largeur); }
}
@media (max-width: 899.98px) {
    .assistant-panneau { width: min(100vw, 420px); box-shadow: -12px 0 32px rgba(15, 23, 42, .25); z-index: 60; }
}

/* Fenêtre flottante : déplaçable par son en-tête, redimensionnable par les coins bas droit et haut gauche ; le contenu de la page n'est plus poussé */
.assistant-panneau.flottant { top: var(--assistant-y, 80px); left: var(--assistant-x, calc(100vw - 460px)); right: auto; bottom: auto;
    width: 420px; height: min(640px, calc(100vh - 32px)); min-width: 320px; min-height: 320px; max-height: calc(100vh - 16px);
    border: 1px solid #d1d5db; border-radius: .75rem; box-shadow: 0 18px 48px rgba(15, 23, 42, .3); overflow: hidden; z-index: 60; }
.assistant-panneau.flottant .assistant-entete { cursor: move; user-select: none; }
.assistant-poignee { display: none; position: absolute; right: 0; bottom: 0; width: 22px; height: 22px; cursor: nwse-resize; touch-action: none; z-index: 2;
    background: linear-gradient(135deg, transparent 0 45%, #9ca3af 45% 52%, transparent 52% 64%, #9ca3af 64% 71%, transparent 71% 83%, #9ca3af 83% 90%, transparent 90%); }
.assistant-poignee.haut { right: auto; bottom: auto; left: 0; top: 0; transform: rotate(180deg); }
.assistant-panneau.flottant .assistant-poignee { display: block; }
body.assistant-ouvert.assistant-flottant > main { margin-right: 0; }

.assistant-entete { display: flex; align-items: center; gap: .5rem; padding: .75rem 1rem; border-bottom: 1px solid #e5e7eb; }
/* Avatar « Étincelle » : états repos, reflechit (outil en cours), parle (texte reçu), erreur — data-etat du panneau */
.assistant-avatar { flex-shrink: 0; overflow: visible; }
.assistant-avatar * { transform-box: fill-box; transform-origin: center; }
.av-etoile { fill: #00C8FF; stroke: #1A365D; stroke-width: 6; stroke-linejoin: round; }
.av-blanc { fill: #fff; stroke: #1A365D; stroke-width: 3; }
.av-pupille, .av-bouche, .av-goutte { fill: #1A365D; }
.av-reflet { fill: #fff; }
.av-joue { fill: #FF8FB1; opacity: .8; }
.av-mini { fill: #40E0D0; stroke: #1A365D; stroke-width: 2; }
.av-pensee circle { fill: #1A365D; opacity: 0; }
.av-goutte { opacity: 0; transition: opacity .3s; }
.av-regard { transition: transform .3s; }
.av-corps { animation: av-tourne 6s ease-in-out infinite; }
.av-oeil { animation: av-cligne 4.5s infinite; }
.av-mini { animation: av-scintille 2.4s ease-in-out infinite; }
/* Réflexion : l'étoile tourne sur elle-même ; le panneau (frontend/src/assistant/Panel.tsx) retire la classe en fin de tour (retour en position droite) */
.assistant-avatar.av-en-rotation .av-corps { animation: av-tour 1.2s linear infinite; }
.assistant-panneau[data-etat="reflechit"] .av-regard { transform: translate(-3px, -4px); }
.assistant-panneau[data-etat="reflechit"] .av-pensee circle { animation: av-point 1.2s infinite; }
.assistant-panneau[data-etat="reflechit"] .av-pensee circle:nth-child(2) { animation-delay: .2s; }
.assistant-panneau[data-etat="reflechit"] .av-pensee circle:nth-child(3) { animation-delay: .4s; }
.assistant-panneau[data-etat="parle"] .av-bouche { animation: av-parle .22s infinite alternate; }
.assistant-panneau[data-etat="erreur"] .av-corps { animation: av-secoue .5s 2; }
.assistant-panneau[data-etat="erreur"] .av-bouche { transform: scaleY(.4); }
.assistant-panneau[data-etat="erreur"] .av-goutte { opacity: 1; }
@keyframes av-tourne { 50% { transform: rotate(7deg); } }
@keyframes av-tour { to { transform: rotate(360deg); } }
@keyframes av-cligne { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes av-scintille { 50% { transform: scale(.6) rotate(45deg); } }
@keyframes av-point { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }
@keyframes av-parle { to { transform: scaleY(2.4); } }
@keyframes av-secoue { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .assistant-avatar * { animation: none !important; transition: none !important; } }
.assistant-titre { font-family: 'Poppins', ui-sans-serif, system-ui, sans-serif; font-size: 1rem; font-weight: 600; color: #1A365D; margin: 0; }
.assistant-beta { font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; background: #e0f7fb; color: #1A365D; }
.assistant-icone { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 6px; color: #4b5563; background: transparent; }
.assistant-icone:hover { background: #f1f5f9; color: #1A365D; }
.assistant-icone[aria-pressed="true"] { background: #e0f7fb; color: #1A365D; }

.assistant-contexte { display: flex; flex-wrap: wrap; align-items: center; gap: .375rem; padding: .625rem 1rem; border-bottom: 1px solid #e5e7eb; background: #f8fafc; }
.assistant-contexte-titre { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: #4b5563; margin-right: .25rem; }
.assistant-contexte-vide { font-size: 12px; color: #4b5563; }
.assistant-pastille { display: inline-flex; align-items: center; gap: .25rem; padding-left: .625rem; border: 1px solid #cbd5e1; border-radius: 999px; background: #fff; font-size: 12px; color: #1A365D; }
.assistant-pastille button { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; margin: -8px -6px -8px -8px; border-radius: 999px; color: #4b5563; }
.assistant-pastille button:hover { color: #b91c1c; }

.assistant-fil { flex: 1 1 auto; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 1rem; }
.assistant-accueil { color: #4b5563; }
.assistant-question { align-self: flex-end; max-width: 90%; padding: .625rem .875rem; border-radius: .75rem .75rem .25rem .75rem; background: #1A365D; color: #fff; white-space: pre-wrap; }
.assistant-reponse { display: flex; flex-direction: column; gap: .75rem; }
.assistant-texte { line-height: 1.55; }
.assistant-texte p { margin: 0 0 .5rem; } .assistant-texte p:last-child { margin-bottom: 0; }
.assistant-texte ol, .assistant-texte ul { margin: 0 0 .5rem 1.25rem; } .assistant-texte ol { list-style: decimal; } .assistant-texte ul { list-style: disc; }
.assistant-texte code { font: 600 .8rem ui-monospace, SFMono-Regular, Menlo, monospace; color: #1A365D; }
.assistant-texte a { color: #1d4ed8; text-decoration: underline; }
.assistant-etapes-bouton { display: inline-flex; align-items: center; gap: .375rem; min-height: 40px; padding: 0 .5rem; margin-left: -.5rem; border-radius: 6px; color: #4b5563; font-size: 12px; }
.assistant-etapes-bouton:hover { background: #f1f5f9; }
.assistant-moteur { margin: 0 0 .25rem; font-size: 11px; color: #6b7280; }
.assistant-moteur-ue { color: #166534; }
.assistant-moteur-hors-ue { color: #92400e; }
.assistant-etapes { margin: 0; padding-left: 1.25rem; list-style: decimal; font-size: 12px; color: #374151; }
.assistant-etapes li { padding: .125rem 0; }
.assistant-mono { font: 500 12px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; }
.assistant-erreur { padding: .625rem .875rem; border: 1px solid #fecaca; border-radius: .5rem; background: #fef2f2; color: #991b1b; }

/* Cartes */
.assistant-carte { border: 1px solid #e5e7eb; border-radius: .625rem; background: #fff; overflow: hidden; }
.assistant-carte-entete { display: flex; align-items: center; gap: .5rem; padding: .625rem .875rem; background: #f8fafc; border-bottom: 1px solid #e5e7eb; }
.assistant-carte-code { font: 600 13px ui-monospace, SFMono-Regular, Menlo, monospace; color: #1A365D; }
.assistant-carte-type { font-size: 11px; color: #4b5563; }
.assistant-carte-total { margin-left: auto; font: 600 14px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; color: #1A365D; }
.assistant-factice { font-size: 11px; font-weight: 600; padding: 1px 6px; border-radius: 4px; background: #fef3c7; color: #78350f; }
.assistant-lignes { padding: .25rem 0; }
.assistant-ligne { display: grid; grid-template-columns: 1.25rem minmax(0, 1fr) auto auto; align-items: center; gap: .5rem; padding: .375rem .875rem; font-size: 12px; }
.assistant-ligne .signe { font: 700 13px ui-monospace, monospace; text-align: center; }
.assistant-ligne .signe-plus { color: #047857; } .assistant-ligne .signe-moins { color: #b91c1c; } .assistant-ligne .signe-nul { color: #4b5563; }
.assistant-ligne .code { overflow-wrap: anywhere; }
.assistant-ligne .montant { font: 500 12px ui-monospace, monospace; font-variant-numeric: tabular-nums; text-align: right; }
.assistant-ligne.exoneree { color: #4b5563; }
.assistant-ligne.imbriquee { padding-left: 2rem; color: #374151; }
.assistant-carte-libelle { padding: .375rem .875rem 0; font-size: 12px; color: #374151; }
.assistant-formule { padding: .375rem .875rem; font-size: 11px; color: #1f2937; overflow-wrap: anywhere; border-bottom: 1px solid #f1f5f9; }
.assistant-carte-erreur { padding: .375rem .875rem; font-size: 12px; color: #b91c1c; }
.assistant-ligne.exoneree .montant { text-decoration: line-through; }
.assistant-niveau { font-size: 10px; font-weight: 600; padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.assistant-niveau-NOYAU { background: #e5e7eb; color: #1f2937; }
.assistant-niveau-PAYS { background: #dbeafe; color: #1e3a8a; }
.assistant-niveau-SECTEUR { background: #ccfbf1; color: #134e4a; }
.assistant-niveau-SOCIETE { background: #ede9fe; color: #4c1d95; }
.assistant-niveau-ETABLISSEMENT { background: #fce7f3; color: #831843; }
.assistant-carte-pied { display: flex; align-items: center; gap: .75rem; padding: .5rem .875rem; border-top: 1px solid #e5e7eb; font-size: 12px; color: #4b5563; }
.assistant-source { display: flex; gap: .75rem; padding: .75rem .875rem; }
.assistant-source-titre { font-weight: 600; color: #1A365D; }
.assistant-source a, .assistant-carte-pied a { display: inline-flex; align-items: center; min-height: 40px; color: #1d4ed8; text-decoration: underline; }
.assistant-apercu { width: 100%; border-collapse: collapse; font-size: 12px; }
.assistant-apercu th, .assistant-apercu td { padding: .375rem .875rem; text-align: left; border-top: 1px solid #f1f5f9; }
.assistant-apercu td { white-space: nowrap; }
.assistant-documents { margin: .25rem 0 0 1.1rem; list-style: disc; font-size: 12px; color: #374151; }
.assistant-apercu th { font-weight: 600; color: #4b5563; }
.assistant-bouton { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 .875rem; border-radius: .5rem; font-weight: 600; font-size: .8125rem; }
.assistant-bouton-primaire { background: #1A365D; color: #fff; }
.assistant-bouton-primaire:disabled { background: #e5e7eb; color: #4b5563; cursor: not-allowed; }
.assistant-bouton-neutre { border: 1px solid #cbd5e1; background: #fff; color: #1f2937; }
.assistant-bouton-neutre:hover { background: #f8fafc; }

.assistant-retours { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem; }
.assistant-signalement { display: flex; flex-direction: column; gap: .375rem; width: 100%; }
.assistant-signalement textarea, .assistant-saisie textarea { width: 100%; padding: .5rem .625rem; border: 1px solid #cbd5e1; border-radius: .5rem; font: inherit; resize: vertical; }
.assistant-merci { font-size: 12px; color: #047857; }

.assistant-saisie { padding: .75rem 1rem 1rem; border-top: 1px solid #e5e7eb; }
.assistant-label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: .375rem; }
.assistant-saisie-ligne { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
#assistant-question { min-height: 5rem; max-height: 14rem; overflow-y: auto; line-height: 1.45; }
.assistant-saisie textarea:focus { outline: none; border-color: #00C8FF; box-shadow: 0 0 0 2px #00C8FF; }
.assistant-envoyer { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: .5rem; background: #1A365D; color: #fff; flex-shrink: 0; }
.assistant-envoyer:disabled { background: #e5e7eb; color: #4b5563; }
/* Dictée (lot R4) : micro à côté de l'envoi, point rouge pendant l'enregistrement */
.assistant-micro { display: inline-flex; align-items: center; justify-content: center; gap: .375rem; min-width: 44px; height: 44px; padding: 0 .75rem; border-radius: .5rem; border: 1px solid #1A365D; background: #eef6ff; color: #1A365D; font-size: .8125rem; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.assistant-micro:hover { border-color: #00C8FF; background: #e0f7ff; }
.assistant-micro:focus-visible { outline: 2px solid #00C8FF; outline-offset: 2px; }
.assistant-micro:disabled { color: #6b7280; border-color: #cbd5e1; background: #f8fafc; }
.assistant-micro.enregistre { background: #b91c1c; border-color: #b91c1c; color: #fff; animation: assistant-micro-anneau 1.4s ease-out infinite; }
@keyframes assistant-micro-anneau { 0% { box-shadow: 0 0 0 0 rgba(185, 28, 28, .55); } 100% { box-shadow: 0 0 0 10px rgba(185, 28, 28, 0); } }
.assistant-dictee { margin: .375rem 0 0; font-size: .8125rem; color: #374151; display: flex; align-items: center; gap: .5rem; }
.assistant-dictee.erreur { color: #b91c1c; }
.assistant-dictee.ecoute { padding: .5rem .75rem; border-radius: .5rem; background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; font-size: .875rem; }
.assistant-dictee-temps { margin-left: auto; font-variant-numeric: tabular-nums; }
.assistant-dictee-point { width: .625rem; height: .625rem; border-radius: 50%; background: #b91c1c; flex-shrink: 0; animation: assistant-dictee-pulse 1s ease-in-out infinite; }
@keyframes assistant-dictee-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { .assistant-dictee-point, .assistant-micro.enregistre { animation: none; } }
.assistant-mention { margin: .5rem 0 0; font-size: 11px; color: #4b5563; }

/* Bouton ✦ « Expliquer » des lignes du bulletin */
.assistant-expliquer { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 6px; color: #4b5563; }
.assistant-expliquer:hover, .assistant-expliquer[aria-pressed="true"] { background: #e0f7fb; color: #1A365D; }
tr.assistant-ligne-selectionnee { background: #e0f7fb; }

/* Demande à l'équipe REGINE (remontées des key users, lot R1) : carte de relecture et « Mes demandes » */
.assistant-demande { display: flex; flex-direction: column; gap: .5rem; }
.assistant-demande .assistant-label { margin-bottom: .125rem; }
.assistant-demande input, .assistant-demande select, .assistant-demande textarea { width: 100%; padding: .375rem .5rem; border: 1px solid #cbd5e1; border-radius: .5rem; font: inherit; font-size: 13px; background: #fff; }
.assistant-demande textarea { resize: vertical; }
.assistant-demande :is(input, select, textarea):focus { outline: none; border-color: #00C8FF; box-shadow: 0 0 0 2px #00C8FF; }
.assistant-demande :is(input, select, textarea):disabled { background: #f8fafc; color: #4b5563; }
.assistant-demande-ligne { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.assistant-avertissement { font-size: 12px; color: #92400e; background: #fffbeb; border: 1px solid #fde68a; border-radius: .5rem; padding: .375rem .5rem; }
.assistant-verbatim { margin: 0; padding-left: .625rem; border-left: 3px solid #cbd5e1; font-size: 12px; color: #374151; white-space: pre-wrap; }
.assistant-mes-demandes { padding: .5rem 1rem; border-bottom: 1px solid #e5e7eb; font-size: 12px; max-height: 40%; overflow: auto; }
.assistant-mes-demandes ul { margin: 0; padding: 0; list-style: none; }
.assistant-mes-demandes li { display: flex; flex-wrap: wrap; gap: .25rem .5rem; padding: .25rem 0; border-top: 1px solid #f1f5f9; }
.assistant-mes-demandes-commentaire { flex-basis: 100%; color: #475569; white-space: pre-wrap; }

/* Onglets du panneau (refonte des remontées, 15/10/2026) : Poser une question | Signaler / demander | Mes demandes */
.assistant-onglets { display: flex; border-bottom: 1px solid #e5e7eb; padding: 0 .5rem; gap: .25rem; }
.assistant-onglet { flex: 1 1 0; min-height: 40px; padding: .25rem .5rem; font-size: 12.5px; font-weight: 600; color: #475569; border-bottom: 3px solid transparent; }
.assistant-onglet:hover { color: #1A365D; }
.assistant-onglet[aria-selected="true"] { color: #1A365D; border-bottom-color: #00C8FF; }
.assistant-onglet-contenu { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.assistant-onglet-contenu[hidden] { display: none; }
.assistant-onglet-texte { padding: 1rem; gap: .75rem; overflow-y: auto; }
.assistant-onglet-texte.assistant-mes-demandes { max-height: none; border-bottom: 0; }
.assistant-escalade { align-self: flex-start; }
.assistant-aide { font-size: 12px; color: #4b5563; margin-top: .25rem; }

/* Fenêtre « Signaler / demander » : dialogue modal natif, large, au-dessus de la page */
.assistant-dialogue { width: min(720px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); padding: 0; border: 0; border-radius: .75rem;
    box-shadow: 0 24px 64px rgba(15, 23, 42, .35); color: #1f2937; font-size: .875rem; overflow: auto; }
.assistant-dialogue::backdrop { background: rgba(15, 23, 42, .45); }
.assistant-dialogue :focus-visible { outline: 2px solid #00C8FF; outline-offset: 2px; }
.assistant-dialogue-entete { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    padding: .75rem 1.25rem; background: #fff; border-bottom: 1px solid #e5e7eb; }
.assistant-dialogue-entete h2 { font-size: 1rem; font-weight: 700; color: #1A365D; }
.assistant-dialogue-corps { padding: 1rem 1.25rem 1.25rem; gap: .875rem; }
.assistant-dialogue .assistant-demande textarea { resize: vertical; min-height: 10rem; }
.assistant-tuiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; border: 0; padding: 0; margin: 0; }
.assistant-tuiles legend { grid-column: 1 / -1; }
.assistant-tuile { position: relative; display: flex; flex-direction: column; gap: .125rem; padding: .625rem .75rem; border: 1px solid #cbd5e1; border-radius: .5rem; cursor: pointer; }
.assistant-tuile input { position: absolute; opacity: 0; pointer-events: none; }
.assistant-tuile:has(input:focus-visible) { outline: 2px solid #00C8FF; outline-offset: 2px; }
.assistant-tuile.choisie { border-color: #1A365D; background: #eef6fb; box-shadow: inset 0 0 0 1px #1A365D; }
.assistant-tuile-titre { font-weight: 700; color: #1A365D; }
.assistant-tuile-aide { font-size: 12px; color: #4b5563; }
.assistant-depot { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .75rem; padding: .75rem; border: 2px dashed #cbd5e1; border-radius: .5rem; font-size: 12px; color: #4b5563; }
.assistant-depot.survol { border-color: #00C8FF; background: #f0fbff; }
.assistant-depot p { flex: 1 1 16rem; margin: 0; }
.assistant-miniatures { display: flex; flex-wrap: wrap; gap: .5rem; margin: 0; padding: 0; list-style: none; flex-basis: 100%; }
.assistant-miniatures li { position: relative; }
.assistant-miniatures img { display: block; width: 128px; height: 80px; object-fit: cover; border: 1px solid #cbd5e1; border-radius: .375rem; }
.assistant-miniatures button { position: absolute; top: 2px; right: 2px; width: 28px; height: 28px; background: #fff; border-radius: 999px; }
.assistant-apercu-demande { display: flex; flex-direction: column; gap: .625rem; padding: .75rem; background: #f8fafc; border: 1px solid #e5e7eb; border-radius: .5rem; }
.assistant-apercu-demande h3 { font-weight: 700; color: #1A365D; }
.assistant-apercu-demande p { white-space: pre-wrap; }
@media (max-width: 599.98px) {
    .assistant-tuiles, .assistant-dialogue .assistant-demande-ligne { grid-template-columns: 1fr; }
}
