/* docs/assets/style.css — tema JARVIS: glassmorphism sobre fondo oscuro. */

:root {
  --bg: #0a121a;
  --bg-hondo: #05090e;
  --panel: rgba(13, 22, 32, 0.55);
  --panel-solido: #0d1620;
  --borde: rgba(63, 208, 255, 0.14);
  --borde-fuerte: rgba(63, 208, 255, 0.32);
  --cian: #3fd0ff;
  --cian-tenue: #1c5a72;
  --cian-suave: rgba(63, 208, 255, 0.10);
  --ambar: #ffb454;
  --verde: #3ddc97;
  --rojo: #ff5d5d;
  --texto: #e7f2f7;
  --texto-tenue: #8ba7b6;
  --texto-fantasma: #4d6472;

  --fuente: -apple-system, "Segoe UI", Roboto, "Inter", Helvetica, Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;

  --radio: 10px;
  --header-h: 60px;
  --sidebar-w: 280px;
  --toc-w: 230px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 620px at 14% -10%, rgba(63, 208, 255, 0.08), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(63, 208, 255, 0.05), transparent 55%),
    var(--bg-hondo);
  color: var(--texto);
  font-family: var(--fuente);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--cian-tenue); color: #fff; }

/* Rejilla técnica de fondo, muy sutil, igual que el panel del móvil */
.app::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(63, 208, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(63, 208, 255, 0.025) 1px, transparent 1px);
  background-size: 34px 34px;
}

/* ============================================================= HEADER === */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 18px;
  background: rgba(8, 13, 19, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--borde);
}

.topbar-izq { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.topbar-centro { flex: 1 1 auto; display: flex; justify-content: center; min-width: 0; }
.topbar-der { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; position: relative; }

.btn-icono {
  background: transparent;
  border: 1px solid transparent;
  color: var(--texto-tenue);
  width: 34px; height: 34px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-icono:hover { background: var(--cian-suave); color: var(--cian); border-color: var(--borde); }
.btn-icono svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.marca { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.marca-anillo {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--cian);
  box-shadow: 0 0 10px rgba(63, 208, 255, 0.55), inset 0 0 6px rgba(63, 208, 255, 0.4);
}
.marca-nombre {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.14em;
  color: #fff;
  text-shadow: 0 0 14px rgba(63, 208, 255, 0.45);
}
.badge-version {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.03em;
  color: var(--cian);
  background: var(--cian-suave);
  border: 1px solid var(--borde-fuerte);
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

/* --- Buscador ------------------------------------------------------------ */
.buscador {
  position: relative;
  width: min(520px, 100%);
}
.buscador-icono {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; fill: none; stroke: var(--texto-fantasma); stroke-width: 2;
  pointer-events: none;
}
#campoBusqueda {
  width: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--borde);
  color: var(--texto);
  padding: 9px 38px;
  border-radius: 9px;
  font-family: var(--fuente);
  font-size: 13.5px;
  transition: border-color 0.15s, background 0.15s;
}
#campoBusqueda::placeholder { color: var(--texto-fantasma); }
#campoBusqueda:focus {
  outline: none;
  border-color: var(--borde-fuerte);
  background: rgba(63, 208, 255, 0.05);
}
.buscador-atajo {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 10px;
  color: var(--texto-fantasma);
  border: 1px solid var(--borde);
  border-radius: 4px;
  padding: 1px 6px;
  pointer-events: none;
}
.buscador:focus-within .buscador-atajo { display: none; }

.resultados-busqueda {
  position: absolute;
  top: calc(100% + 8px);
  left: 0; right: 0;
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(11, 19, 27, 0.94);
  backdrop-filter: blur(16px);
  border: 1px solid var(--borde-fuerte);
  border-radius: var(--radio);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  padding: 6px;
  z-index: 60;
}
.resultado-grupo-titulo {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--texto-fantasma);
  padding: 8px 10px 4px;
}
.resultado-item {
  display: block;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  color: var(--texto);
  text-decoration: none;
}
.resultado-item:hover, .resultado-item.activo { background: var(--cian-suave); }
.resultado-item .r-titulo { font-size: 13.5px; font-weight: 600; display: flex; align-items: baseline; gap: 6px; }
.resultado-item .r-doc { font-family: var(--mono); font-size: 10px; color: var(--cian); }
.resultado-item .r-snippet { font-size: 12px; color: var(--texto-tenue); margin-top: 2px; }
.resultado-item mark { background: rgba(63, 208, 255, 0.35); color: #fff; border-radius: 2px; }
.resultado-vacio { padding: 16px 10px; color: var(--texto-fantasma); font-size: 13px; text-align: center; }

/* --- Estado del daemon ---------------------------------------------------- */
.estado-daemon {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--borde);
  color: var(--texto-tenue);
  padding: 6px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
  white-space: nowrap;
}
.estado-daemon:hover { border-color: var(--borde-fuerte); }
.estado-punto {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--texto-fantasma);
  flex: 0 0 auto;
}
.estado-punto.ok { background: var(--verde); box-shadow: 0 0 8px var(--verde); }
.estado-punto.mal { background: var(--rojo); box-shadow: 0 0 8px var(--rojo); }
.estado-punto.espera { background: var(--ambar); box-shadow: 0 0 8px var(--ambar); }

.popover-estado {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 300px;
  background: rgba(11, 19, 27, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid var(--borde-fuerte);
  border-radius: var(--radio);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  padding: 16px;
  z-index: 60;
}
.popover-titulo { margin: 0 0 6px; font-size: 13.5px; font-weight: 700; }
.popover-nota { margin: 0 0 12px; font-size: 11.5px; color: var(--texto-tenue); line-height: 1.5; }
.popover-nota code { font-family: var(--mono); color: var(--cian); }
.popover-estado label {
  display: block;
  font-size: 11px;
  color: var(--texto-tenue);
  margin-bottom: 10px;
}
.popover-estado input {
  width: 100%;
  margin-top: 4px;
  background: var(--bg-hondo);
  border: 1px solid var(--borde);
  color: var(--texto);
  padding: 8px 9px;
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 12px;
}
.popover-estado input:focus { outline: none; border-color: var(--cian); }
.popover-acciones { display: flex; gap: 8px; margin-top: 4px; }
.btn-primario, .btn-secundario {
  flex: 1;
  padding: 8px 0;
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}
.btn-primario { background: var(--cian-tenue); border: 1px solid var(--cian); color: #fff; }
.btn-primario:hover { background: var(--cian); color: #04121a; }
.btn-secundario { background: transparent; border: 1px solid var(--borde); color: var(--texto-tenue); }
.btn-secundario:hover { border-color: var(--rojo); color: var(--rojo); }

/* ============================================================== LAYOUT === */
.cuerpo {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  min-height: calc(100dvh - var(--header-h) - 44px);
}

/* --- Sidebar --------------------------------------------------------------- */
.sidebar {
  border-right: 1px solid var(--borde);
  background: rgba(7, 12, 18, 0.5);
  position: sticky;
  top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  overflow: hidden;
}
.sidebar-scroll { height: 100%; overflow-y: auto; padding: 18px 12px 40px; }
.sidebar-velo { display: none; }

.sidebar-cargando { color: var(--texto-fantasma); font-size: 13px; padding: 8px 10px; }

.nav-categoria { margin-bottom: 20px; }
.nav-categoria-titulo {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--texto-fantasma);
  padding: 0 10px;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.nav-categoria-titulo svg { width: 13px; height: 13px; stroke: var(--cian); fill: none; stroke-width: 2; opacity: 0.8; }

.nav-link {
  display: block;
  padding: 8px 10px;
  margin: 1px 0;
  border-radius: 7px;
  color: var(--texto-tenue);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.03); color: var(--texto); }
.nav-link.activo {
  background: var(--cian-suave);
  color: var(--cian);
  border-left-color: var(--cian);
  font-weight: 600;
}

/* --- Contenido --------------------------------------------------------------- */
.contenido { min-width: 0; padding: 40px 48px 100px; }

.documento {
  max-width: 780px;
  margin: 0 auto;
  animation: aparecer-doc 0.2s ease-out;
}
@keyframes aparecer-doc { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.doc-cargando, .doc-error { color: var(--texto-fantasma); font-size: 14px; }
.doc-error { color: var(--rojo); }

/* Tipografía del documento renderizado */
.documento h1, .documento h2, .documento h3, .documento h4 {
  font-family: var(--fuente);
  color: #fff;
  font-weight: 700;
  scroll-margin-top: calc(var(--header-h) + 20px);
  letter-spacing: -0.01em;
}
.documento h1 {
  font-size: 30px;
  padding-bottom: 16px;
  margin: 0 0 22px;
  border-bottom: 1px solid var(--borde);
  background: linear-gradient(90deg, #fff, var(--cian) 140%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.documento h2 { font-size: 22px; margin: 42px 0 16px; padding-top: 6px; }
.documento h3 { font-size: 17px; margin: 30px 0 12px; color: var(--cian); }
.documento h4 { font-size: 14.5px; margin: 22px 0 10px; color: var(--texto); }
.documento h2 .anchor, .documento h3 .anchor { display: none; }

.documento p, .documento li { font-size: 15px; line-height: 1.75; color: #cfe1ea; }
.documento p { margin: 0 0 16px; }
.documento strong { color: #fff; }
.documento a { color: var(--cian); text-decoration: none; border-bottom: 1px solid var(--cian-tenue); }
.documento a:hover { border-bottom-color: var(--cian); }

.documento ul, .documento ol { padding-left: 22px; margin: 0 0 16px; }
.documento li { margin-bottom: 6px; }
.documento li > p { margin-bottom: 6px; }
.documento hr { border: none; border-top: 1px solid var(--borde); margin: 36px 0; }

/* Código inline y en bloque */
.documento code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: rgba(63, 208, 255, 0.08);
  color: #b9e9ff;
  padding: 0.15em 0.4em;
  border-radius: 5px;
}
.documento pre {
  background: #0c141d !important;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  padding: 16px 18px;
  overflow-x: auto;
  margin: 0 0 20px;
  position: relative;
}
.documento pre code.hljs {
  background: transparent !important;
  padding: 0;
  font-size: 12.8px;
  line-height: 1.65;
  border-radius: 0;
}
.documento pre::before {
  content: attr(data-lenguaje);
  position: absolute;
  top: 8px; right: 12px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--texto-fantasma);
}

/* Diagramas Mermaid */
.documento pre.mermaid {
  background: var(--bg-hondo) !important;
  border: 1px solid var(--borde);
  padding: 6px;
  display: flex;
  justify-content: center;
}
.mermaid-envoltorio {
  position: relative;
  margin: 8px 0 24px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  background: var(--bg-hondo);
  overflow: hidden;
}
.mermaid-envoltorio svg { width: 100%; height: 420px; display: block; cursor: grab; }
.mermaid-envoltorio svg:active { cursor: grabbing; }
.mermaid-pista {
  position: absolute; bottom: 8px; right: 10px;
  font-family: var(--mono);
  font-size: 10px;
  color: var(--texto-fantasma);
  background: rgba(5, 9, 14, 0.7);
  padding: 3px 8px;
  border-radius: 6px;
  pointer-events: none;
}

/* Tablas — bordes limpios */
.documento table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 22px;
  font-size: 13.5px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  overflow: hidden;
}
.documento th {
  background: rgba(63, 208, 255, 0.06);
  color: var(--cian);
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 10px 14px;
  border-bottom: 1px solid var(--borde-fuerte);
}
.documento td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--borde);
  color: #cfe1ea;
  vertical-align: top;
}
.documento tr:last-child td { border-bottom: none; }
.documento tr:hover td { background: rgba(255, 255, 255, 0.015); }

/* Blockquotes -> alertas informativas */
.documento blockquote {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-left: 3px solid var(--cian);
  background: rgba(63, 208, 255, 0.06);
  border-radius: 0 8px 8px 0;
  color: #bfe4f5;
  font-size: 14px;
}
.documento blockquote p { margin: 0; color: inherit; font-size: inherit; }
.documento blockquote p + p { margin-top: 8px; }

/* --- TOC lateral ("En esta página") ------------------------------------------ */
.toc {
  position: sticky;
  top: var(--header-h);
  height: calc(100dvh - var(--header-h));
  overflow-y: auto;
  padding: 40px 20px;
  border-left: 1px solid var(--borde);
}
.toc-titulo {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--texto-fantasma);
  margin: 0 0 12px;
}
#tocLista a {
  display: block;
  padding: 5px 0 5px 12px;
  border-left: 2px solid var(--borde);
  color: var(--texto-tenue);
  text-decoration: none;
  font-size: 12.5px;
  line-height: 1.4;
}
#tocLista a:hover { color: var(--texto); }
#tocLista a.nivel-3 { padding-left: 22px; font-size: 12px; }
#tocLista a.activo { color: var(--cian); border-left-color: var(--cian); }

/* --- Pie ---------------------------------------------------------------------- */
.piebase {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  font-size: 11.5px;
  color: var(--texto-fantasma);
  border-top: 1px solid var(--borde);
  font-family: var(--mono);
}
.piebase a { color: var(--texto-tenue); text-decoration: none; }
.piebase a:hover { color: var(--cian); }

/* ============================================================ RESPONSIVE === */
.solo-movil { display: none; }

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

@media (max-width: 860px) {
  .solo-movil { display: flex; }
  .cuerpo { grid-template-columns: 1fr; }
  .contenido { padding: 28px 20px 80px; }
  .topbar-centro { display: none; }

  .sidebar {
    position: fixed;
    left: 0; top: var(--header-h);
    width: min(84vw, 320px);
    height: calc(100dvh - var(--header-h));
    z-index: 55;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    background: rgba(9, 15, 22, 0.98);
  }
  .app.sidebar-abierta .sidebar { transform: translateX(0); box-shadow: 20px 0 40px rgba(0,0,0,0.5); }
  .app.sidebar-abierta .sidebar-velo {
    display: block;
    position: fixed; inset: var(--header-h) 0 0 0;
    background: rgba(0,0,0,0.5);
    z-index: 50;
  }

  .popover-estado { right: -8px; width: 88vw; max-width: 320px; }
}

@media (max-width: 640px) {
  .marca-nombre { display: none; }
  .badge-version { display: none; }
  .documento h1 { font-size: 24px; }
}

/* Barras de scroll discretas */
.sidebar-scroll::-webkit-scrollbar, .toc::-webkit-scrollbar, .resultados-busqueda::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb, .toc::-webkit-scrollbar-thumb, .resultados-busqueda::-webkit-scrollbar-thumb {
  background: var(--borde-fuerte); border-radius: 3px;
}
