/* Estilos del portal api-cpe. Una sola hoja para todas las páginas: nada en línea
   (la CSP lo prohíbe) y nada de fuera. */

:root {
  --bg: #f5f6f8; --surface: #ffffff; --surface-2: #f9fafb; --text: #1f2937; --muted: #6b7280;
  --border: #e5e7eb; --primary: #2563eb; --primary-strong: #1d4ed8; --primary-soft: #dbeafe;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --danger: #b91c1c; --danger-soft: #fee2e2; --code-bg: #0f172a; --code-text: #e2e8f0;
  --on-primary: #ffffff; --on-danger: #ffffff;
  --radius: 8px; --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #111a2e; --surface-2: #16213a; --text: #e5e7eb; --muted: #9ca3af;
    --border: #25324d; --primary: #60a5fa; --primary-strong: #93c5fd; --primary-soft: #1e3a5f;
    --ok: #4ade80; --ok-soft: #14361f; --warn: #fbbf24; --warn-soft: #3b2f10;
    --danger: #f87171; --danger-soft: #3b1515; --code-bg: #060b16; --code-text: #e2e8f0;
    --on-primary: #0b1220; --on-danger: #0b1220;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); }
a:hover { color: var(--primary-strong); }
code, pre, kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px; overflow-wrap: anywhere; }
pre { background: var(--code-bg); color: var(--code-text); padding: 14px 16px; border-radius: 6px; overflow-x: auto; line-height: 1.5; margin: 12px 0; }
pre code { background: none; border: 0; padding: 0; color: inherit; }
.container { max-width: 76rem; margin: 0 auto; padding: 0 16px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Cabecera y menú común */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 24px; padding-top: 12px; padding-bottom: 12px; }
.brand { display: flex; align-items: baseline; gap: 8px; text-decoration: none; color: var(--text); }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-by { color: var(--muted); font-size: 13px; }
#site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
#site-nav ul { display: flex; flex-wrap: wrap; gap: 4px; list-style: none; margin: 0; padding: 0; }
#site-nav a { display: block; padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); font-weight: 500; }
#site-nav a:hover { background: var(--surface-2); color: var(--text); }
#site-nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-strong); }
.logout { margin: 0; }
.logout button { background: none; border: 0; color: var(--danger); font: inherit; font-weight: 500; padding: 6px 12px; border-radius: 6px; cursor: pointer; }
.logout button:hover { background: var(--danger-soft); }

/* Página: barra lateral de la sección y contenido */
.page { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; padding-top: 24px; padding-bottom: 40px; }
.page.no-sidebar { grid-template-columns: minmax(0, 1fr); }
.sidebar { align-self: start; position: sticky; top: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.sidebar summary { cursor: pointer; font-weight: 600; display: none; }
.sidebar-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 8px 0 4px; }
.sidebar ul { list-style: none; margin: 0 0 8px; padding: 0; }
.sidebar li a { display: block; padding: 4px 8px; border-radius: 5px; text-decoration: none; color: var(--text); font-size: 14px; }
.sidebar li a:hover { background: var(--surface-2); }
.sidebar li a[aria-current="page"] { background: var(--primary-soft); color: var(--primary-strong); font-weight: 600; }
.sidebar .toc a { color: var(--muted); padding-left: 18px; font-size: 13px; }
main { min-width: 0; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 24px; margin-bottom: 20px; }

h1 { font-size: 28px; line-height: 1.25; margin: 0 0 8px; }
h2 { font-size: 21px; line-height: 1.3; margin: 28px 0 10px; }
h3 { font-size: 17px; margin: 22px 0 8px; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.lead { color: var(--muted); font-size: 17px; margin: 0 0 16px; }
.muted { color: var(--muted); }

/* Tablas */
.table-wrap { overflow-x: auto; margin: 10px 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; background: var(--surface-2); color: var(--muted); font-weight: 600; padding: 8px 10px; white-space: nowrap; border-bottom: 1px solid var(--border); }
td { border-top: 1px solid var(--border); padding: 8px 10px; vertical-align: top; }
td[align="right"], th[align="right"] { text-align: right; }
td[align="center"], th[align="center"] { text-align: center; }
.nowrap { white-space: nowrap; }

/* Avisos (admoniciones de Markdown y mensajes) */
.admonition, .notice { border-left: 4px solid var(--primary); background: var(--primary-soft); border-radius: 6px; padding: 10px 14px; margin: 14px 0; }
.admonition p { margin: 4px 0; }
.admonition-title { font-weight: 700; }
.admonition.warning, .notice.warning { border-left-color: var(--warn); background: var(--warn-soft); }
.admonition.danger, .notice.error { border-left-color: var(--danger); background: var(--danger-soft); }
.notice.success { border-left-color: var(--ok); background: var(--ok-soft); }

/* Portada */
.hero { padding: 8px 0 4px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 16px 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.card h2, .card h3 { margin-top: 0; }
a.card { text-decoration: none; color: var(--text); transition: border-color .15s; }
a.card h2, a.card h3 { color: var(--primary); }
a.card:hover { border-color: var(--primary); color: var(--text); }
.card ul { padding-left: 18px; margin: 8px 0 0; }
.steps { counter-reset: step; list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 10px; }
.steps li { counter-increment: step; position: relative; padding-left: 40px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; font-weight: 700; font-size: 14px; }

/* Referencia */
.method { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 4px; padding: 1px 7px; margin-right: 8px; vertical-align: 1px; }
.method-get { background: var(--ok-soft); color: var(--ok); }
.method-post { background: var(--primary-soft); color: var(--primary-strong); }
.endpoint { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 14px; overflow-wrap: anywhere; }
.operation { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 20px; }
.operation:first-of-type { border-top: 0; margin-top: 0; }
.tag { display: inline-block; font-size: 12px; border-radius: 999px; padding: 1px 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.required { color: var(--danger); font-weight: 600; }
.status { font-weight: 700; }
.status-2 { color: var(--ok); } .status-4 { color: var(--warn); } .status-5 { color: var(--danger); }

/* Consola */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 28px; font-weight: 700; }
.badge { display: inline-block; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 600; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-off { background: var(--danger-soft); color: var(--danger); }
tr.inactive td { color: var(--muted); }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
.row-actions form { margin: 0; }
.row-actions details summary { list-style: none; cursor: pointer; }
.row-actions details summary::-webkit-details-marker { display: none; }
.row-actions details[open] { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.row-actions details p { margin: 6px 0; font-size: 13px; }

/* Formularios y botones */
form.stack > * + * { margin-top: 12px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
label { display: block; font-weight: 500; font-size: 14px; margin-bottom: 4px; }
.hint { color: var(--muted); font-size: 13px; margin: 4px 0 0; }
input[type=text], input[type=password], input[type=number], select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit;
}
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn { display: inline-block; border: 1px solid transparent; border-radius: 6px; padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover { background: var(--primary-strong); color: var(--on-primary); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-light { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-light:hover { background: var(--surface-2); }
.btn-small { padding: 3px 10px; font-size: 13px; font-weight: 500; }
.keybox { border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 20px; }
.keybox code { display: inline-block; margin: 6px 8px 6px 0; font-size: 14px; padding: 4px 8px; background: var(--surface); overflow-wrap: anywhere; }
.login-box { max-width: 26rem; margin: 24px auto; }

/* Pie */
.site-footer { border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; padding: 16px 0 24px; }

@media (max-width: 1000px) {
  .page { grid-template-columns: 200px minmax(0, 1fr); gap: 20px; }
}
@media (max-width: 720px) {
  /* En el móvil, primero el contenido; el índice de la sección, después y plegable. */
  .page { grid-template-columns: minmax(0, 1fr); gap: 16px; padding-top: 16px; }
  .sidebar { position: static; order: 2; }
  .sidebar summary { display: block; }
  .panel { padding: 16px; }
  h1 { font-size: 24px; }
}
