/* =========================================================================
   Documentación INAN — estilos del sitio público
   Réplica del layout de Docusaurus (Infima) con la identidad de INANetworks
   ========================================================================= */

:root {
  --brand:        #1668c1;
  --brand-dark:   #11539c;
  --brand-light:  #2f83dd;
  --accent:       #f7941d;

  --bg:           #ffffff;
  --bg-alt:       #f5f6f8;
  --bg-sidebar:   #ffffff;
  --surface:      #ffffff;
  --text:         #1c1e21;
  --text-soft:    #525860;
  --text-muted:   #7a828c;
  --border:       #e3e6ea;
  --border-soft:  #eceef1;
  --shadow-sm:    0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 14px rgba(0,0,0,.10);

  --nav-h:        60px;
  --sidebar-w:    300px;
  --toc-w:        240px;
  --radius:       8px;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
               'Liberation Mono', monospace;
}

html[data-theme='dark'] {
  --bg:          #1b1b1d;
  --bg-alt:      #242526;
  --bg-sidebar:  #1b1b1d;
  --surface:     #242526;
  --text:        #e3e3e3;
  --text-soft:   #c2c4c7;
  --text-muted:  #9a9da1;
  --border:      #3a3d40;
  --border-soft: #2e3033;
  --brand:       #4a9eea;
  --brand-dark:  #3d8ad4;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.4);
  --shadow-md:   0 4px 14px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px;
}

img { max-width: 100%; height: auto; }

/* ----------------------------------------------------------- navbar */

.navbar {
  position: sticky; top: 0; z-index: 200;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  border-bottom: 1px solid var(--border-soft);
}

.navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.navbar-brand:hover { text-decoration: none; }
.navbar-logo { height: 30px; width: auto; display: block; }

.navbar-items { display: flex; align-items: center; gap: 4px; }
.navbar-items.right { margin-left: auto; }

.navbar-link {
  padding: 6px 12px; border-radius: 6px;
  font-size: 15px; font-weight: 500; color: var(--text-soft);
  display: inline-flex; align-items: center; gap: 5px;
}
.navbar-link:hover { background: var(--bg-alt); color: var(--brand); text-decoration: none; }
.navbar-link.active { color: var(--brand); font-weight: 600; }

.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; margin-left: 6px;
  border: 0; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--text-soft);
}
.theme-toggle:hover { background: var(--bg-alt); }
.theme-toggle .icon-moon { display: none; }
html[data-theme='dark'] .theme-toggle .icon-sun  { display: none; }
html[data-theme='dark'] .theme-toggle .icon-moon { display: block; }

.navbar-toggle {
  display: none; background: none; border: 0; cursor: pointer;
  padding: 8px; color: var(--text); border-radius: 6px;
}

/* ------------------------------------------------------------ buscador */

.search-box { position: relative; margin-left: auto; }
.search-input {
  width: 220px; height: 36px; padding: 0 12px 0 34px;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--bg-alt); color: var(--text);
  font-family: inherit; font-size: 14px;
}
.search-input::placeholder { color: var(--text-muted); }
.search-box svg { position: absolute; left: 11px; top: 10px; color: var(--text-muted); }

.search-results {
  position: absolute; top: 44px; right: 0; width: 380px; max-height: 60vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 6px; display: none; z-index: 300;
}
.search-results.open { display: block; }
.search-results a { display: block; padding: 9px 12px; border-radius: 6px; color: var(--text); }
.search-results a:hover { background: var(--bg-alt); text-decoration: none; }
.search-results .sr-title { font-weight: 600; font-size: 14px; }
.search-results .sr-cat { font-size: 12px; color: var(--text-muted); }
.search-results .sr-empty { padding: 14px; color: var(--text-muted); font-size: 14px; text-align: center; }

/* ------------------------------------------------------------- layout */

.layout { display: flex; align-items: flex-start; }

.sidebar {
  position: sticky; top: var(--nav-h);
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  padding: 18px 12px 40px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
}

.sidebar-menu { list-style: none; margin: 0; padding: 0; }
.sidebar-menu li { margin: 1px 0; }

.menu-link {
  display: block; padding: 7px 14px; border-radius: 6px;
  font-size: 14.5px; line-height: 1.4; color: var(--text-soft);
}
.menu-link:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.menu-link.active {
  background: rgba(22,104,193,.10); color: var(--brand); font-weight: 600;
}
html[data-theme='dark'] .menu-link.active { background: rgba(74,158,234,.14); }

.menu-group > .menu-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; padding: 8px 14px; border: 0; border-radius: 6px;
  background: transparent; cursor: pointer;
  font: 600 15px/1.4 var(--font-sans); color: var(--text); text-align: left;
}
.menu-group > .menu-toggle:hover { background: var(--bg-alt); }
.menu-group.open > .menu-toggle { color: var(--brand); }
.menu-group > .menu-toggle .chevron { transition: transform .2s ease; flex: 0 0 auto; }
.menu-group.open > .menu-toggle .chevron { transform: rotate(90deg); }

.menu-group > ul { list-style: none; margin: 0; padding: 0 0 4px 12px; display: none; }
.menu-group.depth-1 > .menu-toggle { font-size: 14px; font-weight: 600; color: var(--text-soft); }
.menu-group.depth-2 > .menu-toggle { font-size: 13.5px; font-weight: 500; }
.menu-group.depth-1 > ul, .menu-group.depth-2 > ul { padding-left: 10px; border-left: 1px solid var(--border-soft); margin-left: 6px; }
.menu-group.open > ul { display: block; }
.menu-group > ul .menu-link { padding-left: 16px; }

/* ---------------------------------------------------------- contenido */

.main {
  flex: 1 1 auto; min-width: 0;
  display: flex; gap: 24px;
  padding: 28px 40px 60px;
  max-width: 1200px;
}

.doc { flex: 1 1 auto; min-width: 0; }

.breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 22px; font-size: 14px; }
.breadcrumbs a, .breadcrumbs span.crumb {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; color: var(--text-soft);
}
.breadcrumbs a:hover { background: var(--bg-alt); text-decoration: none; }
.breadcrumbs .crumb-current { background: var(--bg-alt); color: var(--text); font-weight: 500; }
.breadcrumbs .sep { color: var(--text-muted); }

.doc h1 { font-size: 2.6rem; line-height: 1.2; letter-spacing: -.02em; margin: 0 0 1.2rem; font-weight: 800; }
.doc h2 { font-size: 1.7rem; margin: 2.4rem 0 1rem; font-weight: 700; letter-spacing: -.01em; }
.doc h3 { font-size: 1.3rem; margin: 1.9rem 0 .8rem; font-weight: 700; }
.doc h4 { font-size: 1.1rem; margin: 1.5rem 0 .6rem; font-weight: 700; }
.doc p  { margin: 0 0 1.1rem; }
.doc ul, .doc ol { margin: 0 0 1.1rem; padding-left: 1.6rem; }
.doc li { margin: .35rem 0; }
.doc hr { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }

.hash-link {
  opacity: 0; margin-left: .4rem; color: var(--text-muted);
  font-weight: 400; text-decoration: none;
}
.doc h2:hover .hash-link, .doc h3:hover .hash-link,
.doc h4:hover .hash-link { opacity: 1; }

.ext-icon { margin-left: 3px; vertical-align: -1px; opacity: .7; }

blockquote {
  margin: 0 0 1.1rem; padding: .6rem 1.1rem;
  border-left: 4px solid var(--border); background: var(--bg-alt);
  border-radius: 0 var(--radius) var(--radius) 0; color: var(--text-soft);
}

/* código */
.doc code {
  font-family: var(--font-mono); font-size: .875em;
  background: var(--bg-alt); border: 1px solid var(--border-soft);
  padding: .12em .35em; border-radius: 4px;
}
.code-block { position: relative; margin: 0 0 1.3rem; border-radius: var(--radius); background: #282c34; overflow: hidden; }
.code-block pre { margin: 0; padding: 16px; overflow-x: auto; }
.code-block code {
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6;
  color: #dcdfe4; background: none; border: 0; padding: 0;
}
.code-lang {
  position: absolute; top: 0; left: 0; padding: 3px 10px;
  font: 600 11px/1.6 var(--font-mono); letter-spacing: .06em; text-transform: uppercase;
  color: #9aa3b0; background: rgba(255,255,255,.06); border-bottom-right-radius: 6px;
}
.code-lang + button + pre, .code-lang ~ pre { padding-top: 34px; }
.code-copy {
  position: absolute; top: 8px; right: 8px; z-index: 2;
  padding: 4px 10px; font-size: 12px; font-weight: 600;
  color: #cbd2dc; background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.16); border-radius: 5px; cursor: pointer;
  opacity: 0; transition: opacity .15s ease;
}
.code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { background: rgba(255,255,255,.18); }

/* tablas */
.table-wrap { overflow-x: auto; margin: 0 0 1.4rem; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.doc th, .doc td { padding: 9px 14px; border: 1px solid var(--border); }
.doc thead th { background: var(--bg-alt); font-weight: 700; }
.doc tbody tr:nth-child(even) { background: var(--bg-alt); }

/* ------------------------------------------------------- admoniciones */

.admonition {
  margin: 0 0 1.4rem; padding: 14px 18px;
  border-left: 5px solid var(--adm-border);
  border-radius: 0 var(--radius) var(--radius) 0;
  background: var(--adm-bg); color: var(--adm-text);
}
.admonition-heading {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 13px; letter-spacing: .05em;
  text-transform: uppercase; color: var(--adm-border);
  margin-bottom: .5rem;
}
.admonition-icon { flex: 0 0 auto; }
.admonition-content > :last-child { margin-bottom: 0; }
.admonition-content p { margin-bottom: .5rem; }

.admonition-note    { --adm-bg: #f6f7f9; --adm-border: #6c7580; --adm-text: var(--text); }
.admonition-tip     { --adm-bg: #e9f7ef; --adm-border: #1a8c4a; --adm-text: #14512e; }
.admonition-info    { --adm-bg: #eaf5fd; --adm-border: #1e88c7; --adm-text: #10425f; }
.admonition-warning { --adm-bg: #fff8e6; --adm-border: #d99400; --adm-text: #6b4b00; }
.admonition-danger  { --adm-bg: #ffeced; --adm-border: #e13238; --adm-text: #71161b; }

html[data-theme='dark'] .admonition-note    { --adm-bg: #2a2c2e; --adm-border: #8a9199; --adm-text: var(--text); }
html[data-theme='dark'] .admonition-tip     { --adm-bg: #14301f; --adm-border: #3fb968; --adm-text: #c7f0d8; }
html[data-theme='dark'] .admonition-info    { --adm-bg: #12283a; --adm-border: #4fb0e8; --adm-text: #cfe8f9; }
html[data-theme='dark'] .admonition-warning { --adm-bg: #352b12; --adm-border: #e5a72f; --adm-text: #f5e2b8; }
html[data-theme='dark'] .admonition-danger  { --adm-bg: #3a1b1d; --adm-border: #f0595e; --adm-text: #f8d2d4; }

/* ------------------------------------------------ contenido incrustado */

.doc iframe {
  display: block; width: 100%; max-width: 720px; aspect-ratio: 16 / 9; height: auto;
  border: 0; border-radius: var(--radius); margin: 0 0 1.5rem;
  background: #000;
}
.doc video { display: block; max-width: 100%; border-radius: var(--radius); margin: 0 0 1.5rem; }

.doc details {
  margin: 0 0 1.3rem; padding: 12px 16px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg-alt);
}
.doc details[open] { background: var(--surface); }
.doc summary {
  cursor: pointer; font-weight: 600; list-style: none;
  display: flex; align-items: center; gap: 8px;
}
.doc summary::-webkit-details-marker { display: none; }
.doc summary::before {
  content: ''; width: 0; height: 0; flex: 0 0 auto;
  border-left: 6px solid var(--text-soft);
  border-top: 5px solid transparent; border-bottom: 5px solid transparent;
  transition: transform .18s ease;
}
.doc details[open] summary::before { transform: rotate(90deg); }
.doc details > *:not(summary) { margin-top: .8rem; }
.doc details > *:last-child { margin-bottom: 0; }

.doc figure { margin: 0 0 1.4rem; }
.doc figcaption { font-size: 13.5px; color: var(--text-muted); margin-top: 6px; text-align: center; }

/* Imágenes rotas: que no descuadren el texto de alrededor */
.doc img { vertical-align: middle; }

/* --------------------------------------------------------- banner doc */

.doc-banner { margin: 0 0 1.6rem; }
.doc-banner img { border-radius: var(--radius); display: block; }
.doc-banner a { display: inline-block; transition: transform .18s ease, box-shadow .18s ease; }
.doc-banner a:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

/* ------------------------------------------------------- pie del doc */

.doc-meta { margin: 2.4rem 0 1.6rem; font-size: 14px; color: var(--text-muted); }

.doc-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 1.6rem; }
.doc-nav a {
  display: flex; flex-direction: column; gap: 4px;
  padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); transition: border-color .15s ease, box-shadow .15s ease;
}
.doc-nav a:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); text-decoration: none; }
.doc-nav .label { font-size: 13px; color: var(--text-muted); }
.doc-nav .title { font-weight: 700; color: var(--brand); }
.doc-nav .prev { align-items: flex-start; }
.doc-nav .next { align-items: flex-end; text-align: right; }
.doc-nav .spacer { }

/* ------------------------------------------------------------- TOC */

.toc {
  position: sticky; top: calc(var(--nav-h) + 24px);
  width: var(--toc-w); flex: 0 0 var(--toc-w);
  max-height: calc(100vh - var(--nav-h) - 48px); overflow-y: auto;
  padding-left: 16px; border-left: 1px solid var(--border-soft);
  font-size: 14px;
}
.toc-title { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; }
.toc ul { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 2px 0; }
.toc a { display: block; padding: 3px 0; color: var(--text-soft); line-height: 1.4; }
.toc a:hover, .toc a.active { color: var(--brand); text-decoration: none; }
.toc a.active { font-weight: 600; }
.toc .lvl-3 { padding-left: 14px; }

/* ------------------------------------------------------------- home */

.home-hero {
  padding: 56px 40px 40px; border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(180deg, var(--bg-alt), var(--bg));
}
.home-hero h1 { font-size: 2.5rem; margin: 0 0 .6rem; font-weight: 800; letter-spacing: -.02em; }
.home-hero p { font-size: 1.1rem; color: var(--text-soft); margin: 0; max-width: 700px; }

.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px; padding: 34px 40px 60px; max-width: 1200px;
}
.card {
  display: block; padding: 22px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--surface);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--brand); text-decoration: none; }
.card h3 { margin: 0 0 6px; font-size: 1.15rem; color: var(--text); }
.card p { margin: 0 0 10px; color: var(--text-soft); font-size: 14.5px; }
.card .count { font-size: 13px; color: var(--text-muted); }

/* ------------------------------------------------------------ footer */

.footer {
  padding: 26px 40px; text-align: center;
  background: #2b3137; color: #c9ced4; font-size: 14px;
}
html[data-theme='dark'] .footer { background: #141517; }
.footer a { color: #9ec9f5; }

/* ---------------------------------------------------------- responsive */

.sidebar-backdrop { display: none; }

@media (max-width: 996px) {
  .navbar-toggle { display: inline-flex; }
  .navbar-items.left { display: none; }
  .search-input { width: 150px; }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 400;
    height: 100%; width: 290px; padding-top: 16px;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow-md);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    display: block; position: fixed; inset: 0; z-index: 350;
    background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .2s ease;
  }
  .sidebar-backdrop.open { opacity: 1; pointer-events: auto; }

  .main { padding: 22px 20px 50px; }
  .toc { display: none; }
  .home-hero, .card-grid, .footer { padding-left: 20px; padding-right: 20px; }
  .doc h1 { font-size: 2rem; }
}

@media (max-width: 600px) {
  .doc-nav { grid-template-columns: 1fr; }
  .search-results { width: calc(100vw - 32px); right: -8px; }
  .navbar-items.right .navbar-link span { display: none; }
}
