/* Ulysse — dashboard réseau. Un seul fichier, aucune dépendance, aucun style en ligne
   (la CSP est stricte : tout vit ici). */

:root {
  --fond: #0b0f14;
  --fond-2: #0f151d;
  --carte: #151d29;
  --carte-2: #1b2533;
  --bord: #26313f;
  --texte: #e9eff8;
  --texte-2: #adbacb;
  --muet: #7f8da2;
  --accent: #4f8cff;
  --accent-fonce: #2f6fe0;
  --ok: #35c46a;
  --alerte: #e3b341;
  --erreur: #f0564a;
  --jauge: #22303f;
  --ombre: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .22);
  --rayon: 14px;
}

[data-theme="clair"] {
  --fond: #f4f6fa;
  --fond-2: #ffffff;
  --carte: #ffffff;
  --carte-2: #f1f4f9;
  --bord: #dde3ec;
  --texte: #131b26;
  --texte-2: #4b5768;
  --muet: #5f6c80;
  --accent: #2f6fe0;
  --accent-fonce: #2456b4;
  --ok: #17914a;
  --alerte: #9a6a00;
  --erreur: #cc3327;
  --jauge: #e3e8f0;
  --ombre: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

/* Indispensable : plusieurs conteneurs de ce fichier portent un `display`
   (flex/grid). Sans cette regle, elle l'emporte sur le `display: none` que le
   navigateur applique a [hidden], et les vues masquees restent toutes visibles
   les unes sous les autres. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0; }

.aide { color: var(--muet); font-size: .875rem; }
.horodatage { margin: -6px 0 4px 2px; }

/* ------------------------------------------------------------ chargement */

.chargement {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  color: var(--muet);
}

/* ------------------------------------------------------------- connexion */

.ecran-connexion {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.carte {
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 18px;
  box-shadow: var(--ombre);
}

.connexion {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 26px;
  text-align: left;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  flex: none;
}

.logo.grand { width: 46px; height: 46px; border-radius: 13px; font-size: 1.4rem; }

.champ { display: flex; flex-direction: column; gap: 6px; font-size: .875rem; }
.champ > span { color: var(--texte-2); font-weight: 500; }

input[type="text"], input[type="password"], input:not([type]), textarea, .recherche {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--bord);
  background: var(--fond-2);
  color: var(--texte);
  font: inherit;
}

input:focus-visible, textarea:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

textarea { resize: vertical; min-height: 46px; max-height: 160px; }

.bouton {
  border: 1px solid var(--bord);
  background: var(--carte-2);
  color: var(--texte);
  padding: 9px 14px;
  border-radius: 10px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s;
}
.bouton:hover { border-color: var(--accent); }
.bouton:active { transform: translateY(1px); }
.bouton.primaire { background: var(--accent); border-color: var(--accent); color: #fff; }
a.bouton { text-decoration: none; display: inline-flex; align-items: center; }
.bouton.primaire:hover { background: var(--accent-fonce); border-color: var(--accent-fonce); }
.bouton.discret { background: transparent; color: var(--texte-2); }
.bouton.discret:hover { color: var(--texte); }
.bouton.large { width: 100%; justify-content: center; }
.bouton[disabled] { opacity: .55; cursor: progress; }

.lien {
  border: 0;
  background: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

.message { border-radius: 10px; padding: 9px 12px; font-size: .875rem; border: 1px solid transparent; }
.message.erreur { background: rgba(240, 86, 74, .12); border-color: rgba(240, 86, 74, .4); color: var(--erreur); }
.message.succes { background: rgba(53, 196, 106, .12); border-color: rgba(53, 196, 106, .4); color: var(--ok); }
.message.vide { text-align: center; color: var(--muet); }
.message.avertissement {
  background: rgba(227, 179, 65, .12);
  border-color: rgba(227, 179, 65, .45);
  color: var(--alerte);
  margin-bottom: 16px;
}

/* ------------------------------------------------------------ structure */

.application { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.laterale {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 18px 14px;
  background: var(--fond-2);
  border-right: 1px solid var(--bord);
  position: sticky;
  top: 0;
  height: 100vh;
}

.marque-bloc { display: flex; align-items: center; gap: 10px; }
.marque-texte { display: flex; flex-direction: column; min-width: 0; }
.marque-texte strong { font-size: .98rem; }
.marque-texte small { color: var(--muet); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--texte-2);
  text-align: left;
  padding: 9px 12px;
  border-radius: 10px;
  font: inherit;
  cursor: pointer;
}
.nav-item:hover { background: var(--carte-2); color: var(--texte); }
.nav-item.actif { background: var(--carte-2); color: var(--texte); border-color: var(--bord); font-weight: 500; }

.pastille {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--accent);
  color: #fff;
  font-size: .72rem;
  font-weight: 600;
  text-align: center;
}

.laterale-bas { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }

.contenu { padding: 26px 30px 60px; max-width: 1300px; }

.vue { display: flex; flex-direction: column; gap: 16px; }

.vue-tete {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.vue-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.recherche { width: 230px; }

.segments { display: flex; border: 1px solid var(--bord); border-radius: 10px; overflow: hidden; }
.segment {
  border: 0;
  background: transparent;
  color: var(--texte-2);
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}
.segment + .segment { border-left: 1px solid var(--bord); }
.segment.actif { background: var(--carte-2); color: var(--texte); font-weight: 500; }

/* --------------------------------------------------------------- réseau */

.noeud { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }

.noeud-titre { grid-column: 1 / -1; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.noeud-titre h3 { font-size: 1.05rem; }

.metriques { display: flex; flex-direction: column; gap: 6px; }
.metriques-tete { display: flex; justify-content: space-between; font-size: .82rem; color: var(--texte-2); }
.metriques-tete b { color: var(--texte); font-weight: 600; }

.jauge { height: 6px; border-radius: 99px; background: var(--jauge); overflow: hidden; }
.jauge > span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.niveau-ok { background: var(--accent); }
.niveau-alerte { background: var(--alerte); }
.niveau-critique { background: var(--erreur); }

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

.carte-invite {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: var(--rayon);
  padding: 14px;
  box-shadow: var(--ombre);
}
.carte-invite.arrete { opacity: .58; }

.entete-invite { display: flex; align-items: center; gap: 8px; }
.entete-invite strong { font-size: .98rem; }
.entete-invite .num { color: var(--muet); font-size: .78rem; font-variant-numeric: tabular-nums; }

.point { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); flex: none; box-shadow: 0 0 0 3px rgba(53, 196, 106, .16); }
.point.arrete { background: var(--erreur); box-shadow: 0 0 0 3px rgba(240, 86, 74, .16); }

.etiquettes { display: flex; flex-wrap: wrap; gap: 6px; }
.etiquette {
  font-size: .74rem;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--carte-2);
  border: 1px solid var(--bord);
  color: var(--texte-2);
}
.etiquette.adresse { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--texte); }
.etiquette.lien { border-color: rgba(79, 140, 255, .5); }
.etiquette.lien a { color: var(--accent); text-decoration: none; }
.etiquette.lien a:hover { text-decoration: underline; }

.description { color: var(--texte-2); font-size: .85rem; white-space: pre-line; }

.journal summary { cursor: pointer; color: var(--texte-2); font-size: .9rem; }
.journal ul { list-style: none; margin: 12px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.journal li { font-size: .83rem; color: var(--texte-2); border-top: 1px solid var(--bord); padding-top: 6px; }
.journal li:first-child { border-top: 0; padding-top: 0; }
.journal time { color: var(--muet); font-variant-numeric: tabular-nums; }

/* ----------------------------------------------------------------- chat */

.discussion {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 300px;
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  padding: 4px;
}

.bulle {
  max-width: 78%;
  padding: 11px 14px;
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.bulle.utilisateur { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.bulle.ulysse { align-self: flex-start; background: var(--carte); border: 1px solid var(--bord); border-bottom-left-radius: 4px; }
.bulle.attente { color: var(--muet); font-style: italic; }
.bulle small { display: block; margin-top: 6px; opacity: .7; font-size: .72rem; }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.puce {
  border: 1px dashed var(--bord);
  background: transparent;
  color: var(--texte-2);
  padding: 6px 11px;
  border-radius: 99px;
  font: inherit;
  font-size: .84rem;
  cursor: pointer;
}
.puce:hover { border-color: var(--accent); color: var(--texte); }

.barre-envoi { display: flex; gap: 10px; align-items: flex-end; }
.barre-envoi textarea { flex: 1; }

/* ------------------------------------------------------------- fichiers */

.depot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  text-align: center;
  border-style: dashed;
  border-width: 2px;
  padding: 28px;
}
.depot.survol { border-color: var(--accent); background: var(--carte-2); }
.depot-titre { font-size: 1.05rem; font-weight: 600; }
.depot .champ { width: 100%; max-width: 460px; text-align: left; margin-top: 6px; }

.progression { display: flex; flex-direction: column; gap: 6px; }

.liste-fichiers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.fichier {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 11px 14px;
  flex-wrap: wrap;
}
.fichier-infos { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fichier-infos strong { font-size: .92rem; overflow-wrap: anywhere; }
.fichier-infos small { color: var(--muet); font-size: .78rem; }
.fichier-note { color: var(--texte-2); font-size: .82rem; font-style: italic; }
.fichier-actions { display: flex; gap: 8px; align-items: center; }
.fichier.neuf { border-color: rgba(79, 140, 255, .55); }

/* -------------------------------------------------------------- compte */

.infos { display: grid; grid-template-columns: auto 1fr; gap: 6px 18px; margin: 12px 0 0; font-size: .9rem; }
.infos dt { color: var(--muet); }
.infos dd { margin: 0; }

#form-mdp { display: flex; flex-direction: column; gap: 12px; max-width: 460px; }

/* --------------------------------------------------------------- toast */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: var(--carte);
  border: 1px solid var(--bord);
  border-radius: 12px;
  padding: 11px 16px;
  box-shadow: var(--ombre);
  font-size: .9rem;
  max-width: 90vw;
  z-index: 20;
}

/* ------------------------------------------------- largeurs de jauge */

.j-0 { width: 0; }
.j-5 { width: 5%; }
.j-10 { width: 10%; }
.j-15 { width: 15%; }
.j-20 { width: 20%; }
.j-25 { width: 25%; }
.j-30 { width: 30%; }
.j-35 { width: 35%; }
.j-40 { width: 40%; }
.j-45 { width: 45%; }
.j-50 { width: 50%; }
.j-55 { width: 55%; }
.j-60 { width: 60%; }
.j-65 { width: 65%; }
.j-70 { width: 70%; }
.j-75 { width: 75%; }
.j-80 { width: 80%; }
.j-85 { width: 85%; }
.j-90 { width: 90%; }
.j-95 { width: 95%; }
.j-100 { width: 100%; }

/* ----------------------------------------------------------- responsive */

@media (max-width: 880px) {
  .application { grid-template-columns: 1fr; }
  .laterale {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;          /* marque + boutons sur une ligne, navigation sur la suivante */
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--bord);
    padding: 10px 12px;
  }
  .marque-texte small { display: none; }
  /* La navigation passe sur sa propre ligne et occupe toute la largeur :
     sans ça les 4 onglets débordent et le dernier est coupé. */
  .nav { flex-direction: row; flex: 1 1 100%; order: 3; overflow-x: auto; }
  .nav-item { white-space: nowrap; }
  .laterale-bas { margin-top: 0; margin-left: auto; flex-direction: row; }
  .bouton.discret { white-space: nowrap; }
  .contenu { padding: 18px 14px 50px; }
  .recherche { width: 100%; }
  .bulle { max-width: 92%; }
  .discussion { max-height: none; }
}

/* Action proposée par le chat : une carte dans le fil, avec confirmation.
   Rien ne part vers Proxmox tant que le bouton Confirmer n'est pas cliqué. */
.carte-action {
  border: 1px solid var(--accent);
  border-left-width: 3px;
  background: var(--carte-2);
  border-radius: 12px;
  padding: 12px 14px;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-self: flex-start;
  max-width: 88%;
}
.etiquette-action {
  font-size: .72rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
}
.resume-action { margin: 0; color: var(--texte); }
.rangee-boutons { display: flex; gap: 8px; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
