/* ============================================================
   Opsalis Docs — 3-Column Layout (Swagger-style)
   Left nav | Center content | Right TOC
   Inherits site colors from /style.css
   ============================================================ */

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

:root {
  --bg-primary:   #f8fafc;
  --bg-secondary: #ffffff;
  --bg-code:      #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted:   #94a3b8;
  --accent:       #00b894;
  --accent-hover: #00a381;
  --accent-dim:   rgba(0, 184, 148, 0.06);
  --border:       #e2e8f0;
  --border-accent: rgba(0, 184, 148, 0.25);
  --radius:       6px;
  --font-sans:    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
                  Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
  --font-mono:    'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono',
                  Menlo, Consolas, 'Courier New', monospace;
  --nav-width:    240px;
  --toc-width:    200px;
  --header-height: 56px;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1rem);
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Top Header --- */
.docs-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
}

.docs-header-logo {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.docs-header-logo:hover {
  color: var(--accent);
  text-decoration: none;
}

.docs-header-logo span {
  color: var(--accent);
}

.docs-header-tag {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.docs-header-links {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  align-items: center;
}

.docs-header-links a {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}

.docs-header-links a:hover {
  color: var(--accent);
}

/* --- 3-Column Layout --- */
.docs-layout {
  display: grid;
  grid-template-columns: var(--nav-width) 1fr var(--toc-width);
  min-height: 100vh;
  padding-top: var(--header-height);
}

/* --- Left Nav --- */
.docs-nav {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  font-size: 0.875rem;
}

.docs-nav::-webkit-scrollbar {
  width: 4px;
}

.docs-nav::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.nav-section {
  padding: 0 1.25rem;
  margin-bottom: 1.5rem;
}

.nav-section-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.nav-link {
  display: block;
  padding: 0.3rem 0.75rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius);
  transition: background 0.1s, color 0.1s;
  line-height: 1.5;
}

.nav-link:hover {
  background: var(--accent-dim);
  color: var(--accent);
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent-dim);
  color: var(--accent);
  font-weight: 600;
  border-left: 2px solid var(--accent);
  padding-left: calc(0.75rem - 2px);
}

.nav-link.sub {
  padding-left: 1.5rem;
  font-size: 0.825rem;
}

/* --- Center Content --- */
.docs-content {
  max-width: 780px;
  padding: 2rem 3rem 4rem;
}

.docs-content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  line-height: 1.3;
}

.docs-content .lead {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
  line-height: 1.7;
}

.docs-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.docs-content h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.docs-content p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.docs-content a {
  color: var(--accent);
  text-decoration: none;
}

.docs-content a:hover {
  text-decoration: underline;
}

.docs-content ul, .docs-content ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.docs-content li {
  margin-bottom: 0.35rem;
}

.docs-content strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* Inline code */
.docs-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #0f766e;
  border: 1px solid var(--border);
}

/* Code blocks */
.docs-content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
}

.docs-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.825rem;
  line-height: 1.7;
  color: #334155;
  white-space: pre;
  display: block;
}

/* Tables */
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
}

.docs-content th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.docs-content td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
}

/* Info box */
.info-box {
  background: var(--accent-dim);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
}

.info-box p {
  color: var(--text-secondary);
  margin: 0;
}

.info-box strong {
  color: var(--accent);
}

/* Warning box */
.warn-box {
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 0.875rem 1.25rem;
  margin: 1rem 0 1.5rem;
  font-size: 0.9rem;
}

.warn-box p {
  color: #92400e;
  margin: 0;
}

/* Method badges */
.method {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.method-get    { background: #dbeafe; color: #1d4ed8; }
.method-post   { background: #d1fae5; color: #047857; }
.method-put    { background: #fef3c7; color: #b45309; }
.method-delete { background: #fee2e2; color: #dc2626; }

/* Endpoint path */
.endpoint {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  margin: 0.5rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Right TOC --- */
.docs-toc {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 1.5rem 1rem 1.5rem 0;
  font-size: 0.8rem;
}

.docs-toc::-webkit-scrollbar {
  width: 4px;
}

.docs-toc::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

.toc-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.toc-link {
  display: block;
  padding: 0.2rem 0;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.1s;
  line-height: 1.5;
}

.toc-link:hover {
  color: var(--accent);
  text-decoration: none;
}

.toc-link.active {
  color: var(--accent);
  font-weight: 600;
}

.toc-link.sub {
  padding-left: 0.75rem;
  font-size: 0.775rem;
}

/* --- Page nav (prev/next) --- */
.docs-page-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  gap: 1rem;
}

.page-nav-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s;
  flex: 1;
  max-width: 50%;
}

.page-nav-link:hover {
  border-color: var(--border-accent);
  text-decoration: none;
}

.page-nav-link .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.page-nav-link .title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
}

.page-nav-link.next {
  text-align: right;
  margin-left: auto;
}

/* --- Mobile responsive --- */
@media (max-width: 1100px) {
  .docs-layout {
    grid-template-columns: var(--nav-width) 1fr;
  }
  .docs-toc {
    display: none;
  }
}

@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-nav {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: 280px;
    height: calc(100vh - var(--header-height));
    z-index: 90;
    box-shadow: 4px 0 12px rgba(0,0,0,0.08);
  }
  .docs-nav.open {
    display: block;
  }
  .docs-content {
    padding: 1.5rem 1rem 3rem;
  }
  .docs-header .mobile-nav-toggle {
    display: flex;
  }
}

/* Mobile nav toggle (hidden on desktop) */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  margin-right: 0.75rem;
}

.mobile-nav-toggle svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
}

/* --- TOC scroll spy highlight (JS-driven) --- */
.toc-link[data-active="true"] {
  color: var(--accent);
  font-weight: 600;
}
