/* === Dark theme (default) === */
:root {
  --bg: #0f1117;
  --bg-card: #161923;
  --bg-code: #0d0f14;
  --border: #252836;
  --text: #c9cdd6;
  --text-dim: #6b7280;
  --text-bright: #f0f2f5;
  --accent: #3b82f6;
  --accent-dim: #2563eb;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --sidebar-w: 260px;
  --logo-h: 57px;        /* logo row height (pad+img+pad) */
}

/* === Light theme === */
html.light {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-code: #f0f1f4;
  --border: #dde0e6;
  --text: #3b3f4a;
  --text-dim: #7c828d;
  --text-bright: #1a1d24;
  --accent: #2563eb;
  --accent-dim: #1d4ed8;
  --green: #16a34a;
  --yellow: #ca8a04;
  --red: #dc2626;
}

html.light code { color: #b45309; }

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; scroll-padding-top: 2rem; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 15px;
}

/* ========== Sidebar ========== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 0;
  z-index: 10;
}

/* Logo — pinned at the top */
.sidebar-logo {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  border-left: 3px solid transparent !important;
  background: var(--bg-card);
  flex-shrink: 0;
}

.sidebar-logo img { height: 36px; width: auto; }
.sidebar-logo .brand { font-weight: 700; font-size: 1.1rem; color: var(--text-bright); }
.sidebar-logo .sub { font-size: 0.7rem; color: var(--text-dim); display: block; }

/* Sidebar footer — pinned at bottom, matches portal layout */
.sidebar-footer {
  flex-shrink: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

/* Footer items — mirror portal's sidebar buttons exactly */
.sidebar-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 6px;
  background: none;
  color: var(--text-dim);
  font-size: 0.875rem;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.sidebar-btn:hover {
  background: rgba(59,130,246,0.08);
  color: var(--text-bright);
  text-decoration: none;
}

/* Theme icon / label visibility */
.sidebar-btn .icon-moon,
.sidebar-btn .label-dark  { display: none; }
.sidebar-btn .icon-sun,
.sidebar-btn .label-light { display: inline; }
html.light .sidebar-btn .icon-sun,
html.light .sidebar-btn .label-light { display: none; }
html.light .sidebar-btn .icon-moon,
html.light .sidebar-btn .label-dark  { display: inline; }

/* Nav links area — scrollable middle section */
.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-top: 0.5rem;
  padding-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar-nav h4 {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  padding: 0.9rem 1.25rem 0.3rem;
  font-weight: 700;
}

.sidebar-nav a {
  display: block;
  padding: 0.3rem 1.25rem;
  color: var(--text);
  text-decoration: none;
  font-size: 0.82rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
  background: rgba(59,130,246,0.08);
  color: var(--text-bright);
}
.sidebar-nav a.active {
  border-left-color: var(--accent);
  color: var(--accent);
  background: rgba(59,130,246,0.06);
  font-weight: 500;
}

/* ========== Main content ========== */
.main {
  margin-left: var(--sidebar-w);
  padding: 2.5rem 3rem 4rem;
  max-width: 860px;
}

/* ========== Mobile ========== */
.menu-toggle { display: none; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; padding: 1.5rem 1.25rem 3rem; }
  .menu-toggle {
    display: flex;
    position: fixed;
    top: 0.75rem; left: 0.75rem;
    z-index: 20;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
  }
  .overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9;
  }
  .overlay.open { display: block; }
}

/* ========== Typography ========== */
h1 { font-size: 2rem; color: var(--text-bright); margin-bottom: 0.75rem; font-weight: 700; }
h2 { font-size: 1.45rem; color: var(--text-bright); margin: 2.5rem 0 0.75rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--border); font-weight: 600; }
h3 { font-size: 1.1rem; color: var(--text-bright); margin: 1.75rem 0 0.5rem; font-weight: 600; }

p { margin-bottom: 0.9rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

ul, ol { padding-left: 1.5rem; margin-bottom: 1rem; }
li { margin-bottom: 0.3rem; }

strong { color: var(--text-bright); }

/* ========== Code ========== */
code {
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.85em;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.15em 0.4em;
  color: #e5c07b;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text);
}

/* ========== Cards / callouts ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.callout {
  border-left: 4px solid var(--accent);
  background: rgba(59,130,246,0.06);
  padding: 0.9rem 1.25rem;
  border-radius: 0 8px 8px 0;
  margin-bottom: 1.25rem;
}
.callout.warn { border-left-color: var(--yellow); background: rgba(234,179,8,0.06); }
.callout.danger { border-left-color: var(--red); background: rgba(239,68,68,0.06); }
.callout.success { border-left-color: var(--green); background: rgba(34,197,94,0.06); }

/* ========== Tables ========== */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}

th {
  text-align: left;
  font-weight: 600;
  color: var(--text-bright);
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

tr:hover td { background: rgba(255,255,255,0.02); }
html.light tr:hover td { background: rgba(0,0,0,0.02); }

/* ========== Steps ========== */
.steps { counter-reset: step; list-style: none; padding-left: 0; }
.steps li {
  counter-increment: step;
  padding-left: 2.5rem;
  position: relative;
  margin-bottom: 1.25rem;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: 0;
  width: 1.75rem; height: 1.75rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ========== Badges ========== */
.badge {
  display: inline-block;
  padding: 0.15em 0.55em;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-blue { background: rgba(59,130,246,0.15); color: var(--accent); }
.badge-green { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-yellow { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-red { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-orange { background: rgba(249,115,22,0.15); color: #f97316; }

/* ========== Mode toggle (SaaS / Self-hosted) ========== */
.mode-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.mode-bar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}
.mode-toggle {
  display: inline-flex;
  gap: 0.4rem;
}
.mode-toggle button {
  padding: 0.55em 1.4em;
  border: none;
  border-radius: 6px;
  background: rgba(128,128,128,0.12);
  color: var(--text);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.15s;
}
.mode-toggle button:hover:not(.active) {
  background: rgba(128,128,128,0.2);
}
.mode-toggle button.active[data-mode="saas"] {
  background: var(--accent);
  color: #fff;
}
.mode-toggle button.active[data-mode="selfhosted"] {
  background: #f97316;
  color: #fff;
}
/* Hide non-active mode doc content. Toggle buttons override below. */
.mode-saas [data-mode="selfhosted"]       { display: none; }
.mode-selfhosted [data-mode="saas"]       { display: none; }
.mode-toggle button[data-mode]            { display: inline-flex !important; }

/* ========== Diagram ========== */
.diagram-img {
  display: block;
  width: 100%;
  max-width: 750px;
  margin: 0 auto 1.25rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1rem;
}

/* ========== Hero intro ========== */
.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
}

/* ========== Feature grid ========== */
.features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 600px) {
  .features { grid-template-columns: 1fr; }
}

.feature {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.25rem 1rem;
}

.feature:hover {
  border-color: var(--accent-dim);
}

.feature-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  line-height: 1;
}

.feature h3 {
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
  color: var(--text-bright);
}

.feature p {
  font-size: 0.85rem;
  margin: 0;
  color: var(--text);
  line-height: 1.6;
}

/* ========== Footer ========== */
.doc-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
}
