/* Loki : l'application web. Mobile d'abord, thème clair ou sombre selon le téléphone. */
:root {
  --fond: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #eef1ee;
  --texte: #1c2521;
  --texte-2: #5d6b64;
  --bordure: #dde3df;
  --accent: #0f766e;
  --accent-texte: #ffffff;
  --moi: #0f766e;
  --moi-texte: #ffffff;
  --erreur: #b42318;
  --rayon: 14px;
  --ombre: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 16px rgb(0 0 0 / 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fond: #0f1412;
    --surface: #182019;
    --surface-2: #212b25;
    --texte: #e7ece9;
    --texte-2: #9aa8a1;
    --bordure: #2c3831;
    --accent: #2dd4bf;
    --accent-texte: #06231f;
    --moi: #115e59;
    --moi-texte: #e6fffb;
    --erreur: #f97066;
    --ombre: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  background: var(--surface);
  font-size: 16px; /* pas de zoom automatique sur iPhone */
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
label { display: block; font-size: 14px; color: var(--texte-2); margin-bottom: 6px; }

.principal {
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-texte);
  font-weight: 600;
}
.secondaire {
  padding: 12px 16px;
  border: 1px solid var(--bordure);
  border-radius: 10px;
  background: var(--surface);
  font-weight: 600;
}
.discret { border: 0; background: none; color: var(--texte-2); font-size: 14px; padding: 8px; }
.erreur { color: var(--erreur); min-height: 1.4em; margin: 10px 0 0; font-size: 14px; }

/* Connexion */
.ecran { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.carte-connexion {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--bordure);
  border-radius: 20px;
  padding: 28px 22px;
  box-shadow: var(--ombre);
  display: grid;
  gap: 10px;
}
.carte-connexion .logo { justify-self: center; }
.carte-connexion h1 { margin: 0; text-align: center; font-size: 26px; }
.sous-titre { margin: 0 0 8px; text-align: center; color: var(--texte-2); }

/* Application */
.app { height: 100%; display: flex; flex-direction: column; }
.entete {
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--bordure);
}
.entete h1 { font-size: 19px; margin: 0; flex: 1; }
.contenu { flex: 1; min-height: 0; display: flex; }
.vue { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; width: 100%; max-width: 720px; margin: 0 auto; }

/* Chat */
.vue-chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.fil { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.bulle { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bulle .qui { display: block; font-size: 13px; font-weight: 600; color: var(--texte-2); margin-bottom: 2px; }
.bulle .quand { display: block; font-size: 12px; opacity: 0.7; margin-top: 4px; }
.bulle.agent { align-self: flex-start; background: var(--surface); border: 1px solid var(--bordure); border-bottom-left-radius: 6px; }
.bulle.moi { align-self: flex-end; background: var(--moi); color: var(--moi-texte); border-bottom-right-radius: 6px; }
.bulle.moi .quand { text-align: right; }
.bulle.systeme { align-self: center; background: var(--surface-2); color: var(--texte-2); font-size: 14px; }
.bulle.attente { align-self: flex-start; background: var(--surface); border: 1px solid var(--bordure); color: var(--texte-2); }
.vide { margin: auto; text-align: center; color: var(--texte-2); padding: 24px; }

.suggestions { display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 8px; scrollbar-width: none; }
.suggestions button {
  flex: none; border: 1px solid var(--bordure); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 14px;
}
.saisie {
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 12px;
  background: var(--surface);
  border-top: 1px solid var(--bordure);
}
.saisie textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 14px; }
.envoyer {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--accent-texte); font-size: 20px; font-weight: 700;
}
.envoyer:disabled { opacity: 0.5; }

/* Journal */
.filtre { display: flex; gap: 8px; margin-bottom: 14px; }
.journal { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.journal li { background: var(--surface); border: 1px solid var(--bordure); border-radius: 12px; padding: 10px 12px; }
.journal .meta { display: flex; flex-wrap: wrap; gap: 6px 10px; font-size: 13px; color: var(--texte-2); margin-bottom: 4px; }
.journal .type { background: var(--surface-2); border-radius: 6px; padding: 0 6px; }
.journal .texte { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Onglets */
.onglets {
  display: grid; grid-template-columns: repeat(2, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--bordure);
  padding-bottom: env(safe-area-inset-bottom);
}
.onglets button {
  border: 0; background: none; padding: 8px 4px 10px;
  display: grid; justify-items: center; gap: 2px;
  font-size: 12px; color: var(--texte-2);
}
.onglets button span { font-size: 20px; }
.onglets button[aria-current="page"] { color: var(--accent); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100% - 32px);
  background: var(--texte); color: var(--fond);
  padding: 10px 16px; border-radius: 12px; font-size: 14px;
  box-shadow: var(--ombre);
}
