/* ── Documentation Page — Sidebar Layout ─────────────────────── */
.docs-layout {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
}

/* ── Sidebar ─────────────────────────────────────────────────── */
.docs-sidebar {
    width: 220px;
    flex-shrink: 0;
    padding: 24px 16px;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 57px;
    height: calc(100vh - 57px);
    overflow-y: auto;
}
.docs-sidebar a {
    display: block;
    color: var(--text-muted);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    margin-bottom: 2px;
}
.docs-sidebar a:hover { color: var(--text); background: rgba(88, 166, 255, .06); }
.docs-sidebar .section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin: 16px 8px 4px;
    font-weight: 700;
}

/* ── Content ─────────────────────────────────────────────────── */
.docs-content {
    flex: 1;
    padding: 32px 40px;
    min-width: 0;
    line-height: 1.7;
}
.docs-content h1 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--accent);
}
.docs-content > p {
    margin-bottom: 12px;
}

/* ── Sections ────────────────────────────────────────────────── */
.docs-section {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.docs-section:last-child { border-bottom: none; }
.docs-section h2 {
    font-size: 20px;
    margin: 40px 0 12px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.docs-section h2:first-child { margin-top: 0; }
.docs-section h3 {
    font-size: 16px;
    margin: 16px 0 8px;
    color: var(--purple);
}
.docs-section h4 { font-size: 14px; margin-bottom: 4px; }
.docs-section p {
    font-size: 13px;
    margin-bottom: 8px;
    color: var(--text);
    line-height: 1.7;
}
.docs-section code {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--accent);
}
.docs-section ul, .docs-section ol { margin: 0 0 12px 20px; }
.docs-section li { margin-bottom: 4px; font-size: 13px; }

/* ── Endpoint cards ──────────────────────────────────────────── */
.docs-endpoint {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 0 8px;
    padding: 12px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 600;
}
.docs-endpoint code {
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}
.docs-method {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.docs-method.get    { background: rgba(88,166,255,.12); color: var(--accent); }
.docs-method.post   { background: rgba(63,185,80,.12); color: var(--success); }
.docs-method.put    { background: rgba(210,153,34,.15); color: var(--warning); }
.docs-method.delete { background: rgba(248,81,73,.12); color: var(--error); }
.docs-method.ws     { background: rgba(188,140,255,.12); color: var(--purple); }

/* ── Params table ────────────────────────────────────────────── */
.docs-params {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0 16px;
    font-size: 13px;
}
.docs-params th, .docs-params td {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    vertical-align: top;
}
.docs-params th {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 600;
    background: var(--surface);
}
.docs-params code { font-size: 12px; }

/* ── Code blocks ─────────────────────────────────────────────── */
.docs-code {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px 16px;
    margin: 8px 0 16px;
    overflow-x: auto;
}
.docs-code pre {
    font-family: var(--mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    margin: 0;
    white-space: pre;
    background: none;
    border: none;
    padding: 0;
    border-radius: 0;
}
.docs-code pre .cm { color: var(--text-muted); }

/* ── Code tabs (display toggling) ────────────────────────────── */
.code-examples .code-block { display: none; }
.code-examples .code-block.active { display: block; }

/* ── Notes ───────────────────────────────────────────────────── */
.docs-note {
    background: #302a18;
    border-left: 2px solid var(--warning);
    padding: 6px 10px;
    border-radius: 0 var(--radius) var(--radius) 0;
    font-size: 12px;
    margin-bottom: 12px;
}

.docs-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 16px 0;
}

/* ── Architecture Diagram ────────────────────────────────────── */
.arch-diagram {
    margin: 12px 0 16px;
    padding: 20px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}
.arch-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}
.arch-row-mid { gap: 20px; }
.arch-row-workers { gap: 8px; flex-wrap: wrap; }
.arch-node {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 8px 13px;
    text-align: center;
    min-width: 100px;
    transition: border-color 0.15s;
}
.arch-node:hover { border-color: var(--accent); }
.arch-icon { font-size: 20px; margin-bottom: 2px; }
.arch-label { font-size: 12px; font-weight: 600; color: var(--text); }
.arch-port { font-size: 11px; font-family: var(--mono); color: var(--accent); margin-top: 2px; }
.arch-desc { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

.arch-client  { border-color: var(--text-muted); }
.arch-nginx   { border-left: 2px solid var(--success); }
.arch-api     { border-left: 2px solid var(--accent); }
.arch-redis   { border-left: 2px solid var(--error); }
.arch-volume  { border-left: 2px solid var(--warning); border-style: dashed; border-width: 1px; border-left-width: 2px; }
.arch-worker  { min-width: 120px; }
.arch-w-sam   { border-left: 2px solid var(--purple); }
.arch-w-yolo  { border-left: 2px solid var(--accent); }

/* Horizontal arrow */
.arch-arrow-h {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 2px;
    min-width: 50px;
    position: relative;
    height: 20px;
    justify-content: center;
}
.arch-arrow-h::before {
    content: '';
    display: block;
    width: 100%;
    height: 0;
    border-top: 1.5px solid var(--text-muted);
    position: relative;
}
.arch-arrow-h::after {
    content: '';
    position: absolute;
    right: -1px;
    top: 50%;
    width: 0; height: 0;
    border-left: 5px solid var(--text-muted);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
}
.arch-arrow-h span {
    font-size: 9px;
    color: var(--text-muted);
    position: absolute;
    top: -10px;
    white-space: nowrap;
}

/* Vertical arrow */
.arch-arrow-v {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    height: 32px;
    width: 1px;
    background: var(--text-muted);
    margin: 0 auto;
}
.arch-arrow-v::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 0; height: 0;
    border-top: 5px solid var(--text-muted);
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
}
.arch-arrow-v span {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    font-style: italic;
}

/* ── Flow Diagram (lifecycle) ────────────────────────────────── */
.flow-diagram {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin: 12px 0 16px;
    padding: 13px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
.flow-step {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding: 8px 10px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-width: 120px;
    flex-shrink: 0;
    transition: border-color 0.15s;
}
.flow-step:hover { border-color: var(--accent); }
.flow-num {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.flow-title { font-weight: 600; font-size: 12px; margin-bottom: 3px; }
.flow-text { font-size: 11px; color: var(--text-muted); line-height: 1.45; }
.flow-text code { font-size: 10px; }
.flow-arrow-h {
    display: flex;
    align-items: center;
    padding: 0 3px;
    flex-shrink: 0;
    position: relative;
    width: 24px;
}
.flow-arrow-h::before {
    content: '';
    display: block;
    width: 100%;
    height: 0;
    border-top: 1.5px solid var(--border);
}
.flow-arrow-h::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 0; height: 0;
    border-left: 5px solid var(--border);
    border-top: 3px solid transparent;
    border-bottom: 3px solid transparent;
}

.docs-steps {
    padding-left: 20px;
    margin: 6px 0 12px;
}
.docs-steps li { font-size: 12px; margin-bottom: 3px; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
    .docs-sidebar { display: none; }
    .docs-content { padding: 20px 16px; }
}

/* ── Code tabs ───────────────────────────────────────────────── */
.code-tabs {
  margin-bottom: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.code-tabs__header {
  display: flex;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.code-tab {
  background: none;
  border: none;
  color: var(--text-dim);
  padding: 8px 16px;
  font-size: 12px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-family: inherit;
}
.code-tab:hover { color: var(--text); }
.code-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.code-tabs__body {
  display: none;
  margin: 0;
  padding: 16px;
  background: var(--surface);
  font-size: 13px;
  overflow-x: auto;
}
.code-tabs__body.active { display: block; }

/* ── Extra badges ────────────────────────────────────────────── */
.badge--put {
  background: #d29922;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}
.badge--delete {
  background: #da3633;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { padding: 20px 16px; }
}
