/* ============================================================================
   EndoriumSpace — feuille partagée (centre de doc + communauté Q&A).
   Tokens calqués sur l'UI EndoriumFort (frontend/src/ui/theme.css).
   ========================================================================== */

:root {
  --brand-start: #3a64f0; --brand-end: #26f1ff; --priv: #d9650b;
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #fafbfc; --sub: #f1f3f5;
  --line: #e3e6ea; --line-2: #cfd4da; --text: #16191d; --text-2: #4d5561; --muted: #848b96;
  --accent: #3a64f0; --accent-bg: #eef2fe; --accent-line: #c3d0fb;
  --ok: #1a7f37; --ok-bg: #e9f6ec; --warn: #9a6700;
  --shadow: 0 1px 2px rgba(16,24,40,.05); --shadow-lg: 0 24px 60px -24px rgba(16,24,40,.28);
  --radius: 10px; --radius-sm: 6px;
  --font: "IBM Plex Sans","Segoe UI",system-ui,-apple-system,sans-serif;
  --display: "Space Grotesk","IBM Plex Sans",system-ui,sans-serif;
  --mono: "IBM Plex Mono",ui-monospace,"SFMono-Regular",Consolas,monospace;
}
:root[data-theme="dark"] {
  --bg: #0f1115; --panel: #171a1f; --panel-2: #1a1d22; --sub: #1d2127;
  --line: #2a2f37; --line-2: #3a404a; --text: #e7e9ec; --text-2: #b4bac3; --muted: #858c97;
  --accent: #5b8def; --accent-bg: #1a2740; --accent-line: #2c4675;
  --ok: #3fb760; --ok-bg: #14301d; --warn: #d29922;
  --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 30px 70px -30px rgba(0,0,0,.7);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 15.5px/1.65 var(--font); -webkit-font-smoothing: antialiased; }
h1,h2,h3,h4 { font-family: var(--display); font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .9em; }

/* Header (partagé) ------------------------------------------------------ */
.hdr { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); }
.hdr-in { display: flex; align-items: center; gap: 22px; height: 60px; padding: 0 20px; max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; } .brand img { width: 26px; height: 26px; } .brand b { color: var(--priv); }
.hdr nav { display: flex; gap: 20px; margin-left: 8px; }
.hdr nav a { color: var(--text-2); font-size: 14px; font-weight: 500; }
.hdr nav a:hover, .hdr nav a.active { color: var(--text); text-decoration: none; }
.hdr .spacer { margin-left: auto; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--sub); }
.btn { display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--panel); color: var(--text); font: 600 14px var(--font); cursor: pointer; }
.btn:hover { background: var(--sub); text-decoration: none; }
.btn--primary { color: #fff; border: 0; background: linear-gradient(135deg,var(--brand-start),var(--brand-end)); }
.btn--primary:hover { filter: brightness(1.07); }

/* Layout docs/forum ----------------------------------------------------- */
.layout { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: 260px 1fr; gap: 0; align-items: start; }
.sidebar { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); overflow-y: auto; border-right: 1px solid var(--line); padding: 22px 16px 60px; }
.sidebar h4 { font: 600 11.5px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 20px 10px 8px; }
.sidebar h4:first-child { margin-top: 0; }
.sidebar a { display: block; padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text-2); font-size: 14px; }
.sidebar a:hover { background: var(--sub); color: var(--text); text-decoration: none; }
.sidebar a.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.content { min-width: 0; padding: 36px clamp(20px, 5vw, 64px) 100px; }
.content-inner { max-width: 820px; }

/* Typographie de contenu (Markdown rendu) ------------------------------- */
.md h1 { font-size: 2rem; margin: 0 0 .5em; }
.md h2 { font-size: 1.5rem; margin: 1.8em 0 .6em; padding-bottom: .3em; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 1.2rem; margin: 1.5em 0 .5em; }
.md p, .md li { color: var(--text-2); }
.md p { margin: 0 0 1em; }
.md ul, .md ol { margin: 0 0 1em; padding-left: 1.5em; }
.md li { margin: .3em 0; }
.md li.task { list-style: none; margin-left: -1.3em; }
.md li.task .box { color: var(--accent); font-weight: 600; }
.md a { font-weight: 500; }
.md strong { color: var(--text); font-weight: 600; }
.md code { background: var(--sub); border: 1px solid var(--line); border-radius: 5px; padding: .12em .4em; color: var(--text); }
.md pre { background: #0d1017; color: #d7dbe3; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; overflow-x: auto; margin: 0 0 1.2em; position: relative; }
.md pre code { background: none; border: 0; padding: 0; color: inherit; font-size: 13.5px; line-height: 1.7; }
.md blockquote { margin: 0 0 1em; padding: 2px 16px; border-left: 3px solid var(--accent); background: var(--accent-bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-2); }
.md blockquote p { margin: .6em 0; }
.md table { width: 100%; border-collapse: collapse; margin: 0 0 1.2em; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.md th, .md td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; font-size: 14px; }
.md th { background: var(--panel-2); font-family: var(--display); color: var(--text); }
.md td { color: var(--text-2); } .md tr:last-child td { border-bottom: 0; }
.md hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.md .copy { position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid #2a2f37; background: #171a1f; color: #b4bac3; border-radius: 6px; cursor: pointer; }
.md .copy:hover { background: #1d2127; }
.doc-meta { margin: 8px 0 28px; font-size: 13px; color: var(--muted); }
.callout { border: 1px solid var(--accent-line); background: var(--accent-bg); border-radius: var(--radius-sm); padding: 12px 16px; margin: 0 0 1.2em; font-size: 14px; }
.callout.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); }

/* Recherche ------------------------------------------------------------- */
.search { position: relative; }
.search input { height: 36px; width: 220px; max-width: 46vw; padding: 0 12px 0 34px; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: var(--panel); color: var(--text); font: 400 14px var(--font); }
.search input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-results { position: absolute; top: 42px; right: 0; width: min(420px, 90vw); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); overflow: hidden; z-index: 60; }
.search-results a { display: block; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover { background: var(--sub); text-decoration: none; }
.search-results .s-title { font-weight: 600; font-size: 14px; }
.search-results .s-crumb { font-size: 12px; color: var(--muted); }
.search-results .empty { padding: 14px; color: var(--muted); font-size: 14px; }

/* ── Communauté (Q&A façon StackOverflow) ── */
.community { max-width: 1120px; margin: 0 auto; padding: 32px 20px 100px; }
.q-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.q-head h1 { font-size: 1.7rem; margin: 0; }
.tagbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.tag { font: 500 12.5px var(--font); color: var(--accent); background: var(--accent-bg); border: 1px solid var(--accent-line); border-radius: 5px; padding: 4px 9px; cursor: pointer; }
.tag:hover { text-decoration: none; filter: brightness(1.03); }
.tag.active { background: var(--accent); color: #fff; }
.qlist { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--panel); }
.qrow { display: grid; grid-template-columns: 88px 1fr; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); }
.qrow:last-child { border-bottom: 0; }
.qstats { display: flex; flex-direction: column; gap: 6px; text-align: right; font-size: 13px; color: var(--text-2); }
.qstats .n { font-family: var(--display); font-weight: 600; font-size: 1.05rem; color: var(--text); }
.qstats .accepted { color: var(--ok); border: 1px solid color-mix(in srgb,var(--ok) 40%,transparent); background: var(--ok-bg); border-radius: 5px; padding: 2px 0; }
.qrow h3 { margin: 0 0 6px; font-size: 1.08rem; }
.qrow h3 a { color: var(--text); } .qrow h3 a:hover { color: var(--accent); text-decoration: none; }
.qrow .excerpt { color: var(--text-2); font-size: 14px; margin: 0 0 10px; }
.qrow .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.qrow .meta .who { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* Question detail */
.qd { max-width: 880px; margin: 0 auto; padding: 28px 20px 100px; }
.qd .back { font-size: 13.5px; color: var(--text-2); }
.qd h1 { font-size: 1.7rem; margin: 10px 0 6px; }
.qd .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.post { display: grid; grid-template-columns: 56px 1fr; gap: 16px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.votes { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted); }
.votes .score { font-family: var(--display); font-weight: 600; font-size: 1.3rem; color: var(--text); }
.votes .acc { color: var(--ok); }
.ans-head { margin: 30px 0 4px; font-family: var(--display); font-weight: 600; font-size: 1.2rem; }
.whobox { display: inline-block; margin-top: 10px; padding: 8px 12px; background: var(--accent-bg); border: 1px solid var(--accent-line); border-radius: var(--radius-sm); font-size: 12.5px; color: var(--text-2); }
.disclaimer { margin: 26px 0 0; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 16px; }

/* Responsive ------------------------------------------------------------ */
.menu-btn { display: none; }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 60px; left: 0; bottom: 0; width: 270px; background: var(--panel); z-index: 40; transform: translateX(-100%); transition: transform .2s ease; height: auto; }
  .sidebar.open { transform: none; }
  .menu-btn { display: inline-grid; }
  .hdr nav { display: none; }
}
@media (max-width: 560px) {
  .qrow { grid-template-columns: 1fr; } .qstats { flex-direction: row; gap: 14px; text-align: left; }
  .search input { width: 160px; }
}

/* Liens précédent / suivant en bas des pages de documentation */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.pager a { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); text-decoration: none; color: var(--text); font-weight: 500; }
.pager a:hover { border-color: var(--accent); }
.pager a span { display: block; font-size: .78em; color: var(--muted); font-weight: 400; margin-bottom: 2px; }
.pager .next { text-align: right; }

/* Communauté : canaux d'entraide */
.community .lede { margin: 6px 0 0; color: var(--text-2); max-width: 640px; }
.channels { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin: 0 0 26px; }
.channel { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); }
.channel:hover { border-color: var(--accent); text-decoration: none; }
.channel h3 { margin: 0; font-size: 1.02rem; }
.channel p { margin: 0; color: var(--text-2); font-size: 14px; flex: 1; }
.channel .go { font-size: 13px; font-weight: 600; color: var(--accent); }
.sec-title { font-size: 1.3rem; margin: 34px 0 4px; }
.sec-sub { margin: 0 0 16px; color: var(--text-2); font-size: 14px; }
.qrow.solo, .qlist .qrow { grid-template-columns: 1fr; }
.empty-q { padding: 28px; color: var(--muted); }
.post.solo { grid-template-columns: 1fr; }
.ans-badge { display: inline-block; font-size: 12px; font-weight: 600; color: var(--ok); background: var(--ok-bg); border: 1px solid color-mix(in srgb,var(--ok) 40%,transparent); border-radius: 5px; padding: 2px 8px; margin-bottom: 8px; }
