/* ============================================================
   OmniSCADA Documentation Portal — Apple / Antigravity Aesthetic
   ============================================================ */

:root {
  --brand-red: #D7263D;
  --brand-red-deep: #A61C2E;
  --brand-red-glow: rgba(215, 38, 61, 0.18);
  --brand-teal: #0E9E9E;

  --bg-primary: #FFFFFF;
  --bg-secondary: #F6F6F8;
  --bg-card: #FFFFFF;
  --bg-sidebar: #FBFBFC;
  --bg-header: rgba(255, 255, 255, 0.85);

  --text-primary: #1D1D1F;
  --text-secondary: #56565B;
  --text-tertiary: #86868B;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --header-h: 64px;
  --sidebar-w: 280px;
  --toc-w: 240px;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

[data-theme="dark"] {
  --bg-primary: #0B0B0E;
  --bg-secondary: #121217;
  --bg-card: #18181E;
  --bg-sidebar: #0E0E12;
  --bg-header: rgba(11, 11, 14, 0.85);

  --text-primary: #F5F5F7;
  --text-secondary: #A8A8B2;
  --text-tertiary: #72727C;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.65;
  transition: background 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ── Sticky Header ─────────────────────────────────────────── */
.header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--bg-header); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border); z-index: 100;
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
}
.header__brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.header__brand img { height: 26px; width: auto; }
.header__logo-light { display: block; }
.header__logo-dark { display: none; }
[data-theme="dark"] .header__logo-light { display: none; }
[data-theme="dark"] .header__logo-dark { display: block; }
.header__badge {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--brand-red-glow); color: var(--brand-red);
  padding: 2px 8px; border-radius: 100px; border: 1px solid rgba(215, 38, 61, 0.2);
}
.header__actions { display: flex; align-items: center; gap: 12px; }

/* ── Search Trigger ────────────────────────────────────────── */
.search-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  color: var(--text-tertiary); font-size: 13px; padding: 7px 14px; border-radius: 100px;
  cursor: pointer; transition: all 0.2s; min-width: 180px; justify-content: space-between;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text-primary); }
.search-btn kbd {
  background: var(--bg-card); border: 1px solid var(--border-strong);
  padding: 2px 6px; border-radius: 4px; font-size: 11px; font-family: var(--font-mono);
}

/* ── Action Buttons & Theme Toggle ─────────────────────────── */
.icon-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 10px;
  width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer; transition: all 0.2s;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
.landing-link {
  font-size: 13px; font-weight: 600; color: var(--text-secondary);
  padding: 8px 14px; border-radius: 100px; border: 1px solid var(--border); transition: all 0.2s;
}
.landing-link:hover { color: var(--text-primary); border-color: var(--border-strong); background: var(--bg-secondary); }
.burger-btn { display: none; }

/* ── Main Layout ───────────────────────────────────────────── */
.layout {
  display: flex; min-height: 100vh; padding-top: var(--header-h); max-width: 1560px; margin: 0 auto;
}

/* ── Left Sidebar Navigation ───────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: 20px 12px 40px; border-right: 1px solid var(--border); background: var(--bg-sidebar);
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.nav-group { margin-bottom: 8px; }
.nav-group__header {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: transparent; border: none; border-radius: var(--radius-sm);
  cursor: pointer; color: var(--text-tertiary); transition: background 0.15s ease, color 0.15s ease;
  user-select: none; text-align: left; font-family: inherit;
}
.nav-group__header:hover { background: var(--bg-secondary); color: var(--text-primary); }
.nav-group__header:focus-visible { outline: 2px solid var(--brand-red); outline-offset: 1px; }
.nav-group__title {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: inherit;
}
.nav-group__meta { display: inline-flex; align-items: center; gap: 7px; }
.nav-group__count {
  font-size: 10px; font-weight: 600; font-variant-numeric: tabular-nums;
  padding: 1px 6px; border-radius: 100px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-tertiary); line-height: 1.3;
}
.nav-group__chevron {
  width: 13px; height: 13px; color: var(--text-tertiary);
  transform: rotate(90deg); transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
  flex-shrink: 0;
}
.nav-group.collapsed .nav-group__chevron { transform: rotate(0deg); }
.nav-group__header:hover .nav-group__chevron { color: var(--text-primary); }
.nav-group__items {
  display: grid; grid-template-rows: 1fr;
  transition: grid-template-rows 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}
.nav-group.collapsed .nav-group__items { grid-template-rows: 0fr; }
.nav-group__tree {
  min-height: 0; overflow: hidden;
  border-left: 1.5px solid var(--border);
  margin-left: 10px; padding-left: 6px; margin-top: 2px;
}
.nav-item {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); padding: 5px 10px 5px 12px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all 0.15s ease; margin-bottom: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item:hover { color: var(--text-primary); background: var(--bg-secondary); }
.nav-item.active {
  color: var(--brand-red); font-weight: 600; background: var(--brand-red-glow);
  box-shadow: inset 2.5px 0 0 var(--brand-red);
}

/* ── Content Container & Typography ────────────────────────── */
.content-wrapper { flex: 1; min-width: 0; display: flex; justify-content: center; }
.article {
  max-width: 820px; width: 100%; padding: 40px 36px 80px; font-size: 15.5px;
}
.article h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.025em; margin-bottom: 16px; line-height: 1.2; }
.article h2 { font-size: 23px; font-weight: 700; letter-spacing: -0.02em; margin: 38px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.article h3 { font-size: 18px; font-weight: 600; margin: 26px 0 10px; }
.article p { margin-bottom: 18px; color: var(--text-secondary); line-height: 1.7; }
.article p strong { color: var(--text-primary); }
.article a { color: var(--brand-red); text-decoration: none; }
.article a:hover { text-decoration: underline; }
.article ul, .article ol { margin-bottom: 20px; padding-left: 22px; color: var(--text-secondary); }
.article li { margin-bottom: 6px; }
.article hr { border: none; border-top: 1px solid var(--border); margin: 36px 0; }
.article code:not(pre code) {
  font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-secondary);
  border: 1px solid var(--border); padding: 2px 6px; border-radius: 4px; color: var(--brand-red);
}

/* ── Admonition Cards (Apple Callouts) ──────────────────────── */
.admonition {
  margin: 24px 0; padding: 18px 20px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--bg-secondary);
}
.admonition__header { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.admonition__header svg { width: 18px; height: 18px; flex-shrink: 0; }
.admonition__content { font-size: 14px; line-height: 1.65; color: var(--text-secondary); }
.admonition__content p:last-child { margin-bottom: 0; }
.admonition--tip { border-color: rgba(14, 158, 158, 0.3); background: rgba(14, 158, 158, 0.05); }
.admonition--tip .admonition__header { color: var(--brand-teal); }
.admonition--note, .admonition--info { border-color: rgba(0, 122, 255, 0.3); background: rgba(0, 122, 255, 0.05); }
.admonition--note .admonition__header, .admonition--info .admonition__header { color: #007AFF; }
.admonition--warning { border-color: rgba(255, 149, 0, 0.3); background: rgba(255, 149, 0, 0.05); }
.admonition--warning .admonition__header { color: #FF9500; }
.admonition--danger, .admonition--caution { border-color: rgba(215, 38, 61, 0.3); background: var(--brand-red-glow); }
.admonition--danger .admonition__header, .admonition--caution .admonition__header { color: var(--brand-red); }

/* ── Code Blocks & Syntax Highlighting ──────────────────────── */
.code-block {
  position: relative; margin: 24px 0; border-radius: var(--radius-md);
  background: #141418; border: 1px solid rgba(255,255,255,0.08); overflow: hidden;
}
.code-block__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: rgba(255,255,255,0.04); border-bottom: 1px solid rgba(255,255,255,0.06);
  font-size: 12px; color: #8C8C9A; font-family: var(--font-mono);
}
.code-block__copy {
  background: transparent; border: none; color: #A0A0B0; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px; font-size: 12px; padding: 2px 6px; border-radius: 4px;
}
.code-block__copy:hover { color: #FFF; background: rgba(255,255,255,0.1); }
.code-block pre { margin: 0; padding: 16px; overflow-x: auto; font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6; color: #E6E6EE; }
.code-block pre code { background: none; border: none; padding: 0; color: inherit; }

/* ── Tables & Media ────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; margin: 24px 0; border-radius: var(--radius-md); border: 1px solid var(--border); }
.article table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
.article th { background: var(--bg-secondary); padding: 10px 14px; font-weight: 600; border-bottom: 1px solid var(--border); }
.article td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text-secondary); }
.article tr:last-child td { border-bottom: none; }
.article img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin: 24px auto 10px auto;
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  clear: both;
}

.doc-figure {
  margin: 28px auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  clear: both;
}
.doc-figure img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin: 0 auto;
  cursor: zoom-in;
}
.doc-figcaption {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-tertiary);
  font-style: italic;
  line-height: 1.5;
  text-align: center;
  max-width: 800px;
}
.article p > em {
  display: block;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 8px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ── Prev / Next Navigation Footer ─────────────────────────── */
.doc-nav-footer {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border);
}
.doc-nav-card {
  display: flex; flex-direction: column; padding: 16px 20px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--bg-secondary); transition: all 0.2s;
}
.doc-nav-card:hover { border-color: var(--brand-red); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.doc-nav-card--next { text-align: right; margin-left: auto; width: 100%; }
.doc-nav-card__sub { font-size: 11px; text-transform: uppercase; color: var(--text-tertiary); font-weight: 600; margin-bottom: 4px; }
.doc-nav-card__title { font-size: 15px; font-weight: 600; color: var(--text-primary); }

/* ── Right TOC Sidebar (Scrollspy) ─────────────────────────── */
.toc {
  width: var(--toc-w); flex-shrink: 0; position: sticky; top: var(--header-h);
  height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 36px 16px;
}
.toc__title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-tertiary); margin-bottom: 12px; }
.toc__list { border-left: 1px solid var(--border); padding-left: 12px; }
.toc__item { margin-bottom: 8px; }
.toc__link {
  display: block; font-size: 13px; color: var(--text-secondary); line-height: 1.4;
  transition: all 0.15s; position: relative;
}
.toc__link:hover { color: var(--text-primary); }
.toc__link.active { color: var(--brand-red); font-weight: 600; }
.toc__link--h3 { padding-left: 12px; font-size: 12px; color: var(--text-tertiary); }

/* ── Search Modal Dialog ───────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(8px);
  z-index: 200; display: flex; align-items: flex-start; justify-content: center; padding-top: 100px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%; max-width: 600px; background: var(--bg-card); border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal-search { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-search svg { width: 20px; height: 20px; color: var(--text-tertiary); }
.modal-input {
  flex: 1; background: transparent; border: none; outline: none; font-size: 16px;
  color: var(--text-primary); font-family: inherit;
}
.modal-results { max-height: 380px; overflow-y: auto; padding: 8px; }
.modal-item {
  display: flex; flex-direction: column; padding: 10px 14px; border-radius: var(--radius-sm);
  cursor: pointer; transition: background 0.15s;
}
.modal-item:hover, .modal-item.selected { background: var(--bg-secondary); }
.modal-item__category { font-size: 11px; text-transform: uppercase; font-weight: 700; color: var(--brand-red); }
.modal-item__title { font-size: 14.5px; font-weight: 600; color: var(--text-primary); }
.modal-item__desc { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.modal-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px; font-size: 12px; color: var(--text-tertiary); background: var(--bg-secondary); border-top: 1px solid var(--border);
}

/* ── Mobile Responsive ─────────────────────────────────────── */
@media (max-width: 1200px) {
  .toc { display: none; }
}
@media (max-width: 900px) {
  .sidebar {
    position: fixed; top: var(--header-h); left: -100%; bottom: 0; width: 300px;
    z-index: 90; transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .burger-btn { display: inline-flex; }
  .article { padding: 24px 20px 60px; }
  .search-btn { min-width: unset; width: 38px; padding: 0; justify-content: center; }
  .search-btn span, .search-btn kbd { display: none; }
}

/* ── Image Lightbox Modal ─────────────────────────────────────── */
.article img {
  cursor: zoom-in;
  border-radius: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.article img:hover {
  transform: scale(1.01);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.doc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(5, 8, 15, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.doc-lightbox.active {
  opacity: 1;
  pointer-events: auto;
}
.doc-lightbox__content {
  position: relative;
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.doc-lightbox.active .doc-lightbox__content {
  transform: scale(1);
}
.doc-lightbox__img {
  max-width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.12);
  cursor: zoom-out;
}
.doc-lightbox__caption {
  margin-top: 14px;
  font-size: 13.5px;
  color: #e2e8f0;
  font-weight: 500;
  text-align: center;
  max-width: 760px;
  background: rgba(15, 23, 42, 0.8);
  padding: 8px 20px;
  border-radius: 9999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.doc-lightbox__close {
  position: absolute;
  top: 24px;
  right: 28px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  line-height: 1;
  transition: all 0.2s ease;
  z-index: 10001;
}
.doc-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.08);
}

