/* ==========================================================================
   Documentation CAPPS — feuille unique (clair / sombre, FR / EN / AR en RTL).
   Mêmes jetons de couleur que le site public (site_v2.css), même clé de thème.
   ========================================================================== */

:root {
    --bg: #f7f7fb;
    --surface: #ffffff;
    --surface-2: #f1f1f8;
    --text: #0f172a;
    --text-2: #334155;
    --muted: #5b6475;
    --line: #e4e4ee;
    --brand: #4f46e5;
    --brand-txt: #4338ca;
    --brand-soft: #eef0ff;
    --fonce: #0f172a;
    --sur-fonce: #ffffff;
    --info-bg: #eef0ff; --info-line: #c7cbfb; --info-txt: #312e81;
    --att-bg: #fff7e6; --att-line: #f5c46b; --att-txt: #78350f;
    --ast-bg: #ecfdf5; --ast-line: #8fd9b9; --ast-txt: #065f46;
    --code-bg: #f1f1f8;
    --header-h: 64px;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --bg: #0b0d1a; --surface: #121528; --surface-2: #181c33;
    --text: #eef0fb; --text-2: #cfd3e6; --muted: #a3a9c2; --line: #262b47;
    --brand: #818cf8; --brand-txt: #a5b4fc; --brand-soft: #1e2147;
    --fonce: #eef0fb; --sur-fonce: #0b0d1a;
    --info-bg: #171a3a; --info-line: #3b3f86; --info-txt: #c7d2fe;
    --att-bg: #231a08; --att-line: #7a5512; --att-txt: #fde68a;
    --ast-bg: #0b2219; --ast-line: #1f6b4f; --ast-txt: #a7f3d0;
    --code-bg: #181c33;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b0d1a; --surface: #121528; --surface-2: #181c33;
        --text: #eef0fb; --text-2: #cfd3e6; --muted: #a3a9c2; --line: #262b47;
        --brand: #818cf8; --brand-txt: #a5b4fc; --brand-soft: #1e2147;
        --fonce: #eef0fb; --sur-fonce: #0b0d1a;
        --info-bg: #171a3a; --info-line: #3b3f86; --info-txt: #c7d2fe;
        --att-bg: #231a08; --att-line: #7a5512; --att-txt: #fde68a;
        --ast-bg: #0b2219; --ast-line: #1f6b4f; --ast-txt: #a7f3d0;
        --code-bg: #181c33;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px; line-height: 1.6;
    display: flex; flex-direction: column; min-height: 100vh;
}
html[lang="ar"] body { font-family: system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", Arial, sans-serif; line-height: 1.75; }
a { color: var(--brand-txt); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
img, svg { max-width: 100%; }
.i { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; background: var(--surface); padding: 10px 14px; border-radius: 8px; }
.skip:focus { top: 12px; }
.cadre { max-width: 1440px; margin: 0 auto; padding-inline: 32px; }

/* ---------- Boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 15px; border: 1px solid transparent; cursor: pointer; text-decoration: none !important; }
.btn-principal { background: #4f46e5; color: #fff; }
.btn-principal:hover { background: #4338ca; }
.btn-secondaire { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn-fonce { background: var(--fonce); color: var(--sur-fonce); min-height: 40px; padding: 8px 14px; font-size: 14px; }
.btn-icone { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex: none; }
.js-theme .soleil { display: none; }
:root[data-theme="dark"] .js-theme .soleil { display: block; }
:root[data-theme="dark"] .js-theme .lune { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .js-theme .soleil { display: block; }
    :root:not([data-theme="light"]) .js-theme .lune { display: none; }
}

/* ---------- En-tête ---------- */
.entete { position: sticky; top: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--line); }
.entete-l { min-height: 64px; display: flex; align-items: center; gap: 6px 24px; padding-block: 10px 6px; flex-wrap: wrap; }
.burger { display: none; }
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; font-size: 18px; text-decoration: none !important; }
.logo img { border-radius: 8px; }
.logo-doc { font-weight: 500; color: var(--muted); }
.sections { order: 3; flex: 1 1 100%; display: flex; gap: 2px; font-size: 14px; font-weight: 500; margin-inline: -12px; overflow-x: auto; }
.sections a { padding: 8px 12px; border-radius: 8px; color: var(--text-2); white-space: nowrap; }
.sections a:hover { background: var(--surface-2); text-decoration: none; }
.sections a[aria-current] { background: var(--brand-soft); color: var(--brand-txt); }
.outils { flex: 0 1 auto; margin-inline-start: auto; display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.recherche { position: relative; flex: 0 1 300px; min-width: 200px; }
.champ-recherche { display: flex; align-items: center; gap: 8px; height: 40px; padding-inline: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--muted); }
.champ-recherche:focus-within { border-color: var(--brand); }
.champ-recherche input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; }
.raccourci { font: inherit; font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.resultats { position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 50; margin: 0; padding: 6px; list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 40px -16px rgba(15, 23, 42, .35); max-height: 60vh; overflow: auto; min-width: 300px; }
.resultats li a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; }
.resultats li a small { display: block; color: var(--muted); font-size: 12px; }
.resultats li a:hover, .resultats li[aria-selected="true"] a { background: var(--brand-soft); }
.resultats .vide { padding: 10px; color: var(--muted); font-size: 14px; }
.choix select { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding-inline: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 14px; max-width: 160px; }

/* ---------- Corps : sommaire + contenu ---------- */
.corps { flex: 1; display: flex; gap: 40px; align-items: flex-start; width: 100%; }
.sommaire { flex: 0 0 270px; position: sticky; top: calc(var(--header-h) + 1px); max-height: calc(100vh - var(--header-h) - 1px); overflow: auto; padding: 28px 4px 40px 0; font-size: 14px; }
[dir="rtl"] .sommaire { padding: 28px 0 40px 4px; }
.sections-mobile { display: none; }
.sommaire-h { margin: 18px 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
[lang="ar"] .sommaire-h { letter-spacing: 0; }
.sommaire-h:first-of-type { margin-top: 0; }
.arbre, .arbre ul { list-style: none; margin: 0; padding: 0; }
.arbre summary { list-style: none; display: flex; align-items: center; gap: 6px; cursor: pointer; border-radius: 8px; padding: 2px 4px; }
.arbre summary::-webkit-details-marker { display: none; }
.arbre summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; flex: none; margin-inline: 4px 2px; }
[dir="rtl"] .arbre summary::before { transform: rotate(135deg); }
.arbre details[open] > summary::before { transform: rotate(45deg); }
.arbre summary a { flex: 1; padding: 6px 6px; color: var(--text); font-weight: 600; border-radius: 8px; }
.arbre ul { margin: 2px 0 8px; padding-inline-start: 18px; border-inline-start: 1px solid var(--line); margin-inline-start: 10px; }
.arbre ul a { display: block; padding: 6px 10px; color: var(--text-2); border-radius: 8px; line-height: 1.4; }
.arbre a:hover { background: var(--surface-2); text-decoration: none; }
.arbre a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-txt); font-weight: 600; }
.voile { display: none; }

.principal { flex: 1 1 auto; min-width: 0; padding: 28px 0 64px; outline: none; }
.fil { font-size: 13px; color: var(--muted); margin-bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; }
.fil a { color: var(--muted); }
h1 { margin: 0 0 12px; font-size: 36px; line-height: 1.15; letter-spacing: -0.02em; font-weight: 800; }
[lang="ar"] h1 { letter-spacing: 0; line-height: 1.35; }
.chapo { margin: 0 0 22px; font-size: 18px; color: var(--text-2); max-width: 70ch; }
.badge { display: inline-block; margin: 0 0 14px; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; background: #fef3c7; color: #78350f; }

/* ---------- Accueil ---------- */
.hero { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 40px; }
.hero h1 { font-size: 42px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.bloc { margin-top: 40px; }
.bloc > h2 { margin: 0 0 6px; font-size: 22px; }
.sous { margin: 0 0 16px; color: var(--muted); }
.taches, .tuiles { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.bloc > h2 + .tuiles { margin-top: 16px; }
.tache { display: flex; gap: 14px; align-items: flex-start; height: 100%; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none !important; }
.tache:hover, .tuile:hover { border-color: var(--brand); }
.tache .num { flex: none; width: 34px; height: 34px; border-radius: 10px; background: #fef3c7; color: #78350f; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.tache strong { display: block; line-height: 1.35; }
.tache .meta { display: block; font-size: 13px; color: var(--muted); margin-top: 4px; }
.tuile { display: flex; flex-direction: column; gap: 8px; height: 100%; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; color: var(--text); text-decoration: none !important; }
.tuile strong { font-size: 17px; }
.tuile-ic { width: 40px; height: 40px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-txt); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tuile-desc { font-size: 14px; color: var(--muted); }
.tuile-nb { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--brand-txt); }
.deux { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.carte { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; }
.carte h2 { margin: 0 0 8px; font-size: 18px; }
.carte p { margin: 0 0 10px; color: var(--text-2); font-size: 15px; }

/* ---------- Module ---------- */
.titre-module { display: flex; align-items: center; gap: 14px; }
.liste-articles { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; max-width: 860px; counter-reset: art; }
.liste-articles a { display: block; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none !important; }
.liste-articles a:hover { border-color: var(--brand); }
.liste-articles strong { display: block; }
.liste-articles span { display: block; font-size: 14px; color: var(--muted); margin-top: 2px; }

/* ---------- Article ---------- */
.article-grille { display: flex; gap: 40px; align-items: flex-start; }
.article { flex: 1 1 auto; min-width: 0; max-width: 800px; }
.meta-article { display: flex; flex-wrap: wrap; gap: 4px 18px; margin: 0 0 22px; font-size: 13px; color: var(--muted); }
.sur-page { flex: 0 0 220px; position: sticky; top: calc(var(--header-h) + 24px); font-size: 13px; }
.sur-page-h { margin: 0 0 8px; font-weight: 700; }
.sur-page ul { list-style: none; margin: 0; padding: 0; padding-inline-start: 12px; border-inline-start: 1px solid var(--line); display: grid; gap: 8px; }
.sur-page a { color: var(--text-2); }
.sur-page a.actif { color: var(--brand-txt); font-weight: 600; }

.contenu { font-size: 16px; color: var(--text-2); }
.contenu > :first-child { margin-top: 0; }
.contenu h2 { margin: 36px 0 12px; font-size: 24px; color: var(--text); line-height: 1.3; }
.contenu h3 { margin: 26px 0 8px; font-size: 18px; color: var(--text); }
.contenu p, .contenu ul, .contenu ol { margin: 0 0 14px; }
.contenu ul, .contenu ol { padding-inline-start: 22px; }
.contenu li + li { margin-top: 6px; }
.contenu strong { color: var(--text); }
.contenu code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .9em; background: var(--code-bg); padding: 1px 6px; border-radius: 6px; }
.contenu kbd { font: inherit; font-size: .85em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 0 6px; background: var(--surface); }
.contenu .chapo { font-size: 18px; }
ol.etapes { list-style: none; padding: 0; counter-reset: etape; display: grid; gap: 14px; }
ol.etapes > li { counter-increment: etape; position: relative; padding-inline-start: 44px; min-height: 30px; margin: 0; }
ol.etapes > li::before { content: counter(etape); position: absolute; inset-inline-start: 0; top: 0; width: 30px; height: 30px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-txt); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; }
ol.etapes > li > p { margin: 3px 0 6px; }
.note { border: 1px solid; border-radius: 12px; padding: 14px 16px; margin: 0 0 18px; }
.note p { margin: 0 0 6px; }
.note p:last-child { margin-bottom: 0; }
.note-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-txt); }
.note-attention { background: var(--att-bg); border-color: var(--att-line); color: var(--att-txt); }
.note-astuce { background: var(--ast-bg); border-color: var(--ast-line); color: var(--ast-txt); }
.note strong, .note a { color: inherit; }
.note a { text-decoration: underline; }
.tableau { overflow-x: auto; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 12px; }
.tableau table { border-collapse: collapse; width: 100%; font-size: 14px; }
.tableau th, .tableau td { padding: 10px 14px; text-align: start; vertical-align: top; border-top: 1px solid var(--line); }
.tableau thead th { border-top: 0; background: var(--surface-2); color: var(--text); }
.prec-suiv { display: flex; justify-content: space-between; gap: 12px; margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--line); }
.prec-suiv a { display: flex; flex-direction: column; max-width: 48%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); text-decoration: none !important; }
.prec-suiv a:hover { border-color: var(--brand); }
.prec-suiv a span { font-size: 12px; color: var(--muted); }
.prec-suiv a strong { color: var(--text); font-size: 15px; }
.prec-suiv .suiv { margin-inline-start: auto; text-align: end; }

/* ---------- Notes de version ---------- */
.version-notes { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 24px; margin-top: 22px; max-width: 860px; }
.version-notes h2 { margin: 0 0 14px; font-size: 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.version-notes h2 .badge { margin: 0; }
.version-notes h2 .date { font-size: 14px; font-weight: 500; color: var(--muted); }
.etiquette { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; margin-inline-end: 8px; }
.etiquette-nouveau { background: #dcfce7; color: #166534; }
.etiquette-ameliore { background: #e0e7ff; color: #3730a3; }
.etiquette-corrige { background: #fee2e2; color: #991b1b; }

/* ---------- Pied ---------- */
.pied { border-top: 1px solid var(--line); background: var(--surface); }
.pied-l { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 24px; padding-block: 20px; font-size: 13px; color: var(--muted); }
.pied-l p { margin: 0; }
.pied-liens { display: flex; flex-wrap: wrap; gap: 8px 18px; }

/* ---------- Adaptations ---------- */
@media (max-width: 1240px) {
    .sections { display: none; }
    .sections-mobile { display: flex; flex-direction: column; gap: 2px; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
    .sections-mobile a { padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 600; }
    .sur-page { display: none; }
}
@media (max-width: 960px) {
    .cadre { padding-inline: 16px; }
    .burger { display: inline-flex; }
    .entete-l { gap: 10px 12px; }
    .outils { flex: 1 1 100%; justify-content: stretch; margin-inline-start: 0; }
    .entete-l { padding-block: 10px; }
    .recherche { flex: 1 1 100%; order: -1; }
    .choix { flex: 1 1 0; }
    .choix select { width: 100%; max-width: none; height: 44px; }
    .btn-icone { width: 44px; height: 44px; }
    .raccourci { display: none; }
    .ouvrir { display: none; }
    .logo { margin-inline-end: auto; }
    .sommaire { position: fixed; top: 0; bottom: 0; inset-inline-start: 0; z-index: 60; width: min(320px, 86vw); max-height: none; background: var(--surface); padding: 20px 16px 40px; border-inline-end: 1px solid var(--line); transform: translateX(-105%); transition: transform .2s ease; visibility: hidden; }
    [dir="rtl"] .sommaire { transform: translateX(105%); padding: 20px 16px 40px; }
    body.sommaire-ouvert .sommaire { transform: none; visibility: visible; }
    .voile { position: fixed; inset: 0; z-index: 55; background: rgba(2, 6, 23, .5); }
    body.sommaire-ouvert .voile { display: block; }
    .principal { padding-top: 20px; }
    h1, .hero h1 { font-size: 30px; }
    .hero { padding: 24px; }
    .chapo { font-size: 17px; }
    .arbre summary a, .arbre ul a { padding-block: 10px; }
}
@media (max-width: 480px) {
    .prec-suiv { flex-direction: column; }
    .prec-suiv a { max-width: none; }
    .resultats { min-width: 0; }
}
@media print {
    .entete, .sommaire, .sur-page, .pied, .prec-suiv, .voile { display: none !important; }
    .corps { display: block; }
}
