/* ============================================================
   TokenGate — /docs
   Shell: sidebar de rutas · contenido · "en esta página"
   Usa los tokens de app/01-tokens.css (Mercury/Indigo) sin definir color propio.
   ============================================================ */

.docs-shell {
  --docs-sidebar-w: 264px;
  --docs-toc-w: 220px;
  --docs-content-max: 760px;
  --docs-gap: 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: grid;
  grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr) var(--docs-toc-w);
  gap: var(--docs-gap);
  align-items: start;
}

@media (max-width: 1180px) {
  .docs-shell { grid-template-columns: var(--docs-sidebar-w) minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 860px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); padding: 0 1rem; }
  .docs-sidebar { display: none; }
  .docs-sidebar.is-open { display: block; }
}

/* ── Sidebar de rutas ─────────────────────────────────────────── */

.docs-sidebar {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 1.75rem 0.25rem 2rem 0;
  font-size: 0.86rem;
}

.docs-search {
  position: relative;
  margin-bottom: 1.5rem;
}

.docs-search input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.7rem 0.55rem 2.1rem;
  font-size: 0.83rem;
  color: var(--text);
  font-family: inherit;
}

.docs-search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-10);
}

.docs-search svg {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.docs-nav-group { margin-bottom: 1.5rem; }

.docs-nav-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 0.65rem;
  margin-bottom: 0.4rem;
  display: block;
}

.docs-nav-link {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.42rem 0.65rem;
  border-radius: 7px;
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.3;
  border-left: 2px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
}

.docs-nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.docs-nav-link.is-active {
  color: var(--brand);
  background: var(--brand-10);
  border-left-color: var(--brand);
  font-weight: 600;
}

.docs-nav-link[hidden] { display: none; }

.docs-nav-link.is-indent {
  padding-left: 1.5rem;
  font-size: 0.82rem;
  position: relative;
}
.docs-nav-link.is-indent::before {
  content: "";
  position: absolute;
  left: 0.75rem;
  top: 50%;
  width: 5px;
  height: 1px;
  background: var(--border);
}

/* ── Contenido ────────────────────────────────────────────────── */

.docs-content {
  max-width: var(--docs-content-max);
  padding: 2.5rem 0 5rem;
  min-width: 0;
}

.docs-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}

.docs-eyebrow .docs-route-dot { color: var(--brand); }

.docs-content h1 {
  font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.65rem;
}

.docs-lede {
  font-size: 1.02rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 2.5rem;
  max-width: 60ch;
}

.docs-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 2.75rem 0 1rem;
  padding-top: 0.25rem;
  scroll-margin-top: 5.5rem;
}

.docs-content h2:first-of-type { margin-top: 0; }

.docs-content h3 {
  font-size: 1.02rem;
  font-weight: 700;
  margin: 1.75rem 0 0.75rem;
  scroll-margin-top: 5.5rem;
}

.docs-content p { color: var(--text); line-height: 1.68; margin-bottom: 1rem; font-size: 0.95rem; }
.docs-content p.muted { color: var(--text-muted); }
.docs-content ul, .docs-content ol { margin: 0 0 1.1rem 1.3rem; }
.docs-content li { color: var(--text); line-height: 1.65; font-size: 0.95rem; margin-bottom: 0.4rem; }
.docs-content li::marker { color: var(--text-muted); }
.docs-content strong { color: var(--text); font-weight: 650; }
.docs-content a:not(.btn) { color: var(--brand); text-decoration: none; border-bottom: 1px solid var(--brand-25); }
.docs-content a:not(.btn):hover { border-bottom-color: var(--brand); }

.docs-content code {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.85em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 5px;
}

.docs-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  overflow-x: auto;
  margin-bottom: 1.25rem;
  position: relative;
}

.docs-content pre code {
  background: none;
  border: none;
  padding: 0;
  color: #E4E4EE;
  font-size: 0.82rem;
  line-height: 1.65;
}

.docs-copy-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  color: #C8C8D4;
  font-size: 0.68rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.docs-copy-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ── Callouts ─────────────────────────────────────────────────── */

.docs-callout {
  display: flex;
  gap: 0.75rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.4rem;
  font-size: 0.88rem;
  line-height: 1.6;
}
.docs-callout p:last-child { margin-bottom: 0; }
.docs-callout-icon { flex-shrink: 0; font-size: 1rem; line-height: 1.5; }
.docs-callout-warning { border-left-color: var(--warning); }
.docs-callout-danger  { border-left-color: var(--danger); }
.docs-callout-success { border-left-color: var(--success); }

/* ── Request/response pair (firma visual: /docs habla el idioma del gateway) ── */

.docs-exchange {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 1.5rem;
  background: var(--surface);
}
.docs-exchange-row {
  display: grid;
  grid-template-columns: 84px 1fr;
  border-bottom: 1px solid var(--border);
}
.docs-exchange-row:last-child { border-bottom: none; }
.docs-exchange-tag {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.9rem 0.5rem;
  text-align: center;
  align-self: stretch;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 1.1rem;
}
.docs-exchange-tag.req { color: var(--brand); background: var(--brand-10); }
.docs-exchange-tag.res { color: var(--success); background: var(--success-15); }
.docs-exchange-tag.err { color: var(--danger); background: var(--danger-15); }
.docs-exchange-body { padding: 0; min-width: 0; }
.docs-exchange-body pre { border: none; border-radius: 0; margin-bottom: 0; background: transparent; }

/* ── Cards de sección (grid de entrada) ─────────────────────────── */

.docs-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.docs-entry-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1.1rem 1.2rem;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.docs-entry-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.docs-entry-card .docs-entry-route {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.7rem;
  color: var(--brand);
  margin-bottom: 0.5rem;
  display: block;
}
.docs-entry-card h3 { margin: 0 0 0.4rem; font-size: 0.98rem; }
.docs-entry-card p { margin: 0; font-size: 0.83rem; color: var(--text-muted); }

/* ── Tabla de pasos numerados (solo cuando el orden es real) ────── */

.docs-steps { list-style: none; margin: 0 0 1.75rem; padding: 0; counter-reset: docs-step; }
.docs-steps > li {
  counter-increment: docs-step;
  position: relative;
  padding: 0 0 1.4rem 2.6rem;
  border-left: 1px solid var(--border);
  margin-left: 0.9rem;
}
.docs-steps > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.docs-steps > li::before {
  content: counter(docs-step);
  position: absolute;
  left: -0.9rem;
  top: 0;
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.docs-steps h4 { font-size: 0.92rem; font-weight: 700; margin: 0 0 0.3rem; }
.docs-steps p { margin-bottom: 0; }

/* ── Tabla ────────────────────────────────────────────────────── */

.docs-content .table-wrap { margin-bottom: 1.5rem; }
.docs-content table { font-size: 0.85rem; }
.docs-content th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }

/* ── Modelo cards (referencia) ────────────────────────────────── */

.docs-model-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.1rem;
}
.docs-model-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}
.docs-model-head h3 { margin: 0; font-size: 1.02rem; }
.docs-model-when {
  font-size: 0.87rem;
  color: var(--text);
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  margin: 0.7rem 0 0.4rem;
  line-height: 1.55;
}
.docs-model-when strong { color: var(--brand); }
.docs-strength-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.docs-strength-tag {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ── Ficha de specs rápidas (contexto, output, precio) ──────────── */

.docs-fact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin: 0.9rem 0;
}
.docs-fact {
  padding: 0.6rem 0.8rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.docs-fact:nth-last-child(-n+99) { border-bottom: none; }
.docs-fact-label {
  display: block;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 0.15rem;
}
.docs-fact-value {
  display: block;
  font-size: 0.86rem;
  font-weight: 650;
  color: var(--text);
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

/* ── Provider hero (encabezado de página de proveedor) ──────────── */

.docs-provider-hero {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.6rem;
}
.docs-provider-hero .chip { font-size: 0.78rem; padding: 0.3rem 0.75rem; }

/* ── Grid de capacidades transversales del proveedor ─────────────── */

.docs-capability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}
.docs-capability {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--surface);
}
.docs-capability-icon { font-size: 1.1rem; margin-bottom: 0.4rem; display: block; }
.docs-capability h4 { font-size: 0.88rem; font-weight: 700; margin: 0 0 0.35rem; }
.docs-capability p { font-size: 0.82rem; color: var(--text-muted); margin: 0; line-height: 1.55; }

/* ── TOC (on this page) ──────────────────────────────────────── */

.docs-toc {
  position: sticky;
  top: 1.5rem;
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  padding: 2.5rem 0 2rem;
  font-size: 0.8rem;
}
.docs-toc-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.7rem;
}
.docs-toc a {
  display: block;
  padding: 0.28rem 0 0.28rem 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--text-muted);
  text-decoration: none;
  line-height: 1.4;
}
.docs-toc a.is-active { color: var(--brand); border-left-color: var(--brand); font-weight: 600; }
.docs-toc a[data-level="3"] { padding-left: 1.4rem; font-size: 0.76rem; }

/* ── Mobile: toggle de sidebar ───────────────────────────────── */

.docs-mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
@media (max-width: 860px) {
  .docs-mobile-bar { display: flex; }
}
.docs-mobile-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-family: inherit;
}

/* ── Prev/next footer ────────────────────────────────────────── */

.docs-pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
}
.docs-pager-link {
  display: block;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1.05rem;
  text-decoration: none;
  color: var(--text);
}
.docs-pager-link:hover { border-color: var(--brand); text-decoration: none; }
.docs-pager-link.next { text-align: right; }
.docs-pager-dir { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-bottom: 0.25rem; }
.docs-pager-title { font-size: 0.9rem; font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .docs-entry-card { transition: none; }
}

/* ── Flow diagram (secuencia / pipeline con flechas) ────────────── */

.docs-flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 1.5rem 0 2rem;
  flex-wrap: wrap;
}

.docs-flow-step {
  flex: 1 1 140px;
  min-width: 140px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 0.85rem 1rem;
}

.docs-flow-step-label {
  display: block;
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--brand);
  margin-bottom: 0.3rem;
  font-weight: 700;
}

.docs-flow-step-title { font-weight: 700; font-size: 0.9rem; margin: 0 0 0.25rem; color: var(--text); }
.docs-flow-step-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.5; margin: 0; }

.docs-flow-arrow {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.5rem;
  color: var(--text-muted);
  font-size: 1.1rem;
  min-width: 28px;
}

@media (max-width: 640px) {
  .docs-flow { flex-direction: column; }
  .docs-flow-arrow { transform: rotate(90deg); padding: 0.3rem 0; align-self: center; }
}

.docs-flow-step.is-error   { border-color: var(--danger); }
.docs-flow-step.is-error   .docs-flow-step-label { color: var(--danger); }
.docs-flow-step.is-success { border-color: var(--success); }
.docs-flow-step.is-success .docs-flow-step-label { color: var(--success); }
.docs-flow-step.is-warning { border-color: var(--warning); }
.docs-flow-step.is-warning .docs-flow-step-label { color: var(--warning); }

/* Bloque de ramas paralelas dentro de un mismo paso del flow (ej: contendientes de un duelo) */
.docs-flow-branch {
  flex: 1.4 1 220px;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 0.65rem;
  background: var(--surface-2);
}

.docs-flow-branch-label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.1rem;
}

.docs-flow-branch-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0.45rem 0.7rem;
  font-size: 0.82rem;
  color: var(--text);
}

.docs-flow-branch-item .docs-flow-tag {
  font-family: "JetBrains Mono", "Fira Code", Consolas, monospace;
  font-size: 0.68rem;
  color: var(--brand);
  font-weight: 700;
}

/* ── Árbol de decisión ───────────────────────────────────────────── */

.docs-tree, .docs-tree ul {
  list-style: none;
  margin: 0;
  padding-left: 1.35rem;
}

.docs-tree {
  margin: 1.5rem 0 2rem;
  padding-left: 0;
}

.docs-tree > li { padding-left: 0; }

.docs-tree li {
  position: relative;
  padding: 0.2rem 0 0.2rem 1.1rem;
  margin: 0.2rem 0;
}

.docs-tree ul {
  border-left: 1px solid var(--border);
  margin-left: 0.55rem;
}

.docs-tree ul li::before {
  content: "";
  position: absolute;
  left: -1px;
  top: 0.8rem;
  width: 0.9rem;
  height: 1px;
  background: var(--border);
}

.docs-tree-q {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-weight: 650;
  color: var(--text);
  font-size: 0.9rem;
}

.docs-tree-a {
  display: inline-block;
  font-size: 0.76rem;
  padding: 0.15rem 0.55rem;
  border-radius: 100px;
  background: var(--brand-10);
  color: var(--brand);
  font-weight: 650;
  white-space: nowrap;
}

.docs-tree-note {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  font-weight: 400;
}

/* ── Diagrama de estados (pills conectados) ─────────────────────── */

.docs-state-flow {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 1.25rem 0 1.75rem;
}

.docs-state-pill {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border: 1px solid var(--border);
  border-radius: 100px;
  background: var(--surface);
  padding: 0.5rem 1rem;
  min-width: 0;
}

.docs-state-pill code {
  font-size: 0.8rem;
  font-weight: 700;
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}

.docs-state-pill.is-terminal-success { border-color: var(--success); }
.docs-state-pill.is-terminal-success code { color: var(--success); }
.docs-state-pill.is-terminal-danger { border-color: var(--danger); }
.docs-state-pill.is-terminal-danger code { color: var(--danger); }

.docs-state-arrow { color: var(--text-muted); font-size: 1rem; flex: 0 0 auto; }

.docs-state-branch {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .docs-state-flow { flex-direction: column; align-items: stretch; }
  .docs-state-arrow { align-self: center; transform: rotate(90deg); }
}
