/* ubs-manual.php — Manuel d'UBS en page web.
   Palette relevée sur le PDF de l'auteur (ReportLab) : accent #1f6feb,
   en-tête de tableau #eef2f7, lignes #fafbfd, encadrés #fff8e6 filet #e0a800,
   code #f4f6f9, texte #22262e / titres #10131a, bordures #e5e9ef / #d9dde3.
   Le mode sombre reprend la même structure avec les teintes du site. */

.page-ubs-manual {
  --um-accent: #1f6feb;
  --um-title: #10131a;
  --um-text: #22262e;
  --um-muted: #5b6069;
  --um-th-bg: #eef2f7;
  --um-row-bg: #fafbfd;
  --um-border: #e5e9ef;
  --um-border-2: #d9dde3;
  --um-note-bg: #fff8e6;
  --um-note-bar: #e0a800;
  --um-note-text: #5a4a18;
  --um-code-bg: #f4f6f9;
  --um-code-text: #1b2733;
  --um-paper: #ffffff;
  --um-hit: #ffe58a;
  --um-hit-cur: #ffb02e;
}
:root[data-theme="dark"] .page-ubs-manual {
  --um-accent: #58a6ff;
  --um-title: #f0f3f6;
  --um-text: #d6dbe1;
  --um-muted: #9aa3ad;
  --um-th-bg: #232a33;
  --um-row-bg: #1b2028;
  --um-border: #2d343d;
  --um-border-2: #39414b;
  --um-note-bg: rgba(224, 168, 0, .10);
  --um-note-bar: #d4a017;
  --um-note-text: #e8d49a;
  --um-code-bg: #161b22;
  --um-code-text: #c9d1d9;
  --um-paper: #171b21;
  --um-hit: rgba(255, 210, 80, .35);
  --um-hit-cur: rgba(255, 160, 40, .75);
}

.page-ubs-manual .main-content { padding-top: 0; }
.um-layout {
  display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px;
  max-width: 1240px; margin: 0 auto; padding: 18px 16px 60px; align-items: start;
}

/* ── Sommaire ─────────────────────────────────────────────── */
.um-toc {
  position: sticky; top: 64px; max-height: calc(100vh - 78px); overflow-y: auto;
  padding: 12px 10px 16px; border: 1px solid var(--color-border); border-radius: 10px;
  background: var(--color-surface); scrollbar-width: thin; font-size: 13px; line-height: 1.35;
}
.um-search { position: sticky; top: -12px; z-index: 2; margin: -12px -10px 8px; padding: 12px 10px 8px; background: var(--color-surface); }
.um-search input {
  width: 100%; box-sizing: border-box; padding: 8px 10px; font: inherit; font-size: 13px;
  border: 1px solid var(--color-border); border-radius: 7px; background: var(--color-bg); color: var(--color-text);
}
.um-search input:focus { outline: none; border-color: var(--um-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--um-accent) 22%, transparent); }
.um-search-nav { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--color-text-secondary); }
.um-search-nav[hidden] { display: none; }
.um-search-nav span { flex: 1; }
.um-search-nav button {
  width: 26px; height: 24px; padding: 0; border: 1px solid var(--color-border); border-radius: 5px;
  background: var(--color-surface); color: var(--color-text); cursor: pointer;
}
.um-search-nav button:hover { border-color: var(--um-accent); }
.um-toc-list, .um-toc-list ol { list-style: none; margin: 0; padding: 0; }
.um-toc-part { margin: 2px 0 6px; }
.um-toc-part > a { display: block; padding: 6px 8px; font-weight: 700; color: var(--color-text); border-radius: 6px; text-decoration: none; }
.um-toc-part ol a { display: block; padding: 4px 8px 4px 16px; color: var(--color-text-secondary); text-decoration: none; border-radius: 6px; border-left: 2px solid transparent; }
.um-toc-l4 a { padding-left: 28px !important; font-size: 12px; }
.um-toc a:hover { color: var(--color-text); background: color-mix(in srgb, var(--um-accent) 8%, transparent); }
.um-toc a.active { color: var(--um-accent); background: color-mix(in srgb, var(--um-accent) 10%, transparent); border-left-color: var(--um-accent); font-weight: 600; }
.um-toc a.has-hits::after { content: attr(data-hits); margin-left: 6px; padding: 0 5px; border-radius: 8px; font-size: 10px; font-weight: 700; background: var(--um-hit-cur); color: #3a2a00; }
.um-toc-toggle { display: none; }

/* ── Document ─────────────────────────────────────────────── */
.um-doc {
  position: relative; min-width: 0; padding: 0 44px 36px; border: 1px solid var(--color-border); border-radius: 10px;
  background: var(--um-paper); color: var(--um-text); font-family: Helvetica, Arial, sans-serif; font-size: 15px; line-height: 1.6;
  overflow: hidden;
}
.um-topline { height: 8px; margin: 0 -44px 22px; background: var(--um-accent); }
.um-meta { font-size: 13px; color: var(--um-muted); padding-bottom: 16px; border-bottom: 1px solid var(--um-border); }
/* Liens du développeur : cases du bloc de contact du site (.contact-box,
   components/contact-links.css), logos à leurs couleurs */
.um-meta .um-meta-line { margin: 0 0 10px; }
.um-links { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.um-meta .um-link { color: var(--color-text); }
.um-link-icon { width: 30px; height: 30px; transition: transform var(--transition-fast); }
.um-link:hover .um-link-icon { transform: scale(1.1); }
.um-yt { color: #ff0000; }
.um-dc { color: #5865f2; }
.um-tg { color: #0088cc; }
:root[data-theme="dark"] .um-dc { color: #7289da; }
:root[data-theme="dark"] .um-tg { color: #29b6f6; }
/* ProfAlgo : bandeau YouTube du développeur (assets/imgs/ubs-manual/profalgo-banner.png),
   qui remplit la case — ses proportions sont celles de la case ; image entière sur mobile */
.um-meta .um-link { min-height: 78px; }
.um-meta .um-pa-img { padding: 0; overflow: hidden; border-color: #0c2347; background: #06152f url(/assets/imgs/ubs-manual/profalgo-banner.png) center / cover no-repeat; }
.um-meta .um-pa-img:hover { background: #06152f url(/assets/imgs/ubs-manual/profalgo-banner.png) center / cover no-repeat; border-color: #216cce; }
.um-meta .um-se { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.um-meta .um-se-btn { display: inline-flex; width: auto; height: 34px; padding: 0 11px 0 7px; color: var(--color-text); }   /* libellé gardé (la barre du haut le masque sous 1100 px) */
.um-se-btn span { display: inline; }
/* Retour en haut : rond flottant en bas à droite, visible après ~1,5 écran défilé */
.um-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 950;
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; padding: 0; border-radius: 50%; cursor: pointer;
  color: #fff; background: var(--um-accent); border: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .22);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .2s, transform .2s, filter .15s;
}
.um-top.show { opacity: 1; transform: none; pointer-events: auto; }
.um-top:hover { filter: brightness(1.1); }
.um-top:focus-visible { outline: 2px solid var(--um-accent); outline-offset: 3px; }
:root[data-theme="dark"] .um-top { color: #0d1117; }
@media (max-width: 900px) { .um-top { right: 14px; bottom: 14px; width: 42px; height: 42px; } }
@media print { .um-top { display: none; } }
.um-links .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.um-meta a, .um-doc a { color: var(--um-accent); }
.um-cover { margin: 26px 0 10px; }
.um-cover h1 { margin: 0; font-size: 36px; line-height: 1.15; color: var(--um-title); letter-spacing: -.01em; }
.um-cover .um-sub { margin: 6px 0 0; color: var(--um-muted); font-size: 15px; }
.um-cover .um-sub span { margin-left: 6px; padding: 1px 7px; border-radius: 9px; font-size: 12px; font-weight: 700; color: #fff; background: var(--um-accent); }
.um-cover::after { content: ''; display: block; width: 110px; height: 3px; margin-top: 14px; background: var(--um-accent); }

.um-doc h2, .um-doc h3, .um-doc h4, .um-doc h5 { color: var(--um-title); scroll-margin-top: 70px; }
.um-part { margin: 46px 0 14px; padding-bottom: 8px; font-size: 27px; line-height: 1.2; border-bottom: 2px solid var(--um-accent); }
.um-doc h3 { margin: 34px 0 10px; font-size: 20px; }
.um-doc h4 { margin: 24px 0 8px; font-size: 16px; }
.um-doc h5 { margin: 18px 0 6px; font-size: 15px; }
.um-doc p { margin: 0 0 12px; }
.um-doc ul { margin: 0 0 12px; padding-left: 22px; }
.um-doc li { margin: 3px 0; }
.um-doc code { padding: 1px 5px; border-radius: 4px; font-family: Courier, 'SF Mono', monospace; font-size: .9em; background: var(--um-code-bg); color: var(--um-code-text); }

.um-note {
  margin: 14px 0 16px; padding: 10px 14px; border-left: 3px solid var(--um-note-bar); border-radius: 0 6px 6px 0;
  background: var(--um-note-bg); color: var(--um-note-text); font-size: 14px;
}
.um-code {
  margin: 10px 0 14px; padding: 10px 14px; border-radius: 6px; overflow-x: auto;
  background: var(--um-code-bg); color: var(--um-code-text); font-family: Courier, 'SF Mono', monospace; font-size: 13px; line-height: 1.5;
}
.um-table-wrap { margin: 10px 0 16px; overflow-x: auto; }
.um-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.um-table thead th { text-align: left; padding: 8px 12px; background: var(--um-th-bg); color: var(--um-title); font-weight: 700; border-bottom: 1px solid var(--um-border-2); }
.um-table tbody th, .um-table tbody td { padding: 8px 12px; vertical-align: top; border-bottom: 1px solid var(--um-border); text-align: left; }
.um-table tbody th { width: 36%; font-weight: 700; color: var(--um-title); scroll-margin-top: 70px; }
.um-table tbody tr:nth-child(even) { background: var(--um-row-bg); }
.um-table tbody tr:target, .um-table tbody tr.um-flash { background: color-mix(in srgb, var(--um-accent) 14%, transparent); }
.um-fig { margin: 14px 0 18px; text-align: center; }
.um-fig img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--um-border); background: #fff; }

.um-since {
  margin: 20px 0 6px; padding: 12px 16px; border: 1px solid color-mix(in srgb, var(--um-accent) 35%, transparent);
  border-radius: 8px; background: color-mix(in srgb, var(--um-accent) 6%, transparent); font-size: 14px;
}
.um-since h2 { margin: 0 0 4px; font-size: 16px; color: var(--um-title); }
.um-since p { margin: 0 0 6px; color: var(--um-muted); }
.um-since ul { margin: 0; }
.um-foot { margin-top: 40px; padding-top: 12px; border-top: 1px solid var(--um-border); font-size: 12px; color: var(--um-muted); }

mark.um-hit { background: var(--um-hit); color: inherit; border-radius: 2px; padding: 0 1px; }
mark.um-hit.current { background: var(--um-hit-cur); box-shadow: 0 0 0 2px var(--um-hit-cur); }

/* ── Mobile : sommaire en tiroir ─────────────────────────── */
@media (max-width: 900px) {
  .um-layout { grid-template-columns: minmax(0, 1fr); padding: 10px 10px 40px; gap: 10px; }
  .um-toc {
    display: none; position: fixed; z-index: 900; top: 58px; left: 10px; right: 10px; max-height: calc(100vh - 72px);
    box-shadow: 0 16px 40px rgba(0,0,0,.25);
  }
  .um-toc.open { display: block; }
  .um-toc-toggle {
    display: block; position: sticky; top: 56px; z-index: 5; justify-self: start; padding: 7px 14px;
    border: 1px solid var(--color-border); border-radius: 18px; background: var(--color-surface); color: var(--color-text);
    font: inherit; font-size: 13px; font-weight: 600; box-shadow: 0 4px 12px rgba(0,0,0,.08); cursor: pointer;
  }
  .um-doc { padding: 0 16px 24px; font-size: 15px; }
  .um-topline { margin: 0 -16px 16px; }
  .um-links { gap: 6px; }
  .um-meta .um-link { min-height: 44px; }
  .um-meta .um-pa-img, .um-meta .um-pa-img:hover { background-size: contain; }
  .um-link-icon { width: 24px; height: 24px; }
  .um-cover h1 { font-size: 28px; }
  .um-part { font-size: 23px; }
  /* Tableaux empilés : le libellé au-dessus de son explication */
  .um-table thead { display: none; }
  .um-table, .um-table tbody, .um-table tr, .um-table tbody th, .um-table tbody td { display: block; width: auto; }
  .um-table tbody tr { padding: 8px 10px; border-bottom: 1px solid var(--um-border); }
  .um-table tbody th, .um-table tbody td { padding: 0; border: 0; }
  .um-table tbody th { margin-bottom: 2px; }
  /* le bouton « Contents » collé en haut ne doit pas couvrir le titre visé */
  .um-doc h2, .um-doc h3, .um-doc h4, .um-doc h5, .um-table tbody tr { scroll-margin-top: 110px; }
}

/* ── Setfile Editor : fenêtre d'information sur un paramètre (sfe-ubs-doc.js) ── */
.ud-overlay { position: fixed; inset: 0; z-index: 10000; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(0, 0, 0, .5); }
.ud-overlay[hidden] { display: none; }
html.ud-modal-open { overflow: hidden; }   /* pas « ud-open » : c'est la classe du bouton « Open in the manual » (marge + bordure sur toute la page) */
.ud-card {
  display: flex; flex-direction: column; width: min(900px, 100%); max-height: calc(100vh - 48px);
  border-radius: 12px; overflow: hidden; background: var(--color-surface); color: var(--color-text);
  border: 1px solid var(--color-border); box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.ud-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); border-top: 4px solid #1f6feb; }
.ud-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.ud-param { font-family: 'SF Mono', 'JetBrains Mono', monospace; font-size: 15px; font-weight: 700; color: var(--color-text); overflow-wrap: anywhere; }
.ud-title { font-size: 13px; color: var(--color-text-secondary); }
.ud-open { flex: 0 0 auto; font-size: 13px; font-weight: 600; color: #1f6feb; text-decoration: none; padding: 6px 10px; border: 1px solid color-mix(in srgb, #1f6feb 40%, transparent); border-radius: 7px; }
.ud-open:hover { background: color-mix(in srgb, #1f6feb 10%, transparent); }
.ud-close { flex: 0 0 auto; width: 32px; height: 32px; border: 1px solid var(--color-border); border-radius: 7px; background: var(--color-surface); color: var(--color-text); font-size: 15px; cursor: pointer; }
.ud-close:hover { border-color: #1f6feb; }
.ud-scroll { overflow-y: auto; flex: 1 1 auto; background: var(--um-paper); }
.ud-body { border: 0; border-radius: 0; padding: 4px 28px 22px; overflow: visible; }
/* Setfile Editor écrit en gras par défaut : graisse normale du manuel, gras gardé pour titres, libellés et <strong> */
.ud-card { font-weight: 400; }
.ud-body p, .ud-body li, .ud-body td, .ud-body .um-note, .ud-body .um-code { font-weight: 400; }
.ud-body strong, .ud-body th, .ud-body h2, .ud-body h3, .ud-body h4, .ud-body h5 { font-weight: 700; }
.ud-body > h3:first-child, .ud-body > h2:first-child { margin-top: 18px; }
.ud-body .um-since { margin-top: 18px; }
.ud-body tr.ud-target th, .ud-body tr.ud-target td { box-shadow: inset 0 0 0 9999px color-mix(in srgb, var(--um-accent) 14%, transparent); }
.ud-body tr.ud-target th:first-child { border-left: 3px solid var(--um-accent); }
.ud-loading { padding: 30px 0; text-align: center; color: var(--um-muted); }
:root[data-theme="dark"] .ud-head { border-top-color: #58a6ff; }
:root[data-theme="dark"] .ud-open { color: #58a6ff; }
