/* ============================================================
   TP 02 — DASHBOARD DE SUPERVISION "NOC"
   Style épuré, clair (inspiration Apple).
   Feuille de style séparée du HTML.

   Points notés du TP :
   - CSS GRID pour la structure globale (la grille de widgets)
   - FLEXBOX pour l'alignement interne (en-tête, cartes, boutons)
   - Responsive SANS media query : repeat(auto-fit, minmax())
   - Aucune largeur en pixels fixes pour la grille
   ============================================================ */

:root {
  --bg: #f5f5f7;            /* gris très clair façon Apple */
  --surface: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5e8;
  --line-soft: #f0f0f2;
  --header-bg: rgba(255,255,255,.8);
  --accent: #0071e3;       /* bleu Apple, l'unique couleur d'accent */
  --ok: #34c759;           /* vert iOS */
  --warn: #ff9f0a;         /* orange iOS */
  --crit: #ff3b30;         /* rouge iOS */
  --radius: 18px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
}

/* thème sombre */
html[data-theme="dark"] {
  --bg: #000000;
  --surface: #1c1c1e;
  --ink: #f5f5f7;
  --muted: #98989d;
  --line: #2c2c2e;
  --line-soft: #2c2c2e;
  --header-bg: rgba(28,28,30,.8);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: grid;                         /* header / main / footer */
  grid-template-rows: auto 1fr auto;
  transition: background .4s ease, color .4s ease;
}

/* ============================================================
   1. EN-TÊTE (FLEXBOX) — titre à gauche, statut à droite
   ============================================================ */
.noc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.1rem clamp(1.2rem, 4vw, 2.4rem);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 10;
}
.noc-brand { display: flex; align-items: center; gap: .7rem; }
.noc-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.noc-brand h1 { font-size: 1.05rem; font-weight: 600; letter-spacing: -.02em; }
.noc-brand span { display: block; font-size: .76rem; color: var(--muted); font-weight: 400; }

.noc-status { display: flex; align-items: center; gap: 1.4rem; }
.status-item { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--muted); }
.status-item strong { color: var(--ink); font-weight: 600; }
.status-item .pastille { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.status-item .clock { font-family: var(--mono); color: var(--ink); font-weight: 500; }

/* boutons de contrôle dans l'en-tête (thème + disposition) */
.noc-controls { display: flex; align-items: center; gap: .5rem; }
.ctrl-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; display: inline-grid; place-items: center;
  transition: background .2s, border-color .2s, transform .15s, box-shadow .2s;
  flex-shrink: 0;
}
.ctrl-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,113,227,.18); }
.ctrl-btn:active { transform: translateY(0) scale(.94); }
.ctrl-btn svg { width: 19px; height: 19px; transition: transform .35s cubic-bezier(.4,0,.2,1); }
.ctrl-btn:hover svg { transform: rotate(15deg); }
/* icône thème : soleil en clair, lune en sombre */
.ctrl-btn .moon { display: none; }
html[data-theme="dark"] .ctrl-btn .sun { display: none; }
html[data-theme="dark"] .ctrl-btn .moon { display: block; }
/* icône disposition : grille par défaut, lignes en mode vertical */
.ctrl-btn .ico-vertical { display: none; }
body.layout-vertical .ctrl-btn .ico-grid { display: none; }
body.layout-vertical .ctrl-btn .ico-vertical { display: block; }

/* ============================================================
   MODE DISPOSITION VERTICALE
   Une seule colonne, panneaux empilés. Le !important est nécessaire
   pour surcharger le repeat(auto-fit, ...) de la grille par défaut.
   ============================================================ */
body.layout-vertical .grid {
  grid-template-columns: 1fr !important;
}

/* ============================================================
   2. GRILLE DE WIDGETS (CSS GRID) — responsive sans media query
   ============================================================ */
main {
  padding: clamp(1.2rem, 4vw, 2.4rem);
  display: flex; flex-direction: column; gap: 1.4rem;
  width: 100%; max-width: 1200px; margin-inline: auto;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1.2rem;
}

/* ============================================================
   3. CARTES (FLEXBOX interne)
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex; flex-direction: column; gap: 1.1rem;
  transition: transform .35s cubic-bezier(.4,0,.2,1), box-shadow .35s cubic-bezier(.4,0,.2,1);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 14px 40px rgba(0,0,0,.07); }

.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-head h2 { font-size: .95rem; font-weight: 600; }
.card-head .tag { font-size: .72rem; color: var(--muted); }

/* ─ Carte 1 : serveurs ─ */
.srv-list { display: flex; flex-direction: column; gap: .5rem; }
.srv { display: flex; align-items: center; justify-content: space-between; padding: .55rem .2rem; border-bottom: 1px solid var(--line-soft); font-size: .88rem; }
.srv:last-child { border-bottom: none; }
.srv .name { display: flex; align-items: center; gap: .6rem; }
.srv .ping { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.led { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.led.ok { background: var(--ok); }
.led.warn { background: var(--warn); }
.led.crit { background: var(--crit); }

/* ─ Carte 2 : trafic (barres sobres) ─ */
.traffic { display: flex; flex-direction: column; gap: .8rem; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 84px; }
.bars .bar { flex: 1; background: var(--accent); border-radius: 4px; min-height: 4px; opacity: .85; transition: height .6s cubic-bezier(.4,0,.2,1); }
.traffic .legend { display: flex; justify-content: space-between; font-size: .76rem; color: var(--muted); }

/* ─ Carte 3 : jauges ─ */
.gauges { display: flex; flex-direction: column; gap: 1rem; }
.gauge .glabel { display: flex; justify-content: space-between; font-size: .85rem; margin-bottom: .4rem; }
.gauge .glabel .pct { font-family: var(--mono); font-weight: 600; }
.gtrack { height: 8px; background: var(--line-soft); border-radius: 99px; overflow: hidden; }
.gfill { height: 100%; width: 0; border-radius: 99px; transition: width .9s cubic-bezier(.4,0,.2,1); }
.gfill.lvl-ok { background: var(--ok); }
.gfill.lvl-warn { background: var(--warn); }
.gfill.lvl-crit { background: var(--crit); }

/* ─ Carte 4 : alertes ─ */
.alerts { display: flex; flex-direction: column; gap: .5rem; }
.alert { display: flex; align-items: flex-start; gap: .7rem; padding: .55rem .2rem; border-bottom: 1px solid var(--line-soft); font-size: .85rem; }
.alert:last-child { border-bottom: none; }
.alert .time { font-family: var(--mono); font-size: .74rem; color: var(--muted); flex-shrink: 0; }
.alert .badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); margin-top: .45rem; flex-shrink: 0; }
.alert.warn .badge-dot { background: var(--warn); }
.alert.crit .badge-dot { background: var(--crit); }

/* ============================================================
   4. ACTIONS RAPIDES (FLEXBOX réparti) — simplifié, 3 boutons
   ============================================================ */
.actions { display: flex; gap: .9rem; flex-wrap: wrap; }
.actions .btn {
  flex: 1 1 150px;
  padding: .8rem 1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  font-family: var(--font); font-size: .9rem; font-weight: 500;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}
.actions .btn:hover { background: var(--line-soft); transform: translateY(-2px); }
.actions .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.actions .btn.primary:hover { background: #0058b9; }

/* ============================================================
   PIED DE PAGE
   ============================================================ */
.noc-footer {
  padding: 1.2rem clamp(1.2rem, 4vw, 2.4rem);
  border-top: 1px solid var(--line-soft);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  font-size: .8rem; color: var(--muted);
}
.noc-footer a { color: var(--accent); text-decoration: none; }

/* ============================================================
   RESPONSIVE — la grille s'adapte seule, on gère juste l'en-tête
   ============================================================ */
@media (max-width: 560px) {
  .noc-header { flex-direction: column; align-items: flex-start; }
  .noc-status { width: 100%; justify-content: space-between; }
}
