/* ==========================================================================
   THELEMA GAB/A GROUP — Portail des services
   Direction : « salle de contrôle » luxe-industriel.
   Coque applicative : sidebar de navigation + topbar + contenu principal.
   ========================================================================== */

:root {
  --bg: #0c0b09;
  --bg-side: #0e0d0a;
  --bg-raise: #14120e;
  --bg-card: rgba(23, 20, 15, 0.72);
  --ink: #e9e2d4;
  --ink-dim: #97907f;
  --ink-faint: #5c574b;
  --gold: #d4a952;
  --gold-soft: rgba(212, 169, 82, 0.14);
  --gold-line: rgba(212, 169, 82, 0.26);
  --line: rgba(233, 226, 212, 0.09);
  --ok: #5fbf77;
  --warn: #d9a441;
  --font-display: "Cinzel", "Georgia", serif;
  --font-body: "Sora", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", monospace;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --side-w: 16.5rem;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: dark; }

/* VERROU D'ACCÈS — l'attribut hidden doit TOUJOURS gagner, même contre les
   display:flex/grid posés plus bas. Sans cette règle, une vue "cachée"
   resterait dans le flux et visible au scroll. */
[hidden] { display: none !important; }

/* Hors connexion, aucun défilement possible : seul le login existe. */
body.locked { overflow: hidden; height: 100vh; }

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* --- Atmosphère ----------------------------------------------------------- */
.grain {
  position: fixed; inset: 0; z-index: 30; pointer-events: none; opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .04 0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)'/%3E%3C/svg%3E");
}
.glow {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(52rem 30rem at 78% -8%, rgba(212, 169, 82, 0.09), transparent 60%),
    radial-gradient(40rem 26rem at 8% 110%, rgba(212, 169, 82, 0.05), transparent 60%);
}

/* ==========================================================================
   CONNEXION
   ========================================================================== */
.login {
  position: relative; z-index: 1;
  min-height: 100vh;
  display: grid; place-items: center;
  padding: 2rem;
  transition: opacity 0.35s var(--ease-out), transform 0.35s var(--ease-out);
}
.login.leaving { opacity: 0; transform: scale(0.985); pointer-events: none; }

.login-card {
  width: min(25rem, 100%);
  padding: 3rem 2.6rem 2.2rem;
  background: var(--bg-card);
  border: 1px solid var(--gold-line);
  position: relative;
  animation: rise 0.9s var(--ease-out) both;
}
.login-card::before, .login-card::after {
  content: ""; position: absolute; width: 14px; height: 14px;
  border: 1px solid var(--gold);
}
.login-card::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.login-card::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.sigil { width: 4.4rem; margin: 0 auto 1.4rem; color: var(--gold); }
.sigil svg { display: block; width: 100%; }

.login-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.45rem; letter-spacing: 0.12em;
  text-transform: uppercase; text-align: center;
}
.login-title span { color: var(--gold); }

.login-sub {
  text-align: center; color: var(--ink-dim);
  font-size: 0.8rem; letter-spacing: 0.06em;
  margin: 0.5rem 0 2.2rem;
}

.field { display: block; margin-bottom: 1.1rem; }
.field span {
  display: block; font-size: 0.66rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--ink-dim); margin-bottom: 0.45rem;
}
.field input {
  width: 100%; padding: 0.72rem 0.9rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-mono); font-size: 0.9rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.field input:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

.login-error { color: #e0705f; font-size: 0.78rem; margin: -0.3rem 0 0.8rem; }
.login-card.shake { animation: shake 0.4s; }

.btn-gold {
  width: 100%; margin-top: 0.4rem;
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  padding: 0.85rem 1rem;
  background: var(--gold); color: #171205;
  border: 0; cursor: pointer;
  font-family: var(--font-body); font-weight: 600;
  font-size: 0.78rem; letter-spacing: 0.24em; text-transform: uppercase;
  transition: transform 0.2s var(--ease-out), box-shadow 0.2s;
}
.btn-gold i { font-style: normal; transition: transform 0.2s var(--ease-out); }
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 8px 28px -8px rgba(212, 169, 82, 0.55); }
.btn-gold:hover i { transform: translateX(4px); }
.btn-gold:active { transform: translateY(0); }

.login-foot {
  margin-top: 1.8rem; text-align: center;
  font-size: 0.66rem; letter-spacing: 0.1em; color: var(--ink-faint);
}

/* ==========================================================================
   COQUE APPLICATIVE
   ========================================================================== */
.app {
  position: relative; z-index: 1;
  display: flex; min-height: 100vh;
  animation: fadeIn 0.45s var(--ease-out) both;
}

/* --- Sidebar --------------------------------------------------------------- */
.sidebar {
  width: var(--side-w); flex: none;
  display: flex; flex-direction: column;
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100vh;
  z-index: 20;
}

.side-brand {
  display: flex; align-items: center; gap: 0.8rem;
  padding: 1.35rem 1.3rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.brand-mark { width: 2.4rem; height: 2.4rem; color: var(--gold); flex: none; }
.side-brand strong {
  display: block; font-family: var(--font-display); font-weight: 600;
  font-size: 0.85rem; letter-spacing: 0.13em; text-transform: uppercase;
  line-height: 1.3;
}
.side-brand small { color: var(--ink-dim); font-size: 0.66rem; letter-spacing: 0.08em; }

.side-nav { flex: 1; overflow-y: auto; padding: 1.1rem 0.85rem 1rem; }
.side-nav::-webkit-scrollbar { width: 4px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--line); }

.side-label {
  font-family: var(--font-mono); font-size: 0.6rem;
  letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--ink-faint);
  margin: 1.2rem 0.5rem 0.5rem;
}
.side-label:first-child { margin-top: 0; }

.nav-item {
  display: flex; align-items: center; gap: 0.7rem;
  width: 100%; padding: 0.62rem 0.75rem;
  background: transparent; border: 0; border-left: 2px solid transparent;
  color: var(--ink-dim); text-align: left; cursor: pointer;
  font-family: var(--font-body); font-weight: 400; font-size: 0.83rem;
  letter-spacing: 0.02em; text-decoration: none;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.nav-item i {
  font-style: normal; font-size: 0.72rem; width: 1rem; text-align: center;
  color: var(--ink-faint); transition: color 0.2s;
}
.nav-item .n {
  margin-left: auto; font-family: var(--font-mono); font-size: 0.62rem;
  color: var(--ink-faint);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.45rem;
}
.nav-item:hover { color: var(--ink); background: rgba(233, 226, 212, 0.04); }
.nav-item:hover i { color: var(--gold); }
.nav-item.active {
  color: var(--ink); background: var(--gold-soft);
  border-left-color: var(--gold);
}
.nav-item.active i { color: var(--gold); }
.nav-item.ext i.arrow { margin-left: auto; width: auto; font-size: 0.68rem; }

.side-foot { border-top: 1px solid var(--line); padding: 1rem 1.1rem 1.15rem; }
.side-user { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.85rem; }
.avatar {
  width: 2.1rem; height: 2.1rem; flex: none;
  display: grid; place-items: center;
  background: var(--gold-soft); color: var(--gold);
  border: 1px solid var(--gold-line);
  font-family: var(--font-display); font-weight: 600; font-size: 0.95rem;
  transform: rotate(45deg);
}
.avatar { border-radius: 4px; }
.side-user strong { display: block; font-weight: 500; font-size: 0.82rem; }
.side-user small { color: var(--ink-faint); font-size: 0.66rem; letter-spacing: 0.06em; }

.btn-logout {
  display: flex; align-items: center; justify-content: center; gap: 0.55rem;
  width: 100%; padding: 0.55rem;
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--line); cursor: pointer;
  font-family: var(--font-body); font-size: 0.72rem; letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.btn-logout i { font-style: normal; }
.btn-logout:hover { color: #e0705f; border-color: rgba(224, 112, 95, 0.4); background: rgba(224, 112, 95, 0.07); }

.side-overlay {
  display: none; position: fixed; inset: 0; z-index: 15;
  background: rgba(5, 4, 3, 0.6); backdrop-filter: blur(2px);
}

/* --- Zone principale -------------------------------------------------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.main-top {
  display: flex; align-items: center; gap: 1.1rem;
  padding: 1.15rem 2.2rem;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
  background: rgba(12, 11, 9, 0.85); backdrop-filter: blur(10px);
}
.btn-menu {
  display: none;
  background: transparent; border: 1px solid var(--line);
  color: var(--ink); font-size: 1rem; padding: 0.35rem 0.65rem; cursor: pointer;
}
.main-heading { min-width: 0; }
.main-heading h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.05rem; letter-spacing: 0.14em; text-transform: uppercase;
}
.main-heading p { color: var(--ink-faint); font-size: 0.7rem; letter-spacing: 0.05em; }

.main-top-right { margin-left: auto; display: flex; align-items: center; gap: 0.8rem; }
.clock { font-family: var(--font-mono); font-size: 0.74rem; color: var(--ink-dim); letter-spacing: 0.04em; white-space: nowrap; }

.pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.4rem 0.85rem;
  background: transparent; color: var(--ink-dim);
  border: 1px solid var(--line); border-radius: 999px;
  font-size: 0.7rem; letter-spacing: 0.1em; text-decoration: none; cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.pill:hover { color: var(--ink); border-color: var(--gold-line); background: var(--gold-soft); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); box-shadow: 0 0 8px rgba(95, 191, 119, 0.8); animation: pulse 2.4s infinite; }

.main-body { flex: 1; padding: 2rem 2.2rem 1rem; outline: none; }

/* --- Vue d'ensemble : tuiles de synthèse ------------------------------------- */
.stats {
  display: grid; gap: 1px;
  grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
  background: var(--line); border: 1px solid var(--line);
  margin-bottom: 2.4rem;
}
.stat {
  background: var(--bg-raise); padding: 1.15rem 1.3rem;
  animation: rise 0.6s var(--ease-out) both;
}
.stat:nth-child(2) { animation-delay: 0.06s; }
.stat:nth-child(3) { animation-delay: 0.12s; }
.stat:nth-child(4) { animation-delay: 0.18s; }
.stat b {
  display: block; font-family: var(--font-display); font-weight: 600;
  font-size: 1.9rem; color: var(--gold); line-height: 1.1;
}
.stat span {
  font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-dim);
}

/* --- Tableau de bord : panneaux ------------------------------------------------ */
.dash-grid {
  display: grid; gap: 1.2rem;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  margin-bottom: 2.4rem;
}
.panel {
  background: var(--bg-raise);
  border: 1px solid var(--line);
  padding: 1.25rem 1.35rem 1.3rem;
  animation: rise 0.6s var(--ease-out) both;
}
.panel-title {
  display: flex; align-items: baseline; gap: 0.8rem;
  font-family: var(--font-display); font-weight: 600;
  font-size: 0.78rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold); margin-bottom: 1rem;
}
.panel-title .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-line), transparent); }

.info-row {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.5rem 0; border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
}
.info-row:last-child { border-bottom: 0; }
.info-row span { color: var(--ink-dim); }
.info-row b { font-weight: 500; font-family: var(--font-mono); font-size: 0.74rem; text-align: right; }

.stack-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.55rem 0; border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
}
.stack-row:last-child { border-bottom: 0; }
.stack-row .dot { flex: none; }
.dot-soon { background: var(--warn); }
.stack-row b { font-weight: 500; }
.stack-row span { color: var(--ink-faint); font-size: 0.7rem; }
.stack-row .n {
  margin-left: auto; font-family: var(--font-mono); font-size: 0.66rem;
  color: var(--ink-dim); white-space: nowrap;
}

.bar-row { margin-bottom: 0.85rem; }
.bar-row:last-child { margin-bottom: 0; }
.bar-meta { display: flex; justify-content: space-between; font-size: 0.72rem; margin-bottom: 0.35rem; }
.bar-meta span { color: var(--ink-dim); }
.bar-meta b { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }
.bar { height: 4px; background: rgba(233, 226, 212, 0.07); overflow: hidden; }
.bar i {
  display: block; height: 100%; background: linear-gradient(90deg, var(--gold), rgba(212, 169, 82, 0.55));
  transform-origin: left; animation: grow 0.9s var(--ease-out) both;
}
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.panel-cta {
  display: inline-flex; align-items: center; gap: 0.5rem;
  margin-top: 1rem; padding: 0.55rem 1rem;
  background: var(--gold-soft); color: var(--gold);
  border: 1px solid var(--gold-line); text-decoration: none;
  font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase;
  transition: background 0.2s, transform 0.2s var(--ease-out);
}
.panel-cta:hover { background: rgba(212, 169, 82, 0.24); transform: translateY(-1px); }

/* --- Sections & cartes -------------------------------------------------------- */
.svc-section { margin-bottom: 2.6rem; animation: rise 0.6s var(--ease-out) both; }
.svc-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.1rem; }
.svc-head h3 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 0.88rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--gold);
}
.svc-head .rule { flex: 1; height: 1px; background: linear-gradient(90deg, var(--gold-line), transparent); }
.svc-head .count { font-family: var(--font-mono); font-size: 0.68rem; color: var(--ink-faint); }

.svc-grid {
  display: grid; gap: 1px;
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
  background: var(--line); border: 1px solid var(--line);
}

.svc-card {
  display: block; position: relative;
  padding: 1.3rem 1.35rem 1.2rem;
  background: var(--bg-raise);
  color: inherit; text-decoration: none;
  transition: background 0.25s, transform 0.25s var(--ease-out);
}
.svc-card:hover { background: #1b1812; transform: translateY(-2px); z-index: 1; }
.svc-card::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 2px;
  background: var(--gold); transform: scaleX(0); transform-origin: left;
  transition: transform 0.3s var(--ease-out);
}
.svc-card:hover::after { transform: scaleX(1); }

.svc-top { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.5rem; }
.svc-name { font-weight: 500; font-size: 0.92rem; letter-spacing: 0.02em; }
.svc-tag {
  font-family: var(--font-mono); font-size: 0.56rem; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--ink-dim);
  border: 1px solid var(--line); padding: 0.16rem 0.5rem; border-radius: 999px;
  white-space: nowrap;
}
.svc-tag.soon { color: var(--warn); border-color: rgba(217, 164, 65, 0.35); }

.svc-desc { color: var(--ink-dim); font-size: 0.76rem; min-height: 2.4em; }
.svc-host {
  display: block; margin-top: 0.85rem;
  font-family: var(--font-mono); font-size: 0.66rem;
  color: var(--ink-faint); letter-spacing: 0.02em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color 0.25s;
}
.svc-card:hover .svc-host { color: var(--gold); }
.svc-card.disabled { pointer-events: none; opacity: 0.55; }

.group-intro { color: var(--ink-dim); font-size: 0.82rem; margin: -0.6rem 0 1.6rem; max-width: 46rem; }

/* --- Pied ------------------------------------------------------------------ */
.main-foot {
  padding: 1.2rem 2.2rem 1.4rem;
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  color: var(--ink-faint); font-size: 0.66rem; letter-spacing: 0.06em;
}
.foot-mono { font-family: var(--font-mono); }

/* --- Animations -------------------------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

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

/* --- Mobile : sidebar en tiroir ------------------------------------------------ */
@media (max-width: 56rem) {
  .sidebar {
    position: fixed; left: 0; top: 0; height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease-out);
    box-shadow: 24px 0 60px rgba(0, 0, 0, 0.5);
  }
  .app.side-open .sidebar { transform: none; }
  .app.side-open .side-overlay { display: block; }
  .btn-menu { display: block; }
  .main-top { padding: 1rem 1.2rem; }
  .main-body { padding: 1.4rem 1.2rem 1rem; }
  .main-foot { padding: 1rem 1.2rem 1.2rem; }
  .clock { display: none; }
}
