/* EnergyLink360 EMS — documentation / online book layout */

:root {
  --doc-bg: #f8fafc;
  --doc-surface: #ffffff;
  --doc-body: #374151;
  --doc-heading: #111827;
  --doc-sidebar-text: #334155;
  --doc-muted: #4b5563;
  --doc-border: #e5e7eb;
  --doc-accent: #2563eb;
  --doc-accent-hover: #1d4ed8;
  --doc-sidebar-w: 260px;
  --doc-outline-w: 200px;
  --doc-content-max: 920px;
  /* No separate doc-topbar anymore — the site <header> from style.css is the
     only bar. Kept as a variable (0) rather than rewriting every calc()
     below in case a slim sub-bar comes back later. */
  --doc-topbar-h: 0px;
  /* site <header> height: 40px logo + 14px*2 padding + 1px border. */
  --site-header-h: 69px;
  --doc-font: 'IBM Plex Sans Thai', 'IBM Plex Sans', 'Segoe UI', Tahoma, sans-serif;
  --doc-mono: ui-monospace, 'Cascadia Code', Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.doc-manual {
  margin: 0;
  font-family: var(--doc-font);
  font-size: 16px;
  line-height: 1.75;
  color: var(--doc-body);
  background: var(--doc-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* ── Search results status banner (shown while using the top-nav search box) ── */
.doc-search-status {
  position: relative;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--doc-accent-hover);
  background: #fff;
  border-bottom: 1px solid var(--doc-border);
  display: none;
}

.doc-search-status.is-visible {
  display: block;
}

/* ── Mobile "Contents" toggle (sidebar is off-canvas below 860px) ── */
.doc-menu-toggle {
  display: none;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--doc-heading);
  background: var(--doc-surface);
  border: none;
  border-bottom: 1px solid var(--doc-border);
  cursor: pointer;
}

/* ── Layout ── */
.doc-layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--site-header-h) - var(--doc-topbar-h));
}

/* ── Left sidebar TOC ── */
.doc-sidebar {
  position: sticky;
  top: calc(var(--site-header-h) + var(--doc-topbar-h));
  flex: 0 0 var(--doc-sidebar-w);
  width: var(--doc-sidebar-w);
  height: calc(100vh - var(--site-header-h) - var(--doc-topbar-h));
  overflow-y: auto;
  padding: 24px 0 32px;
  border-right: 1px solid var(--doc-border);
  background: var(--doc-surface);
}

.doc-sidebar-label {
  padding: 0 20px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
}

.doc-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-nav-link {
  display: block;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--doc-sidebar-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}

.doc-nav-link:hover {
  color: var(--doc-heading);
}

.doc-nav-link.is-active {
  color: var(--doc-accent);
  border-left-color: var(--doc-accent);
  font-weight: 600;
  background: transparent;
}

/* ── Main reading area ── */
.doc-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 36px 28px 72px;
}

.doc-article-wrap {
  width: 100%;
  max-width: var(--doc-content-max);
}

.doc-chapter {
  display: none;
  background: var(--doc-surface);
  padding: 44px 52px 52px;
  border: 1px solid var(--doc-border);
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(17, 24, 39, 0.04);
}

.doc-chapter.is-active {
  display: block;
}

.doc-chapter.doc-search-visible {
  display: block;
  margin-bottom: 28px;
}

.doc-lead {
  font-size: 17px;
  line-height: 1.75;
  color: var(--doc-muted);
  margin: 0 0 32px;
}

.doc-chapter h1 {
  font-size: 2.125rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin: 0 0 16px;
  color: var(--doc-heading);
}

.doc-chapter h2 {
  font-size: 1.375rem;
  font-weight: 700;
  line-height: 1.35;
  margin: 2.4em 0 0.85em;
  padding-top: 0.25em;
  color: var(--doc-heading);
  scroll-margin-top: 72px;
}

.doc-chapter h2:first-of-type {
  margin-top: 1.75em;
}

.doc-chapter h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.45;
  margin: 1.75em 0 0.6em;
  color: var(--doc-heading);
  scroll-margin-top: 72px;
}

.doc-chapter p {
  margin: 0 0 1.05em;
}

.doc-chapter ul,
.doc-chapter ol {
  margin: 0 0 1.15em;
  padding-left: 1.5em;
}

.doc-chapter li {
  margin-bottom: 0.5em;
}

.doc-chapter li > ul,
.doc-chapter li > ol {
  margin-top: 0.4em;
  margin-bottom: 0.4em;
}

.doc-chapter a {
  color: var(--doc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(37, 99, 235, 0.35);
}

.doc-chapter a:hover {
  color: var(--doc-accent-hover);
  text-decoration-color: var(--doc-accent-hover);
}

.doc-chapter code,
.doc-chapter kbd {
  font-family: var(--doc-mono);
  font-size: 0.875em;
  color: var(--doc-heading);
  background: #f3f4f6;
  border: 1px solid var(--doc-border);
  border-radius: 4px;
  padding: 0.12em 0.4em;
}

.doc-pre {
  font-family: var(--doc-mono);
  font-size: 0.875em;
  line-height: 1.55;
  color: var(--doc-heading);
  background: #f8fafc;
  border: 1px solid var(--doc-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 1.25em;
  overflow-x: auto;
  white-space: pre;
}

.doc-chapter kbd {
  font-size: 0.8125em;
}

.doc-chapter em {
  font-style: italic;
}

.doc-chapter strong {
  font-weight: 600;
  color: var(--doc-heading);
}

.doc-chapter hr {
  border: none;
  border-top: 1px solid var(--doc-border);
  margin: 2.5em 0;
}

/* Tables */
.doc-table-wrap {
  overflow-x: auto;
  margin: 0 0 1.5em;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  line-height: 1.6;
}

.doc-table th,
.doc-table td {
  padding: 11px 14px;
  text-align: left;
  border: 1px solid var(--doc-border);
  vertical-align: top;
}

.doc-table th {
  background: #fff;
  font-weight: 600;
  color: var(--doc-heading);
}

.doc-table td {
  color: var(--doc-body);
}

.doc-table tbody tr:nth-child(even) td {
  background: #fafafa;
}

/* Callouts — minimal tint, strong text */
.doc-callout {
  margin: 1.35em 0 1.5em;
  padding: 14px 16px 14px 14px;
  border-left: 4px solid var(--doc-border);
  border-radius: 0;
  background: #fff;
  font-size: 15px;
  line-height: 1.7;
  color: var(--doc-body);
}

.doc-callout-title {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.doc-callout p:last-child {
  margin-bottom: 0;
}

.doc-callout-note {
  border-left-color: #2563eb;
  background: #fafbff;
}

.doc-callout-note .doc-callout-title {
  color: #1d4ed8;
}

.doc-callout-tip {
  border-left-color: #059669;
  background: #fafffb;
}

.doc-callout-tip .doc-callout-title {
  color: #047857;
}

.doc-callout-warning {
  border-left-color: #d97706;
  background: #fffdf8;
}

.doc-callout-warning .doc-callout-title {
  color: #b45309;
}

/* Search highlight */
.doc-search-hit {
  background: #fde68a;
  color: var(--doc-heading);
  border-radius: 2px;
  padding: 0 1px;
}

.doc-chapter.doc-no-match {
  display: none !important;
}

.doc-block.doc-no-match {
  display: none !important;
}

/* ── Right outline ── */
.doc-outline {
  position: sticky;
  top: calc(var(--site-header-h) + var(--doc-topbar-h));
  flex: 0 0 var(--doc-outline-w);
  width: var(--doc-outline-w);
  height: calc(100vh - var(--site-header-h) - var(--doc-topbar-h));
  overflow-y: auto;
  padding: 32px 16px 32px 0;
}

.doc-outline-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 12px;
}

.doc-outline-nav {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-outline-nav a {
  display: block;
  padding: 5px 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: #6b7280;
  text-decoration: none;
}

.doc-outline-nav a:hover {
  color: var(--doc-accent);
}

.doc-outline-nav a.is-active {
  color: var(--doc-accent);
  font-weight: 600;
}

.doc-outline-nav .outline-h3 {
  padding-left: 12px;
  font-size: 12px;
}

.doc-outline-empty {
  font-size: 12.5px;
  color: #9ca3af;
  font-style: italic;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .doc-outline {
    display: none;
  }
}

@media (max-width: 860px) {
  .doc-menu-toggle {
    display: inline-flex;
  }

  .doc-sidebar {
    position: fixed;
    top: calc(var(--site-header-h) + var(--doc-topbar-h));
    left: 0;
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
  }

  .doc-sidebar.is-open {
    transform: translateX(0);
  }

  .doc-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: calc(var(--site-header-h) + var(--doc-topbar-h)) 0 0 0;
    z-index: 80;
    background: rgba(17, 24, 39, 0.4);
  }

  .doc-sidebar-backdrop.is-open {
    display: block;
  }

  .doc-chapter {
    padding: 28px 22px 36px;
  }

  .doc-search {
    min-width: 140px;
    max-width: 160px;
  }

  .doc-topbar-subtitle {
    display: none;
  }
}

/* ── Version history chapter ── */
.doc-version-current {
  color: var(--doc-accent);
}

.doc-version-block {
  margin: 0 0 28px;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--doc-border);
}

.doc-version-block--current {
  padding: 16px 18px 20px;
  margin-bottom: 32px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #f8fbff;
}

.doc-version-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 8px;
}

.doc-version-title {
  margin: 0;
  font-size: 1.15rem;
  color: var(--doc-heading);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.doc-version-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #1d4ed8;
  background: #dbeafe;
  border: 1px solid #93c5fd;
  border-radius: 999px;
  padding: 2px 10px;
  vertical-align: middle;
}

.doc-version-date {
  font-size: 0.875rem;
  color: var(--doc-muted);
}

.doc-version-summary {
  margin: 0 0 10px;
  color: var(--doc-body);
}

.doc-version-components {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 12px;
  font-size: 0.875rem;
  color: var(--doc-muted);
}

.doc-version-component strong {
  color: var(--doc-heading);
  font-weight: 600;
}

.doc-version-changes {
  margin: 0;
  padding-left: 1.25rem;
}

.doc-version-changes li {
  margin-bottom: 6px;
}

.doc-version-changes li:last-child {
  margin-bottom: 0;
}

/* ── Print ── */
@media print {
  .doc-topbar,
  .doc-sidebar,
  .doc-outline,
  .doc-sidebar-backdrop,
  .doc-search-status {
    display: none !important;
  }

  body.doc-manual {
    background: #fff;
    font-size: 11pt;
    line-height: 1.6;
    color: #111827;
  }

  .doc-layout {
    display: block;
    min-height: auto;
  }

  .doc-main {
    padding: 0;
    display: block;
  }

  .doc-article-wrap {
    max-width: none;
  }

  .doc-chapter {
    display: block !important;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    page-break-before: always;
  }

  .doc-chapter:first-child {
    page-break-before: avoid;
  }

  .doc-chapter h1,
  .doc-chapter h2,
  .doc-chapter h3 {
    color: #111827;
  }

  .doc-chapter h1 {
    font-size: 18pt;
  }

  .doc-chapter h2 {
    font-size: 14pt;
    page-break-after: avoid;
  }

  .doc-chapter h3 {
    page-break-after: avoid;
  }

  .doc-table {
    font-size: 10pt;
  }

  .doc-callout {
    border: 1px solid #d1d5db;
    page-break-inside: avoid;
  }

  .doc-version-block {
    page-break-inside: avoid;
    border-bottom: 1px solid #d1d5db;
  }

  .doc-version-block--current {
    border: 1px solid #9ca3af;
    background: #f9fafb;
  }

  .doc-version-badge {
    border: 1px solid #6b7280;
    color: #111827;
    background: #f3f4f6;
  }

  a {
    color: #111827 !important;
    text-decoration: none !important;
  }
}
