/* Edara CRM — User Guide (help.html) styles. A standalone page: it does not
   load tokens.css or app.css, so its palette is its own (:root below). */
:root {
  --navy: #003355;
  --navy-2: #0a4773;
  --gold: #f7be00;
  --gold-2: #d9a800;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-card: #ffffff;
  --code-bg: #f1f5f9;
  --accent-info: #0ea5e9;
  --accent-tip: #16a34a;
  --accent-warn: #d97706;
  --accent-admin: #b45309;
  --accent-admin-bg: #fef3c7;
  --accent-limit-bg: #f1f5f9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.04);
  --topbar-h: 60px;
  --max-w: 1280px;
}
html[data-theme="dark"] {
  --navy: #4d9fdc;
  --navy-2: #66b3eb;
  --gold: #ffc933;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --line: #1e293b;
  --bg: #0b1220;
  --bg-soft: #0f172a;
  --bg-card: #111c2f;
  --code-bg: #0f172a;
  --accent-info: #38bdf8;
  --accent-tip: #4ade80;
  --accent-warn: #fbbf24;
  --accent-admin: #fbbf24;
  --accent-admin-bg: #422006;
  --accent-limit-bg: #111c2f;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-soft); color: var(--ink); }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
html[dir="rtl"] body, html[lang="ar"] body {
  font-family: 'Cairo', 'Tajawal', system-ui, sans-serif;
}
.material-symbols-outlined { font-family: 'Material Symbols Outlined'; vertical-align: -4px; }
html[dir="rtl"] .material-symbols-outlined.flip-rtl { transform: scaleX(-1); }

/* Show only the active-language sections */
body[data-active-lang="en"] [lang="ar"] { display: none; }
body[data-active-lang="ar"] [lang="en"] { display: none; }

/* Top bar — matches the CRM shell top-bar (white surface, border-bottom, MD3 icon buttons) */
.doc-topbar {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg-card); color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.doc-topbar__inner {
  max-width: var(--max-w); margin: 0 auto;
  padding: 0 16px;
  padding-inline-start: max(16px, env(safe-area-inset-left, 0));
  padding-inline-end:   max(16px, env(safe-area-inset-right, 0));
  display: flex; align-items: center; gap: 12px; min-height: var(--topbar-h);
}
.doc-brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.doc-brand__logo-img { height: 22px; width: auto; display: block; }
html[data-theme="dark"] .doc-brand__logo-img { filter: brightness(0) invert(1); }
.doc-brand__logo-sep { font-size: 20px; font-weight: 300; color: var(--muted); opacity: .4; line-height: 1; }
.doc-brand__logo-text {
  font-weight: 600; font-size: 15px; letter-spacing: 0.04em;
  color: var(--muted); white-space: nowrap;
}
.doc-topbar__spacer { flex: 1; }
.doc-topbar__actions { display: flex; align-items: center; gap: 4px; }

.doc-iconbtn {
  background: transparent; border: 0; color: inherit; cursor: pointer;
  min-width: 44px; min-height: 44px;
  border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 6px;
}
.doc-iconbtn:hover { background: var(--bg-soft); }
.doc-iconbtn .material-symbols-outlined { font-size: 22px; }
.doc-iconbtn__label {
  font-family: 'Cairo', 'Inter', sans-serif;
  font-weight: 600; font-size: 16px; line-height: 1;
}
html[lang="ar"] .doc-iconbtn__label { font-family: 'Inter', sans-serif; font-size: 13px; letter-spacing: .04em; }

/* Layout */
.doc-shell {
  max-width: var(--max-w); margin: 0 auto; padding: 24px 20px 80px;
  display: grid; grid-template-columns: 260px 1fr; gap: 32px;
}
.doc-toc {
  position: sticky; top: calc(var(--topbar-h) + 24px);
  align-self: start; max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto; padding-inline-end: 8px;
}
.doc-toc h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
.doc-toc ol { list-style: none; margin: 0; padding: 0; counter-reset: tocidx; }
.doc-toc li { counter-increment: tocidx; }
.doc-toc a {
  display: block; padding: 7px 10px; color: var(--ink-2); text-decoration: none;
  font-size: 13.5px; border-radius: 6px; line-height: 1.4;
}
.doc-toc a::before {
  content: counter(tocidx) ". "; color: var(--muted); font-variant-numeric: tabular-nums;
}
.doc-toc a:hover { background: var(--bg-card); color: var(--navy); }
.doc-toc a.admin-link::after {
  content: "Admin"; margin-inline-start: 6px; font-size: 10px;
  background: var(--accent-admin-bg); color: var(--accent-admin);
  padding: 1px 6px; border-radius: 999px; font-weight: 600;
}
body[data-active-lang="ar"] .doc-toc a.admin-link::after { content: "مسؤول"; }

.doc-toc-mobile {
  display: none;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 16px; padding: 8px 12px;
}
.doc-toc-mobile__btn {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  background: transparent; border: 0; padding: 8px; font: inherit; font-weight: 600; cursor: pointer;
  color: var(--ink);
}
.doc-toc-mobile #docToc { display: none; padding: 4px 0 8px; }
.doc-toc-mobile #docToc[data-open] { display: block; }

/* Content */
.doc-content { min-width: 0; }
.doc-hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff; border-radius: var(--radius); padding: 32px 32px;
  margin-bottom: 28px;
}
.doc-hero h1 { margin: 0 0 8px; font-size: 28px; line-height: 1.2; }
.doc-hero p { margin: 0; opacity: .9; font-size: 15px; max-width: 64ch; }
.doc-hero__meta { margin-top: 14px; font-size: 12.5px; opacity: .75; }

section.doc-section {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 18px;
  box-shadow: var(--shadow);
}
section.doc-section h2 {
  font-size: 22px; margin: 0 0 6px; color: var(--navy); line-height: 1.25;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
section.doc-section h2 .doc-num {
  font-size: 13px; font-weight: 600; color: var(--muted);
  background: var(--bg-soft); padding: 4px 10px; border-radius: 999px;
}
section.doc-section h2 .doc-badge--admin {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  background: var(--accent-admin-bg); color: var(--accent-admin);
  padding: 3px 10px; border-radius: 999px;
}
section.doc-section .doc-lede { color: var(--ink-2); margin: 0 0 18px; }
section.doc-section h3 { font-size: 15px; margin: 20px 0 8px; color: var(--ink); }
section.doc-section h4 { font-size: 14px; margin: 16px 0 6px; color: var(--ink-2); font-weight: 600; }
section.doc-section h3 .material-symbols-outlined { color: var(--navy); font-size: 20px; }
section.doc-section ol, section.doc-section ul { padding-inline-start: 22px; margin: 0 0 14px; }
section.doc-section li { margin-bottom: 6px; }
section.doc-section p { margin: 0 0 12px; }
section.doc-section code {
  background: var(--code-bg); padding: 1px 6px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px; color: var(--ink);
}
section.doc-section kbd {
  display: inline-block; padding: 1px 7px; font-size: 12px;
  background: var(--bg-soft); border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; font-family: ui-monospace, monospace;
}

/* Callouts */
.callout {
  border-inline-start: 4px solid var(--accent-info);
  background: color-mix(in srgb, var(--accent-info) 8%, var(--bg-card));
  border-radius: var(--radius-sm); padding: 12px 16px; margin: 14px 0;
  display: flex; gap: 10px; align-items: flex-start;
}
.callout .material-symbols-outlined { color: var(--accent-info); }
.callout--tip { border-inline-start-color: var(--accent-tip); background: color-mix(in srgb, var(--accent-tip) 8%, var(--bg-card)); }
.callout--tip .material-symbols-outlined { color: var(--accent-tip); }
.callout--warn { border-inline-start-color: var(--accent-warn); background: color-mix(in srgb, var(--accent-warn) 10%, var(--bg-card)); }
.callout--warn .material-symbols-outlined { color: var(--accent-warn); }
.callout--admin { border-inline-start-color: var(--accent-admin); background: var(--accent-admin-bg); }
.callout--admin .material-symbols-outlined { color: var(--accent-admin); }
.callout strong { display: block; margin-bottom: 2px; }
.callout p, .callout ul { margin: 0; }

.limits {
  font-size: 13px; color: var(--muted); font-style: italic;
  background: var(--accent-limit-bg); padding: 10px 14px;
  border-radius: var(--radius-sm); margin-top: 12px;
}
.limits strong { font-style: normal; color: var(--ink-2); font-weight: 600; }

/* Table */
.doc-table { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 14px; }
.doc-table th, .doc-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: start; vertical-align: top; }
.doc-table th { background: var(--bg-soft); font-weight: 600; color: var(--ink-2); }
.doc-table tr:last-child td { border-bottom: 0; }

/* Two-column nav-where blocks */
.where-block {
  background: var(--bg-soft); border-radius: var(--radius-sm);
  padding: 10px 14px; margin: 8px 0 14px; font-size: 13.5px;
  display: flex; gap: 10px; align-items: flex-start;
  border: 1px dashed var(--line);
}
.where-block .material-symbols-outlined { color: var(--navy); font-size: 20px; }
.where-block strong { color: var(--ink); }

/* Demo clips. Each figure shows a still poster until the reader clicks it;
   help-toggle.js then swaps in the animated WebP. Keeping the animation
   opt-in matters twice over: 20-odd looping clips would be ~30 MB on every
   page view, and a wall of simultaneous motion is hard to read past. It
   also means the page is static by default, so there is nothing to suppress
   for prefers-reduced-motion.

   The EN and AR bodies are separate <div>s that CSS hides outright, and a
   display:none figure never intersects the viewport — so loading="lazy"
   fetches only the active language's posters. */
.doc-demo { margin: 16px 0 18px; }
.doc-demo__frame {
  position: relative; display: block; width: 100%; padding: 0;
  background: var(--bg-soft); color: inherit; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow);
}
.doc-demo__frame:hover { border-color: var(--navy); }
.doc-demo__frame:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.doc-demo__img { display: block; width: 100%; height: auto; }
/* A dark scrim in both themes: --navy inverts to a light blue in dark mode,
   which would leave the white icon almost unreadable. */
.doc-demo__play {
  position: absolute; inset: 0; margin: auto;
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 23, 42, .78); color: #fff;
  transition: opacity .12s ease, transform .12s ease, background .12s ease;
}
.doc-demo__play .material-symbols-outlined { font-size: 36px; vertical-align: 0; }
.doc-demo__frame:hover .doc-demo__play { background: rgba(15, 23, 42, .92); transform: scale(1.06); }
/* While playing, the pause badge stays out of the way until you reach for it. */
.doc-demo__frame[data-playing] .doc-demo__play { opacity: 0; }
.doc-demo__frame[data-playing]:hover .doc-demo__play,
.doc-demo__frame[data-playing]:focus-visible .doc-demo__play { opacity: 1; }
.doc-demo figcaption {
  margin-top: 8px; font-size: 13px; color: var(--muted); text-align: start;
}

/* Print */
@media print {
  body { background: #fff; color: #000; }
  .doc-topbar, .doc-toc, .doc-toc-mobile, .doc-backlink, .doc-langgroup, .doc-iconbtn { display: none !important; }
  .doc-shell { display: block; padding: 0; max-width: 100%; }
  section.doc-section { page-break-inside: avoid; box-shadow: none; border-color: #ccc; }
  .doc-hero { background: #003355 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* Figures print whatever frame is loaded — the poster, unless the reader
     played the clip. The play badge is an on-screen affordance only. */
  .doc-demo { page-break-inside: avoid; }
  .doc-demo__play { display: none !important; }
  .doc-demo__frame { box-shadow: none; border-color: #ccc; }
}

/* Responsive */
@media (max-width: 980px) {
  .doc-shell { grid-template-columns: 1fr; gap: 0; padding: 16px; }
  .doc-toc { display: none; }
  .doc-toc-mobile { display: block; }
  .doc-hero { padding: 22px 20px; }
  .doc-hero h1 { font-size: 22px; }
  section.doc-section { padding: 20px 18px; }
  .doc-topbar__inner { padding: 8px 14px; gap: 8px; }
  .doc-brand__subtitle { display: none; }
  .doc-backlink span:not(.material-symbols-outlined) { display: none; }
}
@media (max-width: 480px) {
  .doc-langgroup button { padding: 5px 10px; font-size: 12px; }
}

/* Wide reference tables become stacked cards rather than overflowing the
   section and giving the whole page a horizontal scrollbar. Opt-in with
   .doc-table--stack, and label every cell after the first with data-th.
   No language plumbing: the EN and AR bodies are separate <div>s, so the
   Arabic table simply carries Arabic in its own data-th. */
@media (max-width: 640px) {
  .doc-table--stack thead { display: none; }
  .doc-table--stack tr {
    display: block; background: var(--bg-soft);
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 8px 12px; margin-bottom: 10px;
  }
  .doc-table--stack td { display: block; border-bottom: 0; padding: 4px 0; }
  .doc-table--stack td::before {
    content: attr(data-th); display: block;
    font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 600;
  }
  .doc-table--stack td:first-child { font-size: 15px; font-weight: 600; }
  .doc-table--stack td:first-child::before { display: none; }
}
/* A4 is ~794 CSS px so the query above should not fire when printing, but
   that width is not guaranteed — restore a real table explicitly. */
@media print {
  .doc-table--stack thead { display: table-header-group; }
  .doc-table--stack tr { display: table-row; background: none; border: 0; padding: 0; }
  .doc-table--stack td { display: table-cell; }
  .doc-table--stack td::before { display: none; }
}
