/* Portal Documentation v3 — Shared Styles */
/* Dark theme: Inter font, indigo accent, accordion sidebar */

:root {
  --bg: #0a0e17;
  --bg2: #111827;
  --bg3: rgba(17, 24, 39, 0.7);
  --border: rgba(255, 255, 255, 0.06);
  --glow: rgba(99, 102, 241, 0.3);
  --text: #f1f5f9;
  --t2: #94a3b8;
  --t3: #64748b;
  --accent: #6366f1;
  --accent2: #a5b4fc;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --cyan: #22d3ee;
  --pink: #f472b6;
  --r: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  line-height: 1.6;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(52, 211, 153, 0.05) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ── */
.page {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 100vh;
}

/* ── Sidebar ── */
#sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
  background: rgba(10, 14, 23, 0.95);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar__logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  text-decoration: none;
  color: var(--text);
}

.sidebar__icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #6366f1, #34d399);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.sidebar__title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar__sub {
  font-size: 0.65rem;
  color: var(--t3);
}

.sidebar__section {
  margin-bottom: 0.5rem;
}

.sidebar__heading {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t3);
  margin-bottom: 0.3rem;
  padding: 0.35rem 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar__heading--toggle {
  cursor: pointer;
  border-radius: 6px;
  user-select: none;
  transition: background .15s, color .15s;
}

.sidebar__heading--toggle:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--t2);
}

.sidebar__chevron {
  transition: transform .2s ease;
  flex-shrink: 0;
  color: var(--t3);
}

/* Collapsed state */
.sidebar__section.collapsed .sidebar__items {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  margin: 0;
  pointer-events: none;
}

.sidebar__section.collapsed .sidebar__chevron {
  transform: rotate(-90deg);
}

/* Expanded state */
.sidebar__items {
  max-height: 500px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .25s ease, opacity .2s ease;
}

#sidebar a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.5rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--t2);
  font-size: 0.75rem;
  font-weight: 500;
  transition: all .15s;
}

#sidebar a:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

#sidebar a.active {
  color: var(--accent2);
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.15);
}

#sidebar a .emoji {
  font-size: 0.85rem;
  width: 1.2rem;
  text-align: center;
  flex-shrink: 0;
}

/* ── Main Content ── */
.content {
  max-width: 800px;
  padding: 2rem 2.5rem 4rem;
}

.content h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 0.5rem;
}

.content .subtitle {
  color: var(--t3);
  font-size: 0.8rem;
  margin-bottom: 2rem;
}

/* ── Sections ── */
.section {
  margin-bottom: 2.5rem;
  animation: fadeIn .5s ease both;
}

.section:nth-child(2) { animation-delay: .05s; }
.section:nth-child(3) { animation-delay: .1s; }
.section:nth-child(4) { animation-delay: .15s; }

.section h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--accent2);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  margin: 1.25rem 0 0.5rem;
  color: var(--t2);
}

.section p {
  font-size: 0.82rem;
  color: var(--t2);
  line-height: 1.7;
  margin-bottom: 0.75rem;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Cards ── */
.card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
}

.card h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.card p {
  font-size: 0.75rem;
  color: var(--t3);
  line-height: 1.5;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card--link {
  text-decoration: none;
  transition: all .2s;
  cursor: pointer;
}

.card--link:hover {
  border-color: var(--glow);
  transform: translateY(-2px);
}

.card--link h4 { color: var(--text); }
.card--link p { color: var(--t3); }

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-bottom: 0.75rem;
}

th {
  text-align: left;
  color: var(--t3);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.68rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--t2);
}

tr:hover td { background: rgba(255, 255, 255, 0.02); }
td:first-child { color: var(--text); font-weight: 500; }

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--green { background: rgba(52, 211, 153, 0.15); color: var(--green); }
.badge--amber { background: rgba(251, 191, 36, 0.15); color: var(--amber); }
.badge--red { background: rgba(248, 113, 113, 0.15); color: var(--red); }
.badge--blue { background: rgba(99, 102, 241, 0.15); color: var(--accent2); }
.badge--pink { background: rgba(244, 114, 182, 0.15); color: var(--pink); }
.badge--cyan { background: rgba(34, 211, 238, 0.15); color: var(--cyan); }

/* ── Callouts ── */
.callout {
  background: var(--bg3);
  border-left: 3px solid var(--green);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 0.75rem 1rem;
  margin-bottom: 0.5rem;
  font-size: 0.78rem;
  color: var(--t2);
}

.callout strong { color: var(--green); }
.callout--amber { border-left-color: var(--amber); }
.callout--amber strong { color: var(--amber); }
.callout--blue { border-left-color: var(--accent); }
.callout--blue strong { color: var(--accent2); }
.callout--pink { border-left-color: var(--pink); }
.callout--pink strong { color: var(--pink); }

/* ── Flow diagrams ── */
.flow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

.flow__node {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  transition: all .2s;
}

.flow__node:hover {
  border-color: var(--glow);
  background: rgba(99, 102, 241, 0.08);
}

.flow__node--active { border-color: var(--green); color: var(--green); }
.flow__node--muted { opacity: 0.5; }
.flow__arrow { color: var(--t3); font-size: 0.8rem; }

/* ── Schema fields ── */
.schema-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.schema-card h4 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.schema-card .desc {
  font-size: 0.72rem;
  color: var(--t3);
  margin-bottom: 0.5rem;
}

.field {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 0.72rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.field:last-child { border-bottom: none; }
.field-name { color: var(--accent2); font-weight: 500; font-family: 'Courier New', monospace; }
.field-type { color: var(--t3); }
.field-desc { color: var(--t2); font-size: 0.68rem; max-width: 60%; text-align: right; }

/* ── Code blocks ── */
code {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  background: rgba(99, 102, 241, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  color: var(--accent2);
}

pre {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--t2);
  line-height: 1.6;
  overflow-x: auto;
  margin-bottom: 1rem;
}

/* ── Mindmap ── */
.mindmap {
  width: 100%;
  min-height: 420px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.mindmap svg { width: 100%; height: 100%; }

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 2rem 0;
  font-size: 0.7rem;
  color: var(--t3);
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

.footer a {
  color: var(--accent2);
  text-decoration: none;
}

.footer a:hover { text-decoration: underline; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .page {
    grid-template-columns: 1fr;
  }

  #sidebar {
    position: fixed;
    left: -260px;
    width: 260px;
    z-index: 100;
    transition: left .3s ease;
  }

  #sidebar.open { left: 0; }

  .content {
    padding: 1.5rem 1rem 3rem;
  }

  .content h1 { font-size: 1.3rem; }

  .card-grid { grid-template-columns: 1fr; }

  .mobile-toggle {
    display: flex !important;
  }
}

.mobile-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 101;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
