/* ORENIQ UI-01 : interface de connexion et de conversation (sans framework). */
:root {
  --fond: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --texte: #16202e;
  --texte-doux: #5b6778;
  --bordure: #d8dee8;
  --accent: #0f5f73;
  --accent-fort: #0b4a5a;
  --accent-texte: #ffffff;
  --bulle-user: #0f5f73;
  --bulle-user-texte: #ffffff;
  --bulle-ia: #ffffff;
  --erreur-fond: #fdecec;
  --erreur-texte: #8f1d1d;
  --erreur-bord: #f2b8b8;
  --info-fond: #fff6e0;
  --info-texte: #6b4b00;
  --info-bord: #f0d58c;
  --ok-fond: #e8f5ee;
  --ok-texte: #1d5e3a;
  --ok-bord: #a9d8bd;
  --ombre: 0 6px 24px rgba(16, 32, 46, 0.08);
  --rayon: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f141b;
    --surface: #171e27;
    --surface-2: #1e2732;
    --texte: #e6ebf2;
    --texte-doux: #9aa6b6;
    --bordure: #2c3744;
    --accent: #3fa7bf;
    --accent-fort: #6cc0d4;
    --accent-texte: #06222a;
    --bulle-user: #2b7f93;
    --bulle-user-texte: #ffffff;
    --bulle-ia: #1e2732;
    --erreur-fond: #3a1717;
    --erreur-texte: #ffc9c9;
    --erreur-bord: #6b2a2a;
    --info-fond: #33290f;
    --info-texte: #f3dc9b;
    --info-bord: #5e4b1a;
    --ok-fond: #12301f;
    --ok-texte: #b5e6c9;
    --ok-bord: #2c5e41;
    --ombre: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

.visuellement-cache {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.noscript { padding: 24px; text-align: center; }

/* ---------- marque ---------- */
.marque {
  font-weight: 800;
  letter-spacing: 0.18em;
  font-size: 1.6rem;
  color: var(--accent);
}
.marque.petite { font-size: 1.05rem; }
.sous-titre { margin: 0; color: var(--texte-doux); font-size: 0.95rem; }
.discret { color: var(--texte-doux); margin: 0; }

/* ---------- vues ---------- */
.vue { min-height: 100vh; min-height: 100dvh; }
.vue-centre {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 16px; padding: 24px 16px;
}

/* ---------- connexion ---------- */
.carte {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 32px 28px;
  display: flex; flex-direction: column; gap: 8px;
}
.carte h1 { font-size: 1.25rem; margin: 16px 0 4px; }
.carte label { font-weight: 600; font-size: 0.92rem; margin-top: 8px; }
.carte input {
  font: inherit; color: var(--texte);
  background: var(--surface-2);
  border: 1px solid var(--bordure);
  border-radius: 8px;
  padding: 11px 12px;
  width: 100%;
}
.carte input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.carte .btn-principal { margin-top: 18px; width: 100%; }

/* ---------- bandeaux ---------- */
.bandeau {
  border-radius: 8px; padding: 10px 12px; font-size: 0.93rem;
  border: 1px solid var(--erreur-bord); background: var(--erreur-fond); color: var(--erreur-texte);
}
.bandeau.info { border-color: var(--info-bord); background: var(--info-fond); color: var(--info-texte); }
.bandeau.ok { border-color: var(--ok-bord); background: var(--ok-fond); color: var(--ok-texte); }

/* ---------- boutons ---------- */
button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.6; }
.btn-principal {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: var(--accent-texte);
  border: 0; border-radius: 8px; padding: 11px 18px; font-weight: 600;
}
.btn-principal:hover:not(:disabled) { background: var(--accent-fort); }
.btn-secondaire {
  background: transparent; color: var(--texte);
  border: 1px solid var(--bordure); border-radius: 8px; padding: 7px 12px; font-size: 0.9rem;
}
.btn-secondaire:hover:not(:disabled) { background: var(--surface-2); }
button:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- indicateurs de chargement ---------- */
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--bordure); border-top-color: var(--accent);
  animation: tourne 0.8s linear infinite;
}
.spinner.petit { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255, 255, 255, 0.45); border-top-color: currentColor; }
@keyframes tourne { to { transform: rotate(360deg); } }

.points { display: inline-flex; gap: 4px; }
.points span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--texte-doux);
  animation: saut 1s ease-in-out infinite;
}
.points span:nth-child(2) { animation-delay: 0.15s; }
.points span:nth-child(3) { animation-delay: 0.3s; }
@keyframes saut { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

@media (prefers-reduced-motion: reduce) {
  .spinner, .points span { animation-duration: 2.5s; }
}

/* ---------- conversation ---------- */
.vue-chat {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  height: 100vh; height: 100dvh;
}
.vue-chat[hidden] { display: none !important; }

.entete {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}
.entete-marque { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.entete-utilisateur { display: flex; align-items: center; gap: 10px; min-width: 0; }
.utilisateur { display: flex; align-items: center; gap: 8px; min-width: 0; }
.utilisateur-email {
  font-size: 0.92rem; color: var(--texte-doux);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw;
}
.badge {
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--accent); border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px;
}

.bandeau-ia { margin: 10px 16px 0; border-radius: 8px; }

.historique {
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.message {
  max-width: min(720px, 86%);
  padding: 10px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: var(--ombre);
}
.message .heure { display: block; margin-top: 4px; font-size: 0.72rem; opacity: 0.7; }
.message.utilisateur {
  align-self: flex-end;
  background: var(--bulle-user); color: var(--bulle-user-texte);
  border-bottom-right-radius: 4px;
}
.message.assistant {
  align-self: flex-start;
  background: var(--bulle-ia); color: var(--texte);
  border: 1px solid var(--bordure);
  border-bottom-left-radius: 4px;
}
.message.desactive { border-left: 4px solid var(--info-bord); }
.message.systeme {
  align-self: center; box-shadow: none;
  background: var(--erreur-fond); color: var(--erreur-texte); border: 1px solid var(--erreur-bord);
  font-size: 0.9rem;
}
.message.attente { padding: 14px 16px; }

.saisie {
  display: flex; align-items: flex-end; gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--bordure);
}
.saisie textarea {
  flex: 1;
  font: inherit; color: var(--texte);
  background: var(--surface-2);
  border: 1px solid var(--bordure); border-radius: 10px;
  padding: 10px 12px;
  resize: none;
  max-height: 200px;
  line-height: 1.4;
}

/* ---------- mobile ---------- */
@media (max-width: 600px) {
  .carte { padding: 24px 18px; }
  .entete { padding: 8px 12px; }
  .entete .sous-titre { display: none; }
  .utilisateur-email { max-width: 38vw; font-size: 0.85rem; }
  .badge { display: none; }
  .bandeau-ia { margin: 8px 12px 0; font-size: 0.85rem; }
  .historique { padding: 12px; }
  .message { max-width: 92%; }
  .saisie { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .saisie textarea { font-size: 16px; }
}
