/* ==========================================================================
   CAPBE — Documentation : feuille de style du site généré (docs/)
   Thème sombre, mise en page à barre latérale, responsive.
   ========================================================================== */

:root {
  /* Palette */
  --bg: #0b101d;
  --bg-deep: #070b14;
  --surface: #121a2c;
  --surface-2: #18223a;
  --surface-3: #1e2a45;
  --border: #26314f;
  --border-soft: #1c2740;
  --text: #dbe4f5;
  --text-soft: #b6c2da;
  --muted: #8593b3;
  --accent: #5eead4;
  --accent-2: #7dd3fc;
  --amber: #fbbf24;
  --green: #34d399;
  --red: #f87171;
  --purple: #c4b5fd;
  --code-bg: #0d1526;

  /* Mesures */
  --sidebar-w: 276px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; transition: color 0.15s ease; }
a:hover { color: #cdeeff; text-decoration: underline; }

code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(125, 211, 252, 0.09);
  border: 1px solid rgba(125, 211, 252, 0.16);
  border-radius: 5px;
  padding: 1px 6px;
  color: #cdeeff;
  white-space: nowrap;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  white-space: pre;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }

/* --------------------------------------------------------------------------
   Barre latérale
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  padding: 22px 18px 30px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-header { margin-bottom: 14px; padding: 0 6px; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: none; color: #fff; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #06222b;
  font-size: 18px;
  box-shadow: 0 4px 14px rgba(94, 234, 212, 0.35);
}

.brand-sub {
  display: block;
  margin: 4px 0 0 44px;
  font-size: 12px;
  color: var(--muted);
}

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

.nav-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin: 0 8px 6px;
}

.nav-link {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.nav-link:hover {
  background: var(--surface);
  color: #fff;
  text-decoration: none;
}
.nav-link.active {
  background: var(--surface-2);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid var(--border-soft);
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.9;
}
.sidebar-foot a { font-size: 12.5px; }

/* Pastilles d'état */
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
}
.dot.ok { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.8); }
.dot.warn { background: var(--amber); box-shadow: 0 0 8px rgba(251, 191, 36, 0.8); }
.dot.err { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.8); }

/* --------------------------------------------------------------------------
   Contenu
   -------------------------------------------------------------------------- */
.content {
  flex: 1;
  min-width: 0;
  max-width: 1060px;
  margin: 0 auto;
  padding: 28px 44px 90px;
}

/* Fil d'Ariane */
.breadcrumb {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent-2); }
.breadcrumb .sep { color: #3d4a6b; }
.breadcrumb .current { color: var(--text-soft); }

/* En-tête de document */
.doc-header { margin-bottom: 24px; }
.doc-header h1 {
  font-size: 30px;
  line-height: 1.25;
  margin: 0 0 14px;
  letter-spacing: -0.3px;
  color: #f4f8ff;
}

.doc-meta { display: flex; gap: 10px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--muted);
}
.badge code { font-size: 11.5px; }

/* --------------------------------------------------------------------------
   Corps Markdown
   -------------------------------------------------------------------------- */
.markdown-body h1, .markdown-body h2, .markdown-body h3,
.markdown-body h4, .markdown-body h5, .markdown-body h6 {
  color: #eef4ff;
  line-height: 1.35;
  margin: 2em 0 0.7em;
  scroll-margin-top: 24px;
}
.markdown-body h1 { font-size: 26px; margin-top: 0.4em; }
.markdown-body h2 {
  font-size: 21px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-soft);
}
.markdown-body h3 { font-size: 17.5px; }
.markdown-body h4 { font-size: 15.5px; color: var(--accent-2); }

.markdown-body h2:not(:first-child) { margin-top: 2.2em; }

.markdown-body p { margin: 0.9em 0; }
.markdown-body ul, .markdown-body ol { padding-left: 1.5em; margin: 0.9em 0; }
.markdown-body li { margin: 0.3em 0; }
.markdown-body li::marker { color: var(--accent); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 2.2em 0; }

/* Citations = encadrés d'avertissement */
.markdown-body blockquote {
  margin: 1.2em 0;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
}
.markdown-body blockquote p { margin: 0.4em 0; }
.markdown-body blockquote blockquote {
  background: var(--surface-2);
  border-left-color: var(--amber);
  margin-top: 0.8em;
}

/* Blocs de code (Pygments : <div class="highlight"><pre><code>) */
.markdown-body pre {
  margin: 1.1em 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
  background: var(--code-bg);
}
.markdown-body pre:not(.highlight) { padding: 14px 16px; color: #d6e2f7; }
.markdown-body .highlight {
  margin: 1.1em 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow-x: auto;
  background: var(--code-bg);
}
.markdown-body .highlight pre {
  margin: 0;
  border: none;
  border-radius: 0;
  background: none;
  padding: 14px 16px;
  overflow: visible;
}

/* Tables */
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.2em 0;
  font-size: 14px;
  display: block;
  overflow-x: auto;
}
.markdown-body th, .markdown-body td {
  border: 1px solid var(--border);
  padding: 8px 13px;
  text-align: left;
  vertical-align: top;
}
.markdown-body th {
  background: var(--surface-2);
  color: #eaf1ff;
  font-weight: 700;
  white-space: nowrap;
}
.markdown-body tr:nth-child(even) td { background: rgba(24, 34, 58, 0.45); }
.markdown-body tr:hover td { background: var(--surface-2); }

/* --------------------------------------------------------------------------
   Sommaire (TOC)
   -------------------------------------------------------------------------- */
.toc-box {
  margin: 0 0 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
}
.toc-box summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--accent);
  font-size: 13.5px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  user-select: none;
}
.toc-box summary:hover { color: #b7f5ea; }
.toc-box .toc { margin: 10px 0 4px; padding-left: 4px; }
.toc-box .toc ul { list-style: none; padding-left: 0; margin: 4px 0; }
.toc-box .toc li { margin: 0; }
.toc-box .toc li.sub { padding-left: 1.1em; }
.toc-box .toc a {
  color: var(--text-soft);
  font-size: 13.5px;
  line-height: 1.9;
}
.toc-box .toc a:hover { color: var(--accent-2); text-decoration: none; }

/* --------------------------------------------------------------------------
   Pied de page
   -------------------------------------------------------------------------- */
.doc-footer {
  margin-top: 54px;
  padding-top: 20px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn:hover { background: var(--surface-3); color: #fff; text-decoration: none; transform: translateY(-1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none;
  color: #06222b;
  box-shadow: 0 6px 18px rgba(94, 234, 212, 0.3);
}
.btn.primary:hover { filter: brightness(1.08); color: #06222b; }

/* --------------------------------------------------------------------------
   Page d'accueil
   -------------------------------------------------------------------------- */
.hero { padding: 26px 0 34px; }

.hero-eyebrow {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--accent);
  margin-bottom: 12px;
}

.hero-title {
  font-size: 52px;
  line-height: 1.05;
  margin: 0 0 18px;
  letter-spacing: -1.5px;
  background: linear-gradient(120deg, #f4f8ff 20%, var(--accent) 60%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-sub {
  font-size: 16.5px;
  color: var(--text-soft);
  max-width: 720px;
  margin: 0 0 26px;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Cartes de statistiques */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 10px 0 44px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.stat:hover { transform: translateY(-3px); border-color: var(--accent); }

.stat-num {
  display: block;
  font-size: 28px;
  font-weight: 800;
  color: var(--accent);
  font-family: var(--mono);
  line-height: 1.2;
}
.stat-label { font-size: 13px; color: var(--muted); }

/* Sections */
.section { margin: 46px 0; scroll-margin-top: 20px; }
.section h2 { font-size: 24px; color: #eef4ff; margin: 0 0 18px; }
.h2-date { font-size: 14px; color: var(--muted); font-weight: 500; }
.section h3 { font-size: 17px; color: var(--accent-2); margin: 1.8em 0 0.6em; }
.section h4 { font-size: 15px; margin: 0 0 0.6em; color: var(--text); }

/* Schéma d'architecture */
pre.arch {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: #9fd8cf;
}

/* Grilles & panneaux */
.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 14px 0 22px;
}
@media (max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.panel ul { margin: 0.4em 0 0; padding-left: 1.3em; }
.panel li { margin: 0.35em 0; font-size: 14px; }

/* Tableau clé/valeur (git) */
table.kv { border-collapse: collapse; width: 100%; margin: 4px 0 14px; font-size: 14px; }
table.kv td { padding: 7px 4px; border-bottom: 1px solid var(--border-soft); }
table.kv td:first-child { color: var(--muted); width: 110px; font-weight: 600; }

.git-status {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  border: 1px solid var(--border);
}
.git-status.ok { background: rgba(52, 211, 153, 0.08); border-color: rgba(52, 211, 153, 0.35); }
.git-status.warn { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.35); }
.git-status ul { margin: 6px 0 0; padding-left: 20px; }

/* Mini statistiques (badges de commits) */
.stats-mini { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }
.stat-mini {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 84px;
}
.stat-mini .stat-num { font-size: 20px; }
.stat-mini .stat-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px; }

/* Liste de commits */
ul.commit-list { list-style: none; padding: 0; margin: 8px 0 0; }
.commit-list li {
  display: flex;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--border-soft);
  font-size: 13px;
}
.commit-list li:last-child { border-bottom: none; }
.commit-hash { color: var(--accent); font-family: var(--mono); flex: 0 0 auto; }
.commit-msg { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Grille de cartes de documents */
.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.doc-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--text);
  transition: all 0.18s ease;
}
.doc-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
}

.doc-icon { font-size: 26px; }
.doc-title { font-weight: 700; color: #eef4ff; font-size: 15px; line-height: 1.4; }
.doc-src { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.doc-desc { font-size: 13.5px; color: var(--text-soft); line-height: 1.55; flex: 1; }
.doc-go { font-size: 13px; font-weight: 700; color: var(--accent); }

/* --------------------------------------------------------------------------
   Bouton « haut de page »
   -------------------------------------------------------------------------- */
#toTop {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--accent);
  font-size: 19px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: all 0.2s ease;
  z-index: 50;
  box-shadow: var(--shadow);
}
#toTop.show { opacity: 1; pointer-events: auto; transform: translateY(0); }
#toTop:hover { background: var(--surface-3); color: #fff; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .layout { flex-direction: column; }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    flex: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 18px 12px;
  }
  .sidebar-header { margin-bottom: 8px; }
  .side-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 8px;
  }
  .nav-section { min-width: max-content; }
  .nav-title { display: inline-block; margin: 0 6px 0 0; }
  .nav-link { display: inline-block; border-left: none; border-bottom: 3px solid transparent; }
  .nav-link.active { border-left: none; border-bottom-color: var(--accent); }
  .sidebar-foot { display: none; }
  .content { padding: 22px 22px 70px; }
}

@media (max-width: 560px) {
  .content { padding: 18px 16px 60px; }
  .hero-title { font-size: 38px; }
  .doc-header h1 { font-size: 24px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .doc-footer { flex-direction: column; align-items: flex-start; }
}

/* --------------------------------------------------------------------------
   Impression
   -------------------------------------------------------------------------- */
@media print {
  .sidebar, #toTop, .toc-box, .doc-meta, .hero-actions { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #111; }
  a { color: #0b5fff; }
  pre, code, .markdown-body table { background: #f4f4f4; }
}
