/* ============================================================
   TP 02.5 — CONSOLE DE SÉCURITÉ "SOC"
   Interface de filtrage des alertes de sécurité.

   Points du cahier des charges :
   - Ossature sémantique : header / main(aside + section) / footer
   - Formulaire de filtrage (input texte, select, submit) dans l'aside
   - Tableau SIEM (thead/tbody) dans la section
   - CSS GRID pour le main : 300px (aside) + 1fr (tableau), gap 20px
   - FLEXBOX pour aligner le header (titre à gauche, indicateurs à droite)
   - Fond dégradé sombre + box-shadow colorées (aspect "console pro")
   ============================================================ */

/* ─── Thèmes : SOMBRE par défaut (comme demandé), CLAIR en option ─── */
:root {
  /* dégradé de fond sombre : bleu nuit -> noir */
  --bg-grad-1: #0f172a;
  --bg-grad-2: #020617;
  --panel: #111a2e;
  --panel-2: #0d1526;
  --ink: #e8eef7;
  --muted: #8896ac;
  --line: #223049;
  --accent: #3b82f6;
  --accent-ink: #60a5fa;
  --ok: #22c55e;
  --warn: #f59e0b;
  --crit: #ef4444;
  --field-bg: #0d1526;
  --glow: rgba(59,130,246,.25);
  --radius: 14px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'Consolas', monospace;
}

/* thème clair (bouton de swap) */
html[data-theme="light"] {
  --bg-grad-1: #f5f5f7;
  --bg-grad-2: #eaeaec;
  --panel: #ffffff;
  --panel-2: #f5f5f7;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5e8;
  --accent: #0071e3;
  --accent-ink: #0058b9;
  --field-bg: #ffffff;
  --glow: rgba(0,113,227,.15);
}

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

body {
  font-family: var(--font);
  color: var(--ink);
  line-height: 1.5;
  letter-spacing: -.01em;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  /* fond dégradé sombre demandé par le PDF */
  background: linear-gradient(160deg, var(--bg-grad-1), var(--bg-grad-2));
  background-attachment: fixed;
  display: grid;
  grid-template-rows: auto 1fr auto;
  transition: background .4s ease, color .4s ease;
}

/* ============================================================
   1. HEADER (FLEXBOX) — titre à gauche, indicateurs à droite
   ============================================================ */
.soc-header {
  display: flex;                       /* FLEXBOX */
  align-items: center;
  justify-content: space-between;      /* pousse aux extrémités */
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1.1rem clamp(1.2rem, 4vw, 2rem);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.soc-brand { display: flex; align-items: center; gap: .8rem; }
.soc-brand .shield {
  width: 42px; height: 42px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--accent), #1e40af);
  display: grid; place-items: center; font-size: 1.2rem;
}
.soc-brand h1 { font-size: 1.1rem; font-weight: 600; letter-spacing: -.02em; }
.soc-brand span { display: block; font-size: .76rem; color: var(--muted); }

/* indicateurs (KPI) alignés à droite */
.soc-kpis { display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap; }
.kpi { display: flex; flex-direction: column; align-items: flex-end; }
.kpi .k-val { font-family: var(--mono); font-size: 1.05rem; font-weight: 600; color: var(--ink); }
.kpi .k-val.ok { color: var(--ok); }
.kpi .k-lbl { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
/* bouton swap thème */
.theme-swap {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
  cursor: pointer; display: inline-grid; place-items: center; padding: 0;
  transition: border-color .2s, transform .15s, box-shadow .2s;
}
.theme-swap:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-2px); box-shadow: 0 6px 16px var(--glow); }
.theme-swap:active { transform: scale(.94); }
.theme-swap svg { width: 19px; height: 19px; display: block; }
.theme-swap .moon { display: none; }
html[data-theme="light"] .theme-swap .sun { display: none; }
html[data-theme="light"] .theme-swap .moon { display: block; }

/* ============================================================
   2. MAIN (CSS GRID) — aside 300px + section 1fr, gap 20px
   ============================================================ */
main {
  display: grid;                              /* CSS GRID */
  grid-template-columns: 300px 1fr;           /* filtres | tableau */
  gap: 20px;
  padding: clamp(1.2rem, 4vw, 2rem);
  align-items: start;
  width: 100%; max-width: 1300px; margin-inline: auto;
}

/* ============================================================
   3. ASIDE — formulaire de filtrage
   ============================================================ */
aside {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  /* box-shadow colorée (aspect alerte, demandé par le PDF) */
  box-shadow: 0 0 0 1px transparent, 0 8px 30px rgba(0,0,0,.25), 0 0 20px var(--glow);
}
aside h2 { font-size: .95rem; font-weight: 600; margin-bottom: 1.1rem; display: flex; align-items: center; gap: .5rem; }
.filter-form { display: flex; flex-direction: column; gap: 1rem; }
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.field input[type="text"],
.field select {
  width: 100%;
  padding: .65rem .8rem;
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  font-family: var(--font); font-size: .9rem;
  transition: border-color .2s, box-shadow .2s;
}
.field input[type="text"]:focus,
.field select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--glow);
}
.field input::placeholder { color: var(--muted); }
.filter-form input[type="submit"] {
  margin-top: .3rem;
  padding: .75rem;
  background: var(--accent);
  border: none; border-radius: 9px;
  color: #fff; font-family: var(--font); font-size: .9rem; font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
.filter-form input[type="submit"]:hover { background: var(--accent-ink); transform: translateY(-1px); }

/* ============================================================
   4. SECTION — tableau des événements SIEM
   ============================================================ */
section.events {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: 0 8px 30px rgba(0,0,0,.25), 0 0 20px rgba(239,68,68,.12);
  overflow: hidden;
}
section.events h2 { font-size: .95rem; font-weight: 600; margin-bottom: 1.1rem; display: flex; align-items: center; justify-content: space-between; }
section.events h2 .live { font-size: .72rem; color: var(--crit); font-weight: 500; display: flex; align-items: center; gap: .4rem; }
section.events h2 .live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--crit); animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .3; } }

.table-scroll { overflow-x: auto; }        /* le tableau scrolle si trop large */
table {
  width: 100%; border-collapse: collapse; min-width: 640px;
  font-size: .85rem;
}
thead th {
  text-align: left; padding: .7rem .8rem;
  font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
tbody td { padding: .75rem .8rem; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .2s; }
tbody tr:hover { background: var(--panel-2); }
td.mono { font-family: var(--mono); font-size: .82rem; }
td .ip { font-family: var(--mono); color: var(--accent-ink); }

/* badges type d'attaque + action */
.badge { font-size: .72rem; font-weight: 600; padding: .2rem .6rem; border-radius: 99px; white-space: nowrap; }
.badge.attack { background: rgba(245,158,11,.15); color: var(--warn); }
.badge.crit { background: rgba(239,68,68,.15); color: var(--crit); }
.action { display: inline-flex; align-items: center; gap: .4rem; font-weight: 500; }
.action.blocked { color: var(--crit); }
.action.allowed { color: var(--ok); }
.action .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

/* ============================================================
   5. FOOTER — statut de conformité SecOps
   ============================================================ */
.soc-footer {
  padding: 1rem clamp(1.2rem, 4vw, 2rem);
  border-top: 1px solid var(--line);
  background: var(--panel);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  font-size: .8rem; color: var(--muted);
}
.soc-footer .conform { display: flex; align-items: center; gap: .5rem; }
.soc-footer .conform .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.soc-footer a { color: var(--accent-ink); text-decoration: none; }

/* ============================================================
   RESPONSIVE (aperçu — le vrai media query sera le sujet du Jour 3)
   Sur petit écran, l'aside passe au-dessus du tableau.
   ============================================================ */
@media (max-width: 760px) {
  main { grid-template-columns: 1fr; }   /* une seule colonne */
  .soc-header { flex-direction: column; align-items: flex-start; }
  .soc-kpis { width: 100%; justify-content: space-between; }
}
