/* Console CCAS — utilisable sur un poste de mairie comme sur une tablette
   en visite à domicile. Contrastes élevés, cibles tactiles généreuses. */

:root {
  --encre: #14202e;
  --encre-douce: #5b6b7c;
  --fond: #f4f6f8;
  --carte: #ffffff;
  --trait: #d9e0e7;
  --bleu: #1b5fa8;
  --bleu-clair: #e8f0fa;
  --vert: #1f7a4d;
  --vert-clair: #e6f4ec;
  --orange: #a35a06;
  --orange-clair: #fdf0e0;
  --rouge: #b3261e;
  --rouge-clair: #fce9e7;
  --rayon: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--encre);
  background: var(--fond);
}

/* ---------- En-tête ---------- */

header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--carte);
  border-bottom: 1px solid var(--trait);
  position: sticky;
  top: 0;
  z-index: 10;
}

.marque {
  font-weight: 700;
  font-size: 19px;
  color: var(--bleu);
  text-decoration: none;
  letter-spacing: -0.01em;
}

header nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }

header nav a {
  padding: 8px 14px;
  border-radius: var(--rayon);
  color: var(--encre-douce);
  text-decoration: none;
  font-weight: 500;
}

header nav a:hover { background: var(--bleu-clair); color: var(--bleu); }

.direct { color: var(--trait); font-size: 26px; line-height: 1; }
.direct.actif { color: var(--vert); }

.agent {
  font-size: 14px;
  color: var(--encre-douce);
  white-space: nowrap;
}
.agent a {
  margin-left: 10px;
  color: var(--bleu);
  text-decoration: none;
  font-weight: 500;
}
.agent a:hover { text-decoration: underline; }

/* ---------- Écran de connexion ---------- */

.page-connexion { background: var(--fond); }

.connexion {
  max-width: 400px;
  margin: 8vh auto;
  padding: 32px;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
}

.connexion h1 {
  margin: 0;
  font-size: 26px;
  color: var(--bleu);
  letter-spacing: -0.02em;
}
.connexion > .aide { margin: 2px 0 24px; }
.connexion button.principal { width: 100%; }
.connexion .mention { margin-top: 24px; font-size: 13px; line-height: 1.5; }

.erreur {
  background: var(--rouge-clair);
  color: var(--rouge);
  border-left: 4px solid var(--rouge);
  border-radius: 0 8px 8px 0;
  padding: 11px 14px;
  margin: 0 0 20px;
  font-size: 14px;
  font-weight: 500;
}

.bouton-sso {
  display: block;
  text-align: center;
  padding: 13px 16px;
  border-radius: 8px;
  background: var(--bleu);
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}
.bouton-sso:hover { background: #17518f; }

.separateur {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--encre-douce);
  font-size: 13px;
  margin: 20px 0;
}
.separateur::before, .separateur::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--trait);
}

/* Impossible à confondre avec la production : un délai de deux minutes laissé
   par mégarde noierait les agents sous les alertes. */
.bandeau-demo {
  background: var(--orange);
  color: #fff;
  text-align: center;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

main { max-width: 1120px; margin: 0 auto; padding: 24px; }

h1 { font-size: 26px; margin: 8px 0 20px; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 0 0 14px; }

/* ---------- Blocs ---------- */

.bloc {
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 20px;
  margin-bottom: 20px;
}

.bloc.urgent { border-left: 5px solid var(--rouge); background: var(--rouge-clair); }
.bloc.attention { border-left: 5px solid var(--orange); background: var(--orange-clair); }
/* Le seul bloc du tableau de bord qui n'appelle aucune action : de bonnes
   nouvelles. L'agent doit pouvoir le lire d'un coup d'œil et passer. */
.bloc.rassurant { border-left: 5px solid var(--vert); background: var(--vert-clair); }

.rangee-nouvelles { display: flex; flex-wrap: wrap; gap: 8px; }
.carte-nouvelle {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 13px;
  background: var(--carte);
  border: 1px solid var(--trait);
  border-radius: 20px;
  font-size: 15px;
}

.aide { color: var(--encre-douce); font-size: 14px; margin: 6px 0; }
.discret { color: var(--encre-douce); font-size: 14px; }
.fort { font-weight: 600; }
.code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }

/* ---------- Tableaux ---------- */

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--encre-douce);
  padding: 0 12px 8px 0;
  border-bottom: 1px solid var(--trait);
}
td { padding: 11px 12px 11px 0; border-bottom: 1px solid var(--trait); vertical-align: top; }
tr:last-child td { border-bottom: none; }

td.actions { white-space: nowrap; display: flex; gap: 8px; align-items: center; }
td.actions form { display: flex; gap: 6px; }

/* ---------- Grille d'objets ---------- */

.grille {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.carte {
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: 14px;
  background: var(--carte);
}

.carte header { all: unset; display: flex; align-items: center; gap: 8px; }
.carte.hors-ligne { opacity: 0.62; }
.carte p { margin: 6px 0 0; }
.telemetrie { font-size: 14px; }

.carte.selectionnable { display: block; cursor: pointer; }
.carte.selectionnable:hover { border-color: var(--bleu); }
.carte.selectionnable input { margin-right: 8px; transform: scale(1.3); }
.carte.selectionnable strong { display: inline; }
.carte.selectionnable .code, .carte.selectionnable .discret { display: block; }

.etat {
  width: 10px; height: 10px; border-radius: 50%;
  display: inline-block; flex: none;
}
.etat.ok { background: var(--vert); }
.etat.ko { background: #c2ccd6; }

.alerte-secteur { color: var(--rouge); font-weight: 600; }

tr.inactive { opacity: 0.5; }
.tronque { max-width: 320px; overflow: hidden; text-overflow: ellipsis;
           white-space: nowrap; }
.erreur-flux { color: var(--rouge); font-weight: 600; font-size: 13px; }

code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  background: rgba(20, 32, 46, 0.07);
  padding: 2px 7px;
  border-radius: 5px;
}

/* ---------- Formulaires ---------- */

label { display: block; margin-bottom: 14px; font-weight: 500; font-size: 14px; }
label.case { display: flex; align-items: center; gap: 8px; font-weight: 400; }
label.case input { transform: scale(1.25); }

input[type=text], input[type=tel], input[type=password], input[type=email],
textarea, select {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 10px 12px;
  font: inherit;
  color: inherit;
  border: 1px solid var(--trait);
  border-radius: 8px;
  background: #fff;
}

input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--bleu);
  outline-offset: -1px;
  border-color: var(--bleu);
}

.ligne { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.ligne > label { flex: 1 1 200px; }
.en-ligne { display: flex; gap: 8px; align-items: center; }
.en-ligne select { width: auto; margin-top: 0; }

button {
  font: inherit;
  font-weight: 600;
  padding: 9px 16px;
  border: 1px solid var(--trait);
  border-radius: 8px;
  background: var(--carte);
  color: var(--encre);
  cursor: pointer;
}
button:hover { border-color: var(--bleu); color: var(--bleu); }

button.principal {
  background: var(--bleu);
  border-color: var(--bleu);
  color: #fff;
  padding: 12px 26px;
  font-size: 16px;
}
button.principal:hover { background: #17518f; color: #fff; }

/* Les gestes sans retour en arrière se signalent. Rouge au survol seulement :
   un bouton rouge en permanence dans une liste finit par ne plus rien dire,
   et c'est au moment de le viser qu'il doit alerter. */
button.danger { border-color: var(--rouge); color: var(--rouge); }
button.danger:hover { background: var(--rouge); color: #fff; }

.modeles { display: flex; gap: 8px; flex-wrap: wrap; }
.modele { background: var(--bleu-clair); border-color: transparent; color: var(--bleu); }

/* ---------- Aperçu du message ---------- */

.apercu {
  margin: 0 0 14px;
  padding: 18px 22px;
  background: var(--fond);
  border-left: 4px solid var(--bleu);
  border-radius: 0 8px 8px 0;
  font-size: 19px;
  white-space: pre-wrap;
}

.bouton-apercu {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 8px;
  margin-right: 8px;
  font-weight: 600;
  font-size: 14px;
}
.bouton-apercu.primary { background: var(--vert-clair); color: var(--vert); }
.bouton-apercu.attention { background: var(--orange-clair); color: var(--orange); }
.bouton-apercu.alerte { background: var(--rouge-clair); color: var(--rouge); }

.reponse {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--vert-clair);
  color: var(--vert);
  font-weight: 600;
  font-size: 14px;
}

/* La console reprend les couleurs que la personne a vues sur son écran :
   vert, orange, rouge — les mêmes que TONS dans device/bienveilleur/ui.py.
   Un agent qui balaie une liste se fie aux couleurs avant de lire. */
.reponse.attention {
  background: var(--orange-clair);
  color: var(--orange);
}

.reponse.alerte {
  background: var(--rouge-clair);
  color: var(--rouge);
}

.pastille {
  display: inline-block;
  min-width: 22px;
  padding: 1px 8px;
  border-radius: 20px;
  background: var(--rouge);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}
.pastille.attention { background: var(--orange); }
.pastille.urgent { background: var(--rouge); }
.pastille.vert { background: var(--vert); }

.jauge {
  display: inline-block;
  width: 90px; height: 8px;
  background: var(--trait);
  border-radius: 4px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 8px;
}
.jauge span { display: block; height: 100%; background: var(--vert); }

/* ---------- Notifications temps réel ---------- */

.notifications {
  position: fixed;
  right: 20px; bottom: 20px;
  display: flex; flex-direction: column-reverse; gap: 8px;
  max-width: 360px;
  z-index: 50;
}

.notif {
  padding: 13px 16px;
  border-radius: var(--rayon);
  background: var(--encre);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(20, 32, 46, 0.25);
  transition: opacity 0.6s, transform 0.6s;
}
.notif.urgent { background: var(--rouge); }
.notif.sortie { opacity: 0; transform: translateX(24px); }

@media (max-width: 640px) {
  main { padding: 16px; }
  header { gap: 12px; padding: 10px 16px; }
  td.actions { flex-direction: column; align-items: flex-start; }
}
