/* ═══ POLYSTATS — Documentation Page v4 ═══ */

/* ── Scope all docs styles ── */
.docs-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 60px;
  font-family: 'Inter', -apple-system, sans-serif;
  color: var(--text);
  line-height: 1.6;
}

/* ── Inline code fix ── */
.docs-container code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.88em;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--cyan);
  white-space: nowrap;
}
.docs-container b,
.docs-container strong {
  font-weight: 600;
  color: var(--text);
}

/* ═══ Hero ═══ */
.docs-hero {
  text-align: center;
  padding: 48px 20px 36px;
  margin-bottom: 28px;
  position: relative;
}
.docs-hero::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border), var(--cyan), var(--border), transparent);
}
.docs-hero-title {
  font-family: 'Orbitron', monospace;
  font-size: 2.4rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--green), var(--cyan), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 6px;
  margin-bottom: 10px;
  background-size: 200% 200%;
  animation: heroGrad 6s ease infinite;
}
@keyframes heroGrad {
  0%,100% { background-position: 0% 50%; }
  50%     { background-position: 100% 50%; }
}
.docs-hero-sub {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  max-width: 560px;
  margin: 0 auto 8px;
}
.docs-hero-sub2 {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--muted);
  max-width: 500px;
  margin: 0 auto;
}
.docs-hero-meta {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.docs-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  transition: border-color .2s, background .2s;
}
.docs-meta-chip:hover {
  border-color: var(--cyan);
  background: rgba(0,212,255,0.05);
}
.docs-meta-chip .chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px currentColor;
}

/* ═══ Stats Row ═══ */
.docs-stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}
.docs-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  transition: border-color .2s, transform .15s;
}
.docs-stat:hover {
  border-color: var(--green);
  transform: translateY(-2px);
}
.docs-stat-val {
  font-family: 'Orbitron', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  display: block;
  margin-bottom: 4px;
}
.docs-stat-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ═══ TOC ═══ */
.docs-toc {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 24px;
}
.docs-toc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.docs-toc-title {
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 2px;
  text-transform: uppercase;
}
.docs-toc-btns { display: flex; gap: 6px; }
.docs-toc-btn {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  padding: 4px 12px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}
.docs-toc-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: rgba(0,212,255,0.06);
}
.docs-toc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px 12px;
}
.docs-toc-link {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  padding: 6px 8px;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  text-decoration: none;
}
.docs-toc-link:hover {
  color: var(--cyan);
  background: rgba(0,212,255,0.05);
  text-decoration: none;
}
.docs-toc-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  min-width: 22px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 0;
}
.docs-toc-icon {
  font-size: 14px;
  width: 18px;
  text-align: center;
}

/* ═══ Sections (L1) ═══ */
.docs-section {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color .2s;
}
.docs-section:hover {
  border-color: rgba(0,212,255,0.3);
}
.docs-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(90deg, var(--panel), var(--bg2));
  border-left: 4px solid var(--cyan);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.docs-section-header:hover {
  background: linear-gradient(90deg, var(--panel2), var(--panel));
}
.docs-section-header.green  { border-left-color: var(--green); }
.docs-section-header.purple { border-left-color: var(--purple); }
.docs-section-header.gold   { border-left-color: var(--gold); }
.docs-section-header.red    { border-left-color: var(--red); }
.docs-section-header.cyan   { border-left-color: var(--cyan); }

.docs-section-icon {
  font-size: 18px;
  width: 26px;
  text-align: center;
  flex-shrink: 0;
  line-height: 1;
}
.docs-section-num {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.docs-section-title {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
  flex: 1;
}
.docs-section-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 9px;
}
.docs-section-chevron {
  font-size: 14px;
  color: var(--muted);
  transition: transform .25s ease;
  flex-shrink: 0;
}
.docs-section.collapsed .docs-section-chevron {
  transform: rotate(-90deg);
}
.docs-section-body {
  padding: 18px 18px 14px;
  background: var(--bg);
  animation: docsFadeIn .25s ease;
}
.docs-section.collapsed .docs-section-body {
  display: none;
}
@keyframes docsFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══ Sub-sections (L2) ═══ */
.docs-sub {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg2);
}
.docs-sub-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  cursor: pointer;
  user-select: none;
  transition: background .15s;
}
.docs-sub-header:hover {
  background: var(--panel2);
}
.docs-sub-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.docs-sub-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  flex: 1;
}
.docs-sub-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 7px;
}
.docs-sub-chev {
  font-size: 12px;
  color: var(--muted);
  transition: transform .2s;
}
.docs-sub.collapsed .docs-sub-chev {
  transform: rotate(-90deg);
}
.docs-sub-body {
  padding: 14px;
  animation: docsFadeIn .2s ease;
}
.docs-sub.collapsed .docs-sub-body {
  display: none;
}

/* ═══ Explainer ═══ */
.docs-explain {
  background: linear-gradient(135deg, rgba(0,212,255,0.05), rgba(0,255,136,0.03));
  border: 1px solid rgba(0,212,255,0.18);
  border-radius: 10px;
  padding: 16px 18px;
  margin: 10px 0;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.docs-explain-icon {
  font-size: 24px;
  flex-shrink: 0;
  line-height: 1.2;
}
.docs-explain-text {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}
.docs-explain-text b {
  color: var(--cyan);
  font-weight: 600;
}

/* ═══ Pipeline ═══ */
.docs-pipeline {
  display: flex;
  flex-direction: column;
  margin: 14px 0;
  padding: 4px 0;
}
.docs-pipe-step {
  display: flex;
  align-items: stretch;
  min-height: 52px;
}
.docs-pipe-line {
  width: 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
}
.docs-pipe-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: var(--bg);
  flex-shrink: 0;
  z-index: 1;
  margin-top: 4px;
}
.docs-pipe-dot.active {
  background: var(--cyan);
  box-shadow: 0 0 10px rgba(0,212,255,0.5);
}
.docs-pipe-connector {
  width: 2px;
  flex: 1;
  background: var(--border);
  margin: 2px 0;
}
.docs-pipe-step:last-child .docs-pipe-connector {
  display: none;
}
.docs-pipe-content {
  flex: 1;
  padding: 0 0 12px 14px;
}
.docs-pipe-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.docs-pipe-desc {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ═══ Text ═══ */
.docs-text {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}
.docs-text p {
  margin-bottom: 10px;
}

/* ═══ Feature cards ═══ */
.docs-features {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.docs-feat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 14px;
  text-align: center;
  transition: border-color .2s, transform .15s;
}
.docs-feat:hover {
  border-color: var(--cyan);
  transform: translateY(-2px);
}
.docs-feat-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
  line-height: 1.2;
}
.docs-feat-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.docs-feat-desc {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* ═══ Info cards ═══ */
.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
  margin: 10px 0;
}
.docs-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  transition: border-color .2s;
}
.docs-card:hover {
  border-color: var(--cyan);
}
.docs-card-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
  margin-bottom: 6px;
}
.docs-card-body {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

/* ═══ File tree ═══ */
.docs-tree {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.9;
  overflow-x: auto;
  color: var(--text);
}
.docs-tree .dir  { color: var(--cyan); font-weight: 600; }
.docs-tree .file { color: var(--text); }
.docs-tree .desc { color: var(--muted); font-style: italic; }

/* ═══ Tables ═══ */
.docs-table-wrap {
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.docs-table th {
  font-family: 'JetBrains Mono', monospace;
  background: var(--panel);
  color: var(--cyan);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.docs-table td {
  font-family: 'Inter', sans-serif;
  padding: 8px 14px;
  border-bottom: 1px solid rgba(26,58,74,0.3);
  color: var(--text);
  font-size: 12px;
}
.docs-table tbody tr:last-child td {
  border-bottom: none;
}
.docs-table tr:hover td {
  background: rgba(0,212,255,0.03);
}
.docs-table .t-file {
  font-family: 'JetBrains Mono', monospace;
  color: var(--green);
  font-weight: 500;
}
.docs-table .t-route {
  font-family: 'JetBrains Mono', monospace;
  color: var(--cyan);
}
.docs-table .t-desc {
  color: var(--muted);
}

/* ═══ Code block ═══ */
.docs-code {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.7;
  overflow-x: auto;
  color: var(--text);
  margin: 10px 0;
}
/* Override inline code style inside code blocks */
.docs-code code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.docs-code .kw  { color: var(--purple); }
.docs-code .str { color: var(--green); }
.docs-code .cm  { color: var(--muted); font-style: italic; }
.docs-code .fn  { color: var(--cyan); }
.docs-code .num { color: var(--yellow); }

/* ═══ Tags ═══ */
.docs-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
  line-height: 1.4;
}
.docs-tag.green  { background: rgba(0,255,136,0.12); color: var(--green); }
.docs-tag.cyan   { background: rgba(0,212,255,0.12); color: var(--cyan); }
.docs-tag.purple { background: rgba(168,85,247,0.12); color: var(--purple); }
.docs-tag.gold   { background: rgba(255,215,0,0.12);  color: var(--gold); }
.docs-tag.red    { background: rgba(255,68,102,0.12);  color: var(--red); }

/* ═══ Flow ═══ */
.docs-flow {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 10px 0;
}
.docs-flow-step {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  white-space: nowrap;
}
.docs-flow-arrow {
  color: var(--cyan);
  font-size: 14px;
}

/* ═══ ER cards ═══ */
.docs-er {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.docs-er-table {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color .2s;
}
.docs-er-table:hover {
  border-color: var(--cyan);
}
.docs-er-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.docs-er-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #000;
  font-family: 'JetBrains Mono', monospace;
}
.docs-er-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.docs-er-db {
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 3px;
  margin-left: auto;
}
.docs-er-cols {
  padding: 0;
  list-style: none;
  margin: 0;
}
.docs-er-col {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  border-bottom: 1px solid rgba(26,58,74,0.2);
}
.docs-er-col:last-child { border-bottom: none; }
.docs-er-col-name { color: var(--text); flex: 1; }
.docs-er-col-type { color: var(--muted); font-size: 10px; }
.docs-er-col-badge {
  font-size: 8px;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.docs-er-col-badge.pk  { background: rgba(255,215,0,0.2);  color: var(--gold); }
.docs-er-col-badge.fk  { background: rgba(0,212,255,0.15); color: var(--cyan); }
.docs-er-col-badge.uq  { background: rgba(168,85,247,0.15);color: var(--purple); }
.docs-er-col-badge.idx { background: rgba(0,255,136,0.12); color: var(--green); }
.docs-er-col-badge.enc { background: rgba(255,68,102,0.15); color: var(--red); }
.docs-er-desc {
  padding: 10px 14px;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  color: var(--muted);
  background: rgba(0,212,255,0.02);
  border-top: 1px solid rgba(26,58,74,0.2);
  line-height: 1.6;
}

/* ═══ Relations ═══ */
.docs-rel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin: 12px 0;
  overflow-x: auto;
}
.docs-rel-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
}
.docs-rel-tbl {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 10px;
  color: var(--green);
  font-weight: 500;
  white-space: nowrap;
}
.docs-rel-line {
  display: flex;
  align-items: center;
  gap: 2px;
}
.docs-rel-line .line-dash {
  width: 24px;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--muted), var(--muted) 3px, transparent 3px, transparent 6px);
}
.docs-rel-type {
  font-size: 9px;
  color: var(--cyan);
  padding: 2px 6px;
  background: rgba(0,212,255,0.08);
  border-radius: 3px;
}

/* ═══ Color swatches ═══ */
.docs-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.docs-swatch {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
  transition: border-color .2s;
}
.docs-swatch:hover { border-color: var(--cyan); }
.docs-swatch-color {
  width: 100%;
  height: 32px;
  border-radius: 6px;
  margin-bottom: 6px;
}
.docs-swatch-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--muted);
  line-height: 1.4;
}

/* ═══ Footer ═══ */
.docs-footer {
  margin-top: 24px;
  padding: 28px;
  background: linear-gradient(135deg, var(--panel), var(--bg2));
  border: 1px solid var(--border);
  border-radius: 12px;
  text-align: center;
}

/* ═══ Responsive ═══ */
@media (max-width: 768px) {
  .docs-hero-title { font-size: 1.6rem; letter-spacing: 3px; }
  .docs-toc-grid { grid-template-columns: 1fr 1fr; }
  .docs-cards, .docs-features { grid-template-columns: 1fr; }
  .docs-er { grid-template-columns: 1fr; }
  .docs-flow { flex-direction: column; }
  .docs-flow-arrow { transform: rotate(90deg); }
  .docs-section-title { font-size: 11px; }
  .docs-section-icon { display: none; }
  .docs-stats-row { grid-template-columns: repeat(3, 1fr); }
  .docs-toc-top { flex-direction: column; gap: 8px; align-items: flex-start; }
}
@media (max-width: 480px) {
  .docs-hero-title { font-size: 1.3rem; letter-spacing: 2px; }
  .docs-toc-grid { grid-template-columns: 1fr; }
  .docs-hero-meta { flex-direction: column; gap: 6px; }
  .docs-stats-row { grid-template-columns: repeat(2, 1fr); }
  .docs-features { grid-template-columns: repeat(2, 1fr); }
  .docs-section-badge { display: none; }
}
