/*
Theme Name: Support AR Docs
Theme URI: https://docs.support-ar.com
Author: WebCraker
Author URI: https://support-ar.com
Description: Bilingual (Arabic / English) documentation theme for Support AR products. Pages under /ar/ and /en/ form the two language trees; the theme builds the sidebar, language switch, table of contents and previous/next links from them.
Version: 1.0.2
Requires at least: 6.0
Requires PHP: 8.0
License: Proprietary
Text Domain: sar-docs
*/

/* ---------- Tokens ---------- */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #0f1b2d;
  --ink-2: #44546a;
  --ink-3: #5a687c;
  --btn-bg: #087f9a;
  --btn-ink: #ffffff;
  --badge-bg: #b5470b;
  --line: #dde5ee;
  --brand: #0aa5c7;
  --brand-ink: #087f9a;
  --brand-soft: #e2f6fb;
  --accent: #ff8a3d;
  --code-bg: #0f1b2d;
  --code-ink: #e6edf6;
  --note: #0aa5c7;   --note-bg: #e8f7fb;
  --tip: #17a673;    --tip-bg: #e7f7f0;
  --warn: #d98a00;   --warn-bg: #fff5e0;
  --danger: #d6455d; --danger-bg: #fdecef;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 8px 24px rgba(15, 27, 45, .06);
  --header-h: 64px;
  --font: "IBM Plex Sans Arabic", "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Tahoma, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1320;
  --surface: #111c2d;
  --surface-2: #17243a;
  --ink: #e8eef6;
  --ink-2: #b3c0d1;
  --ink-3: #93a3b8;
  --btn-bg: #2cc3e3;
  --btn-ink: #04202a;
  --badge-bg: #ff8a3d;
  --badge-ink: #2a1200;
  --line: #22324a;
  --brand: #2cc3e3;
  --brand-ink: #5fd6ef;
  --brand-soft: #0f2c3a;
  --code-bg: #060c16;
  --note-bg: #0e2a36; --tip-bg: #0d2a22; --warn-bg: #2e2410; --danger-bg: #301722;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; height: auto; }
code, kbd, pre { font-family: var(--mono); }
.screen-reader-text, .sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap;
}
.skip-link:focus {
  position: fixed; top: 8px; inset-inline-start: 8px; z-index: 100; width: auto; height: auto; clip: auto;
  background: var(--surface); padding: 8px 14px; border-radius: 8px; box-shadow: var(--shadow);
}
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: 1440px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.brand-name b { color: var(--brand); font-weight: 700; }
.brand-tag {
  font-size: 12px; font-weight: 600; color: var(--brand-ink); background: var(--brand-soft);
  padding: 2px 8px; border-radius: 99px; margin-inline-start: 2px;
}
.header-search { flex: 1; max-width: 420px; margin-inline-start: auto; position: relative; }
.header-search input {
  width: 100%; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); font: inherit; font-size: 14px;
  padding-inline: 38px 12px;
}
.header-search input:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px var(--brand-soft); }
.header-search svg { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn, .lang-switch {
  height: 40px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 0 10px;
}
.icon-btn:hover, .lang-switch:hover { color: var(--ink); border-color: var(--brand); text-decoration: none; }
.icon-btn svg, .lang-switch svg { width: 18px; height: 18px; }
.menu-toggle { display: none; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
.back-site { font-size: 14px; color: var(--ink-2); font-weight: 600; padding: 0 6px; white-space: nowrap; }

/* ---------- Layout ---------- */
.layout {
  max-width: 1440px; margin: 0 auto;
  display: grid; grid-template-columns: 280px minmax(0, 1fr) 240px; gap: 0;
}
.layout.no-toc { grid-template-columns: 280px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: var(--header-h); align-self: start;
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 24px 16px 40px; border-inline-end: 1px solid var(--line);
}
.content { padding: 32px 48px 72px; min-width: 0; }
.toc {
  position: sticky; top: var(--header-h); align-self: start;
  max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 32px 20px 40px 8px; font-size: 14px;
}

/* ---------- Sidebar nav ---------- */
.nav-group { margin-bottom: 22px; }
.nav-label {
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3); padding: 0 10px 6px;
}
:lang(ar) .nav-label { letter-spacing: 0; text-transform: none; font-size: 13px; }
.nav-list { list-style: none; margin: 0; padding: 0; }
.nav-list a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; color: var(--ink-2); font-size: 15px; font-weight: 500; line-height: 1.4;
}
.nav-list a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-list a.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 700; }
.nav-ico {
  width: 28px; height: 28px; flex: none; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); overflow: hidden;
}
.nav-ico img { width: 20px; height: 20px; object-fit: contain; }
.nav-ico svg { width: 16px; height: 16px; color: var(--brand-ink); }
.badge {
  margin-inline-start: auto; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px;
  background: var(--badge-bg); color: var(--badge-ink, #fff); line-height: 1.6;
}
.nav-sub { list-style: none; margin: 2px 0 6px; padding: 0; padding-inline-start: 48px; }
.nav-sub a { padding: 4px 10px; font-size: 14px; font-weight: 500; color: var(--ink-3); border-radius: 8px; }
.nav-sub a.active { background: none; color: var(--brand-ink); }
.sidebar-foot { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 14px; }
.sidebar-foot a { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 14px; color: var(--ink-2); font-weight: 500; }
.sidebar-foot svg { width: 16px; height: 16px; }

/* ---------- Article ---------- */
.crumbs { font-size: 14px; color: var(--ink-3); margin-bottom: 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.crumbs a { color: var(--ink-3); }
.crumbs .sep { opacity: .6; }
.article { max-width: 820px; }
.article-head { margin-bottom: 28px; }
.article-head h1 { font-size: clamp(28px, 3.4vw, 38px); line-height: 1.25; margin: 0 0 10px; letter-spacing: -.01em; }
.lede { font-size: 18px; color: var(--ink-2); margin: 0; }
.meta-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--ink-2);
  unicode-bidi: plaintext;
}
.chip.brand { background: var(--brand-soft); border-color: transparent; color: var(--brand-ink); }

.prose { font-size: 16.5px; }
.prose > * + * { margin-top: 1em; }
.prose h2 {
  font-size: 24px; line-height: 1.35; margin: 2.2em 0 .6em; padding-top: 1.2em; border-top: 1px solid var(--line);
  display: flex; align-items: baseline; gap: 10px;
}
.prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.prose h3 { font-size: 19px; margin: 1.6em 0 .4em; }
.prose h2 .anchor, .prose h3 .anchor { opacity: 0; color: var(--ink-3); font-weight: 400; font-size: .8em; }
.prose h2:hover .anchor, .prose h3:hover .anchor { opacity: 1; }
.prose p, .prose li { color: var(--ink); }
.prose ul, .prose ol { padding-inline-start: 1.4em; }
.prose li + li { margin-top: .35em; }
.prose strong { font-weight: 700; }
.prose :not(pre) > code {
  font-size: .86em; background: var(--surface-2); border: 1px solid var(--line); padding: .1em .4em; border-radius: 6px;
  direction: ltr; unicode-bidi: isolate; overflow-wrap: anywhere;
}
.prose kbd, .prose .ui {
  font-family: var(--font); font-size: .9em; font-weight: 600; padding: .05em .45em; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--line); border-bottom-width: 2px; white-space: nowrap;
}
.prose .path { font-weight: 600; color: var(--ink); direction: ltr; unicode-bidi: isolate; }
.prose .path .arr { color: var(--ink-3); margin: 0 .25em; }
.prose table { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.prose th, .prose td { padding: 10px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--line); }
.prose th { background: var(--surface-2); font-weight: 700; font-size: 14px; }
.prose tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* code blocks */
.prose pre, .code {
  position: relative; direction: ltr; text-align: left;
  background: var(--code-bg); color: var(--code-ink); border-radius: 12px;
  padding: 42px 18px 16px; overflow-x: auto; font-size: 14px; line-height: 1.6;
}
.prose pre code { background: none; border: 0; padding: 0; color: inherit; white-space: pre; font-size: inherit; }
.code-wrap { position: relative; }
.copy-btn {
  position: absolute; top: 8px; right: 8px;
  font: 600 12px/1 var(--font); color: #cfe3f1; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px; padding: 7px 10px; cursor: pointer;
}
.copy-btn:hover { background: rgba(255,255,255,.16); }
.copy-btn.done { color: #7ee2b8; border-color: #7ee2b8; }

/* callouts */
.callout {
  --c: var(--note); --cbg: var(--note-bg);
  background: var(--cbg); border: 1px solid color-mix(in srgb, var(--c) 30%, transparent);
  border-inline-start: 4px solid var(--c);
  border-radius: 12px; padding: 14px 18px; font-size: 15.5px;
}
.callout > :first-child { margin-top: 0; }
.callout > :last-child { margin-bottom: 0; }
.callout .callout-title { display: block; font-weight: 700; color: var(--c); margin-bottom: 4px; }
.callout.tip { --c: var(--tip); --cbg: var(--tip-bg); }
.callout.warn { --c: var(--warn); --cbg: var(--warn-bg); }
.callout.danger { --c: var(--danger); --cbg: var(--danger-bg); }

/* steps */
.prose ol.steps { list-style: none; counter-reset: step; padding: 0; margin-inline: 0; }
.prose ol.steps > li {
  counter-increment: step; position: relative; padding-inline-start: 52px; padding-bottom: 22px; margin: 0;
}
.prose ol.steps > li::before {
  content: counter(step); position: absolute; inset-inline-start: 0; top: 0;
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--brand); color: var(--brand-ink); font-weight: 700; font-size: 15px;
}
.prose ol.steps > li::after {
  content: ""; position: absolute; inset-inline-start: 16px; top: 38px; bottom: 4px; width: 2px; background: var(--line);
}
.prose ol.steps > li:last-child::after { display: none; }
.prose ol.steps > li > :first-child { margin-top: 4px; }
.prose ol.steps > li > strong:first-child { display: block; font-size: 17px; }

/* figures */
.prose figure { margin: 1.4em 0; }
.prose figure img, .shot {
  display: block; border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow); background: var(--surface); cursor: zoom-in;
}
.prose figcaption { font-size: 14px; color: var(--ink-3); margin-top: 10px; text-align: center; }
.prose figure.phone img { max-width: 320px; margin-inline: auto; }
.prose .shots { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }

/* file tree */
.tree {
  direction: ltr; text-align: left; font-family: var(--mono); font-size: 14px; line-height: 1.9;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; white-space: pre; overflow-x: auto;
}
.tree .d { color: var(--brand-ink); font-weight: 600; }
.tree .c { color: var(--ink-3); }

/* event chips */
.events { display: flex; flex-wrap: wrap; gap: 8px; direction: ltr; justify-content: flex-start; }
:lang(ar) .events { justify-content: flex-end; }
.events code { overflow-wrap: anywhere; }

/* cards (landing) */
.hero {
  position: relative; overflow: hidden; border-radius: 20px; padding: 44px 40px; margin-bottom: 32px;
  background:
    radial-gradient(600px 240px at 85% -10%, color-mix(in srgb, var(--brand) 35%, transparent), transparent 70%),
    radial-gradient(400px 200px at 0% 120%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--surface);
  border: 1px solid var(--line);
}
:lang(ar) .hero { background:
    radial-gradient(600px 240px at 15% -10%, color-mix(in srgb, var(--brand) 35%, transparent), transparent 70%),
    radial-gradient(400px 200px at 100% 120%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    var(--surface); }
.hero h1 { font-size: clamp(28px, 4vw, 42px); line-height: 1.2; margin: 0 0 10px; }
.hero p { font-size: 18px; color: var(--ink-2); margin: 0 0 22px; max-width: 620px; }
.hero-search { position: relative; max-width: 520px; }
.hero-search input {
  width: 100%; height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface);
  font: inherit; font-size: 16px; color: var(--ink); padding-inline: 46px 16px; box-shadow: var(--shadow);
}
.hero-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.hero-search svg { position: absolute; inset-inline-start: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ink-3); }
.section-title { font-size: 20px; margin: 8px 0 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.card {
  display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow);
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--brand); text-decoration: none; }
.card-top { display: flex; align-items: center; gap: 12px; }
.card-logo { width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); display: grid; place-items: center; border: 1px solid var(--line); overflow: hidden; }
.card-logo img { width: 34px; height: 34px; object-fit: contain; }
.card h3 { margin: 0; font-size: 18px; }
.card p { margin: 0; color: var(--ink-2); font-size: 15px; }
.card .more { margin-top: auto; font-weight: 700; color: var(--brand-ink); font-size: 14px; }
.card .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.help-strip {
  margin-top: 32px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 20px 22px; border-radius: 16px; background: var(--brand-soft); border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
}
.help-strip p { margin: 0; flex: 1; min-width: 220px; color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 42px; padding: 0 18px; border-radius: 10px;
  background: var(--btn-bg); color: var(--btn-ink); font-weight: 700; font-size: 15px; border: 0;
}
.btn:hover { text-decoration: none; filter: brightness(1.05); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }

/* TOC */
.toc-title { font-size: 12px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 10px; }
:lang(ar) .toc-title { text-transform: none; letter-spacing: 0; font-size: 13px; }
.toc ol { list-style: none; margin: 0; padding: 0; border-inline-start: 2px solid var(--line); }
.toc a { display: block; padding: 5px 12px; margin-inline-start: -2px; border-inline-start: 2px solid transparent; color: var(--ink-3); line-height: 1.45; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--brand-ink); border-inline-start-color: var(--brand); font-weight: 600; }
.toc-help { margin-top: 20px; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); }
.toc-help a { font-weight: 700; }

/* Prev / next */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 56px; }
.pager a {
  display: block; padding: 14px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.pager a:hover { border-color: var(--brand); text-decoration: none; }
.pager small { display: block; color: var(--ink-3); font-size: 13px; }
.pager b { font-size: 16px; }
.pager .next { text-align: end; grid-column: 2; }
.updated { margin-top: 36px; font-size: 14px; color: var(--ink-3); display: flex; gap: 14px; flex-wrap: wrap; justify-content: space-between; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 22px 20px; font-size: 14px; color: var(--ink-3); }
.site-footer .inner { max-width: 1440px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; }

/* Search results */
.results { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.results a { display: block; padding: 16px 18px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.results a:hover { border-color: var(--brand); text-decoration: none; }
.results small { color: var(--ink-3); display: block; }
.results mark { background: color-mix(in srgb, var(--accent) 30%, transparent); color: inherit; border-radius: 3px; }

/* Lightbox */
.lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(6, 12, 22, .86); display: none;
  align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); background: #fff; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .layout, .layout.no-toc { grid-template-columns: 260px minmax(0, 1fr); }
  .toc { display: none; }
  .content { padding: 28px 32px 64px; }
}
@media (max-width: 860px) {
  .layout, .layout.no-toc { grid-template-columns: minmax(0, 1fr); }
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; top: var(--header-h); bottom: 0; inset-inline-start: 0; width: min(320px, 86vw); height: auto;
    background: var(--surface); z-index: 60; transform: translateX(-105%); transition: transform .2s ease;
    box-shadow: var(--shadow);
  }
  [dir="rtl"] .sidebar { transform: translateX(105%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: var(--header-h) 0 0; background: rgba(6,12,22,.4); z-index: 55; }
  .content { padding: 22px 16px 56px; }
  .header-inner { padding: 0 12px; gap: 8px; }
  .header-search { display: none; }
  .back-site, .brand-tag { display: none; }
  .header-actions { margin-inline-start: auto; }
  .hero { padding: 28px 20px; }
  .prose .shots { grid-template-columns: 1fr; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
@media print { .site-header, .sidebar, .toc, .pager, .copy-btn { display: none !important; } .layout { display: block; } }
