/* ==========================================================================
   Operium Cockpit — thème sombre mobile-first (iPhone en cible principale)
   Palette : fond ardoise profond, accents cyan, statuts vert/ambre/rouge
   ========================================================================== */

:root {
  --fond: #0b1220;
  --fond-carte: #131c2e;
  --fond-carte-hover: #182338;
  --bordure: #22304a;
  --texte: #e6edf7;
  --texte-2: #93a4bd;
  --texte-3: #5c6f8d;
  --accent: #38bdf8;
  --ok: #34d399;
  --warning: #fbbf24;
  --critical: #f87171;
  --neutre: #64748b;
  --radius: 14px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  background: var(--fond);
  color: var(--texte);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  min-height: 100%;
  overscroll-behavior-y: none;
}

#app { min-height: 100vh; padding-bottom: calc(20px + var(--safe-bottom)); }

/* --------------------------------------------------------------------
   Chargement / spinner
   -------------------------------------------------------------------- */
.chargement-initial { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--bordure); border-top-color: var(--accent);
  animation: rotation 0.8s linear infinite;
}
@keyframes rotation { to { transform: rotate(360deg); } }
.spinner-inline { width: 20px; height: 20px; border-width: 2px; margin: 24px auto; }

/* --------------------------------------------------------------------
   Écran de connexion
   -------------------------------------------------------------------- */
.ecran-login {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; gap: 20px;
}
.ecran-login .logo { font-size: 44px; }
.ecran-login h1 { font-size: 22px; font-weight: 700; letter-spacing: 0.3px; }
.ecran-login p { color: var(--texte-2); font-size: 14px; text-align: center; }
.ecran-login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
.ecran-login input[type="password"] {
  width: 100%; padding: 14px 16px; border-radius: var(--radius);
  border: 1px solid var(--bordure); background: var(--fond-carte);
  color: var(--texte); font-size: 17px; outline: none;
}
.ecran-login input[type="password"]:focus { border-color: var(--accent); }
.erreur-login { color: var(--critical); font-size: 14px; text-align: center; min-height: 18px; }

/* --------------------------------------------------------------------
   Boutons
   -------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border-radius: var(--radius); border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--fond-carte); color: var(--texte);
  border: 1px solid var(--bordure);
}
.btn:active { transform: scale(0.98); }
.btn-primaire { background: var(--accent); border-color: var(--accent); color: #06202e; }
.btn-danger { background: rgba(248, 113, 113, 0.12); border-color: rgba(248, 113, 113, 0.4); color: var(--critical); }
.btn-petit { padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn-bloc { width: 100%; }
.btn[disabled] { opacity: 0.5; pointer-events: none; }

/* --------------------------------------------------------------------
   En-tête
   -------------------------------------------------------------------- */
.entete {
  position: sticky; top: 0; z-index: 20;
  padding: calc(12px + var(--safe-top)) 16px 12px;
  background: rgba(11, 18, 32, 0.92); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--bordure);
  display: flex; align-items: center; gap: 12px;
}
.entete h1 { font-size: 18px; font-weight: 700; flex: 1; }
.entete .sous-titre { font-size: 12px; color: var(--texte-2); font-weight: 400; display: block; }
.btn-icone {
  width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--bordure);
  background: var(--fond-carte); color: var(--texte-2); font-size: 17px;
  display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.btn-icone:active { transform: scale(0.94); }

/* --------------------------------------------------------------------
   Vue d'ensemble — cartes instances
   -------------------------------------------------------------------- */
.grille-cartes { padding: 14px; display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 640px) { .grille-cartes { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .grille-cartes { grid-template-columns: repeat(3, 1fr); } }

.carte-instance {
  background: var(--fond-carte); border: 1px solid var(--bordure);
  border-radius: var(--radius); padding: 14px 16px; cursor: pointer;
  display: flex; flex-direction: column; gap: 10px;
  transition: background 0.15s;
}
.carte-instance:active { background: var(--fond-carte-hover); }
.carte-instance .ligne-titre { display: flex; align-items: center; gap: 10px; }
.carte-instance .nom { font-weight: 700; font-size: 16px; flex: 1; }
.carte-instance .type-badge {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--texte-3); border: 1px solid var(--bordure);
  padding: 2px 7px; border-radius: 6px;
}

.pastille { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.pastille.ok { background: var(--ok); box-shadow: 0 0 8px rgba(52, 211, 153, 0.6); }
.pastille.warning { background: var(--warning); box-shadow: 0 0 8px rgba(251, 191, 36, 0.6); }
.pastille.critical { background: var(--critical); box-shadow: 0 0 8px rgba(248, 113, 113, 0.7); animation: pulse 1.2s infinite; }
.pastille.down { background: var(--neutre); }
@keyframes pulse { 50% { opacity: 0.4; } }

.carte-instance .mini-jauges { display: flex; gap: 14px; }
.mini-jauge { flex: 1; }
.mini-jauge .lib { font-size: 11px; color: var(--texte-3); margin-bottom: 4px; display: flex; justify-content: space-between; }
.mini-jauge .barre { height: 5px; border-radius: 3px; background: var(--bordure); overflow: hidden; }
.mini-jauge .barre > div { height: 100%; border-radius: 3px; background: var(--ok); }
.mini-jauge .barre > div.warning { background: var(--warning); }
.mini-jauge .barre > div.critical { background: var(--critical); }

.carte-instance .ligne-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge-info {
  font-size: 12px; color: var(--texte-2); background: rgba(148, 163, 184, 0.08);
  padding: 4px 9px; border-radius: 8px; display: inline-flex; align-items: center; gap: 5px;
}
.badge-info.alerte { color: var(--warning); background: rgba(251, 191, 36, 0.1); }
.badge-info.critique { color: var(--critical); background: rgba(248, 113, 113, 0.1); }
.badge-info.positif { color: var(--ok); background: rgba(52, 211, 153, 0.1); }

.carte-down-info { font-size: 13px; color: var(--critical); }
.maj-globale { text-align: center; color: var(--texte-3); font-size: 12px; padding: 4px 0 10px; }

/* --------------------------------------------------------------------
   Détail instance — onglets
   -------------------------------------------------------------------- */
.barre-onglets {
  display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px;
  position: sticky; top: calc(62px + var(--safe-top)); z-index: 15;
  background: rgba(11, 18, 32, 0.92); backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  scrollbar-width: none; border-bottom: 1px solid var(--bordure);
}
.barre-onglets::-webkit-scrollbar { display: none; }
.onglet {
  padding: 8px 14px; border-radius: 20px; font-size: 13.5px; font-weight: 600;
  color: var(--texte-2); background: transparent; border: 1px solid transparent;
  white-space: nowrap; cursor: pointer; flex-shrink: 0;
}
.onglet.actif { color: var(--accent); background: rgba(56, 189, 248, 0.1); border-color: rgba(56, 189, 248, 0.35); }

.contenu-onglet { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

/* --------------------------------------------------------------------
   Sections / listes
   -------------------------------------------------------------------- */
.section {
  background: var(--fond-carte); border: 1px solid var(--bordure);
  border-radius: var(--radius); padding: 14px 16px;
}
.section h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--texte-3); margin-bottom: 12px; font-weight: 700;
}

.grille-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 640px) { .grille-stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: rgba(148, 163, 184, 0.05); border-radius: 10px; padding: 10px 12px; }
.stat .valeur { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.stat .valeur.ok { color: var(--ok); }
.stat .valeur.warning { color: var(--warning); }
.stat .valeur.critical { color: var(--critical); }
.stat .lib { font-size: 11.5px; color: var(--texte-3); margin-top: 2px; }

/* Anneaux de jauge (CPU/RAM/Disque) */
.rangee-anneaux { display: flex; justify-content: space-around; gap: 8px; }
.anneau-bloc { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.anneau {
  width: 78px; height: 78px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; position: relative;
}
.anneau::before {
  content: ''; position: absolute; inset: 7px; border-radius: 50%; background: var(--fond-carte);
}
.anneau span { position: relative; font-size: 16px; font-weight: 800; }
.anneau-bloc .lib { font-size: 12px; color: var(--texte-2); }

/* Listes d'événements */
.liste-evenements { display: flex; flex-direction: column; }
.evenement {
  padding: 10px 0; border-bottom: 1px solid rgba(34, 48, 74, 0.6);
  display: flex; flex-direction: column; gap: 3px;
}
.evenement:last-child { border-bottom: none; }
.evenement .ligne1 { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.evenement .ligne1 .qui { font-weight: 600; }
.evenement .ligne1 .quand { margin-left: auto; color: var(--texte-3); font-size: 12px; white-space: nowrap; }
.evenement .ligne2 { color: var(--texte-2); font-size: 13px; word-break: break-word; }
.tag {
  font-size: 10.5px; padding: 2px 7px; border-radius: 6px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.4px; flex-shrink: 0;
}
.tag.ok, .tag.success, .tag.info, .tag.create { color: var(--ok); background: rgba(52, 211, 153, 0.12); }
.tag.warning, .tag.update, .tag.dry_run { color: var(--warning); background: rgba(251, 191, 36, 0.12); }
.tag.critical, .tag.error, .tag.failed, .tag.delete, .tag.bruteforce { color: var(--critical); background: rgba(248, 113, 113, 0.12); }
.tag.neutre, .tag.skipped { color: var(--texte-2); background: rgba(148, 163, 184, 0.12); }

.vide { color: var(--texte-3); font-size: 13.5px; text-align: center; padding: 14px 0; }

/* Utilisateurs connectés */
.rangee-user { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid rgba(34, 48, 74, 0.6); }
.rangee-user:last-child { border-bottom: none; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  background: rgba(56, 189, 248, 0.15); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.rangee-user .infos { flex: 1; min-width: 0; }
.rangee-user .nom { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rangee-user .meta { font-size: 12px; color: var(--texte-3); }
.statut-user { font-size: 11px; font-weight: 700; text-transform: capitalize; }
.statut-user.active { color: var(--ok); }
.statut-user.idle { color: var(--warning); }
.statut-user.away { color: #fb923c; }
.statut-user.offline { color: var(--texte-3); }

/* Alertes / recommandations */
.alerte-bloc {
  border-left: 3px solid var(--warning); background: rgba(251, 191, 36, 0.06);
  border-radius: 0 10px 10px 0; padding: 10px 12px; margin-bottom: 8px;
}
.alerte-bloc.critical { border-left-color: var(--critical); background: rgba(248, 113, 113, 0.06); }
.alerte-bloc .titre { font-weight: 700; font-size: 14px; display: flex; gap: 8px; align-items: center; }
.alerte-bloc .msg { color: var(--texte-2); font-size: 13px; margin-top: 4px; }
.alerte-bloc .reco { color: var(--accent); font-size: 13px; margin-top: 5px; }

/* Graphiques SVG */
.graphique { width: 100%; }
.graphique svg { width: 100%; height: auto; display: block; }
.legende-graph { display: flex; gap: 14px; font-size: 12px; color: var(--texte-2); margin-top: 8px; flex-wrap: wrap; }
.legende-graph .puce { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 5px; vertical-align: -1px; }

/* Actions */
.rangee-action {
  display: flex; align-items: center; gap: 10px; padding: 11px 0;
  border-bottom: 1px solid rgba(34, 48, 74, 0.6);
}
.rangee-action:last-child { border-bottom: none; }
.rangee-action .infos { flex: 1; min-width: 0; }
.rangee-action .nom { font-size: 14px; font-weight: 600; }
.rangee-action .desc { font-size: 12px; color: var(--texte-3); margin-top: 2px; }

/* Sélecteur de filtre (logs) */
.filtres { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.filtres::-webkit-scrollbar { display: none; }

/* Modale de confirmation */
.voile {
  position: fixed; inset: 0; background: rgba(4, 8, 16, 0.7); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
@media (min-width: 640px) { .voile { align-items: center; } }
.modale {
  background: var(--fond-carte); border: 1px solid var(--bordure);
  border-radius: 18px 18px 0 0; padding: 22px 20px calc(22px + var(--safe-bottom));
  width: 100%; max-width: 480px; display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 640px) { .modale { border-radius: 18px; padding-bottom: 22px; } }
.modale h2 { font-size: 17px; }
.modale p { color: var(--texte-2); font-size: 14px; line-height: 1.5; }
.modale .boutons { display: flex; gap: 10px; }
.modale .boutons .btn { flex: 1; }

/* Toast */
.toast {
  position: fixed; bottom: calc(20px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--fond-carte); border: 1px solid var(--bordure); color: var(--texte);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 60;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5); max-width: 90vw; text-align: center;
}
.toast.ok { border-color: rgba(52, 211, 153, 0.5); }
.toast.erreur { border-color: rgba(248, 113, 113, 0.5); }

/* Divers */
.lien-retour { color: var(--accent); font-size: 14px; text-decoration: none; font-weight: 600; }
.texte-2 { color: var(--texte-2); }
.texte-3 { color: var(--texte-3); }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
