:root {
    --primary: #0052FF;
    --accent: #00E676;
    --bg: #F4F6F9;
    --white: #FFFFFF;
    --text: #1A1D20;
    --muted: #5F6368;
    --line: #E3E7EC;
    --code-bg: #0F172A;
    --code-text: #E2E8F0;
    --topbar-h: 60px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--topbar-h) + 1rem); }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--white); color: var(--text); line-height: 1.65; overflow-x: hidden; }
a { color: var(--primary); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Barra superior */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 50; display: flex; align-items: center; gap: 0.75rem; padding: 0 5%; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 1.4rem; color: var(--primary); text-decoration: none; }
.logo span { color: var(--accent); }
.tag-docs { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; background: rgba(0, 82, 255, 0.1); color: var(--primary); padding: 0.2rem 0.6rem; border-radius: 50px; }
.top-links { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.top-links a { text-decoration: none; font-weight: 600; font-size: 0.9rem; color: var(--text); padding: 0.45rem 0.75rem; border-radius: 8px; white-space: nowrap; }
.top-links a:hover { color: var(--primary); }
.top-links .cta { background: var(--primary); color: var(--white); }
.top-links .cta:hover { color: var(--white); filter: brightness(1.1); }

/* Estructura */
.layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); max-width: 1240px; margin: 0 auto; padding-top: var(--topbar-h); }
.sidebar { position: sticky; top: var(--topbar-h); align-self: start; max-height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 1.5rem 1rem 2rem 5%; border-right: 1px solid var(--line); }
.toc summary { display: none; }
.toc h2 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 1.25rem 0 0.4rem; }
.toc h2:first-of-type { margin-top: 0; }
.toc a { display: block; text-decoration: none; color: var(--text); font-size: 0.92rem; font-weight: 500; padding: 0.3rem 0.6rem; border-radius: 6px; border-left: 2px solid transparent; }
.toc a:hover { background: var(--bg); }
.toc a.activo { color: var(--primary); font-weight: 700; border-left-color: var(--primary); background: rgba(0, 82, 255, 0.06); }

.content { padding: 2.5rem 5% 5rem 3rem; min-width: 0; max-width: 900px; }
.content > section { margin-bottom: 3.5rem; }
.content h1 { font-size: clamp(2rem, 5vw, 2.6rem); font-weight: 800; line-height: 1.15; margin-bottom: 0.75rem; }
.content h2 { font-size: 1.6rem; font-weight: 800; margin: 0 0 1rem; padding-top: 0.5rem; }
.content h3 { font-size: 1.1rem; font-weight: 800; margin: 2rem 0 0.6rem; }
.content p { margin-bottom: 1rem; color: #2f3338; }
.content ul, .content ol { margin: 0 0 1rem 1.3rem; }
.content li { margin-bottom: 0.3rem; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 680px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.88em; background: var(--bg); border: 1px solid var(--line); padding: 0.08em 0.35em; border-radius: 5px; overflow-wrap: anywhere; }

/* Bloques de código */
.code-wrap { position: relative; margin: 0 0 1.25rem; }
pre { background: var(--code-bg); color: var(--code-text); padding: 1.1rem 1.25rem; border-radius: 12px; overflow-x: auto; font-size: 0.82rem; line-height: 1.6; -webkit-overflow-scrolling: touch; }
pre code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; overflow-wrap: normal; }
.copy { position: absolute; top: 0.5rem; right: 0.5rem; background: rgba(255, 255, 255, 0.12); color: #CBD5E1; border: 0; border-radius: 6px; padding: 0.3rem 0.65rem; font: 600 0.75rem 'Inter', sans-serif; cursor: pointer; }
.copy:hover { background: rgba(255, 255, 255, 0.22); }
.pre-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-bottom: 0.35rem; }

/* Pestañas de lenguaje */
.tabs [role="tablist"] { display: flex; gap: 0.25rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.tabs [role="tab"] { border: 1px solid var(--line); background: var(--white); border-radius: 8px; padding: 0.35rem 0.9rem; font: 600 0.85rem 'Inter', sans-serif; cursor: pointer; color: var(--muted); }
.tabs [role="tab"][aria-selected="true"] { background: var(--primary); border-color: var(--primary); color: var(--white); }

/* Endpoints */
.ep { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.9rem; margin: 1.25rem 0 0.75rem; }
.ep code { background: none; border: 0; padding: 0; font-weight: 600; font-size: 0.95rem; }
.m { font-size: 0.72rem; font-weight: 800; padding: 0.2rem 0.55rem; border-radius: 6px; color: var(--white); letter-spacing: 0.03em; }
.m.get { background: #0B8F4D; }
.m.post { background: var(--primary); }
.m.patch { background: #B7791F; }
.m.delete { background: #C53030; }
.perm { margin-left: auto; font-size: 0.75rem; color: var(--muted); }

/* Tablas */
.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; border: 1px solid var(--line); border-radius: 12px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; min-width: 480px; }
th, td { text-align: left; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td:first-child { white-space: nowrap; }
.req { color: #C53030; font-weight: 700; font-size: 0.75rem; margin-left: 0.3rem; }

/* Avisos */
.callout { border-left: 4px solid var(--primary); background: rgba(0, 82, 255, 0.05); padding: 0.9rem 1.1rem; border-radius: 0 10px 10px 0; margin: 0 0 1.25rem; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn { border-left-color: #B7791F; background: rgba(183, 121, 31, 0.08); }
.callout strong:first-child { display: block; margin-bottom: 0.15rem; }

.flow { list-style: none; margin: 0 0 1.25rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.flow li { background: var(--bg); border: 1px solid var(--line); border-radius: 50px; padding: 0.3rem 0.9rem; font-size: 0.85rem; font-weight: 600; margin: 0; }
.flow li + li::before { content: '→'; margin-right: 0.6rem; color: var(--muted); }

.footer { border-top: 1px solid var(--line); padding: 1.5rem 5%; text-align: center; color: var(--muted); font-size: 0.85rem; }

/* Tablet y móvil: el índice pasa a un menú desplegable */
@media (max-width: 900px) {
    .layout { display: block; }
    .sidebar { position: sticky; top: var(--topbar-h); z-index: 40; max-height: none; overflow: visible; padding: 0; background: var(--white); border-right: 0; border-bottom: 1px solid var(--line); }
    .toc summary { display: flex; align-items: center; justify-content: space-between; padding: 0.8rem 5%; font-weight: 700; cursor: pointer; list-style: none; }
    .toc summary::-webkit-details-marker { display: none; }
    .toc summary::after { content: '▾'; transition: transform 0.2s; }
    .toc[open] summary::after { transform: rotate(180deg); }
    .toc nav { max-height: 60vh; overflow-y: auto; padding: 0 5% 1rem; border-top: 1px solid var(--line); }
    .content { padding: 1.75rem 5% 4rem; }
    .content > section { margin-bottom: 2.75rem; }
}

@media (max-width: 700px) {
    table { min-width: 0; font-size: 0.85rem; }
    th, td { padding: 0.5rem 0.65rem; }
    td:first-child { white-space: normal; }
}

@media (max-width: 520px) {
    .top-links a:not(.cta) { display: none; }
    .top-links .cta { padding: 0.45rem 0.8rem; font-size: 0.85rem; }
    .content h2 { font-size: 1.4rem; }
    pre { font-size: 0.76rem; padding: 0.9rem; }
    .perm { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; }
}
