/* ==========================================================================
ATRIA — SISTEMA DE AYUDA (CON LOGO RESPONSIVO Y CORRECCIONES DE DESBORDAMIENTO)
Paleta de marca: #0099B0 acento · #0D1B3E navy · #FFFFFF fondo
========================================================================== */

:root {
  --accent: #0099B0;
  --accent-light: #e6f7fa;
  --accent-mid: #007d92;
  --navy: #0D1B3E;
  --navy-mid: #1a2d5a;
  --ink: #111111;
  --ink-mid: #4a5568;
  --ink-light: #94a3b8;
  --border: #e2e8f0;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --sidebar-w: 272px;
  --radius: 8px;
  --font: 'DM Sans', -apple-system, sans-serif;
  --mono: 'DM Mono', ui-monospace, monospace;
}

*, *::before, *::after { 
  box-sizing: border-box; 
  margin: 0; 
  padding: 0; 
}

html { 
  scroll-behavior: smooth; 
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-mid);
  background: var(--bg-soft);
  -webkit-font-smoothing: antialiased;
  /* Evita el desborde horizontal de toda la pantalla en móviles */
  overflow-x: hidden;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: none; /* MODIFICADO: Eliminada línea superior debajo del logo */
  flex-shrink: 0;
}

.brand { 
  display: flex; 
  flex-direction: column; 
  gap: 2px; 
  width: 100%; /* Asegura que no colapse el contenedor */
}

/* NUEVA CLASE PARA EL LOGO - TOTALMENTE RESPONSIVA */
.brand-logo {
  display: block;
  max-height: 75px;        /* Mantiene el tamaño grande de 75px que te gusta en ordenador */
  max-width: 100%;         /* Evita que el logo sea más ancho que la barra lateral (previene desborde) */
  width: auto;             /* Escala el ancho de forma proporcional */
  height: auto;            /* Escala el alto de forma proporcional */
  object-fit: contain;     /* Impide cualquier tipo de deformación visual */
  align-self: flex-start;  /* Alinea el logo a la izquierda */
  margin-bottom: 12px;     /* Separación uniforme con el texto de abajo */
}

.brand-name {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 3px;
  color: #ffffff;
}

.brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.5px;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 16px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

/* SEARCH */
.search-wrap {
  position: relative;
  padding: 14px 16px;
  border-bottom: none; /* MODIFICADO: Eliminada línea inferior debajo del buscador */
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: rgba(255,255,255,0.3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 8px 32px 8px 34px;
  color: #ffffff;
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.search-input::placeholder { color: rgba(255,255,255,0.25); }

.search-input:focus {
  border-color: var(--accent);
  background: rgba(0,153,176,0.1);
}

.search-clear {
  position: absolute;
  right: 26px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-size: 13px;
  cursor: pointer;
  display: none;
  padding: 4px;
  line-height: 1;
}

.search-clear.visible { display: block; }

/* NAV MENU */
.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-menu::-webkit-scrollbar { width: 4px; }
.nav-menu::-webkit-scrollbar-track { background: transparent; }
.nav-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.nav-label {
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 4px 10px 10px;
}

#navList {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 400;
  transition: background 0.12s, color 0.12s;
}

.nav-link svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.12s;
}

.nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.85);
}

.nav-link:hover svg { opacity: 0.9; }

.nav-link.active {
  background: rgba(0,153,176,0.18);
  color: #ffffff;
  font-weight: 500;
}

.nav-link.active svg {
  opacity: 1;
  color: var(--accent);
}

.nav-link.hidden { display: none; }

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.footer-link {
  font-size: 11px;
  color: rgba(255,255,255,0.25);
  text-decoration: none;
  font-family: var(--mono);
  transition: color 0.15s;
}

.footer-link:hover { color: var(--accent); }

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.layout {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden; /* Evita que el layout principal desborde en pantallas pequeñas */
}

/* TOPBAR (solo mobile) */
.topbar {
  display: none;
  align-items: center;
  gap: 14px;
  padding: 0 20px;
  height: 52px;
  background: var(--navy);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  position: sticky;
  top: 0;
  z-index: 100;
}

.menu-toggle {
  background: none;
  border: none;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.menu-toggle svg { width: 18px; height: 18px; }

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
}

/* MAIN */
.main {
  flex: 1;
  padding: 48px 60px;
  max-width: 900px;
  width: 100%;
}

/* LOADING */
.loading {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-light);
  font-size: 14px;
  padding-top: 60px;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* OVERLAY MOBILE */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 150;
}

/* ==========================================================================
   CONTENIDO MARKDOWN RENDERIZADO
   ========================================================================== */
.article h1 {
  font-size: 28px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.5px;
  line-height: 1.2;
  margin-bottom: 8px;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.article-tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  padding: 3px 8px;
  border-radius: 4px;
}

.article-version {
  font-size: 12px;
  color: var(--ink-light);
  font-family: var(--mono);
}

.article h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  margin-top: 40px;
  margin-bottom: 12px;
  letter-spacing: -0.2px;
}

.article h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-top: 28px;
  margin-bottom: 8px;
}

.article p {
  font-size: 15px;
  color: var(--ink-mid);
  line-height: 1.75;
  margin-bottom: 16px;
}

.article ul, .article ol {
  padding-left: 20px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.article li {
  font-size: 15px;
  color: var(--ink-mid);
  line-height: 1.65;
}

.article ul li::marker { color: var(--accent); }
.article strong { color: var(--ink); font-weight: 500; }

.article code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--navy-mid);
}

.article pre {
  background: var(--navy);
  border-radius: var(--radius);
  padding: 20px;
  overflow-x: auto;
  margin: 20px 0;
  max-width: 100%; /* Evita que bloques de código desborden la pantalla móvil */
}

.article pre code {
  background: none;
  border: none;
  color: rgba(255,255,255,0.85);
  font-size: 13px;
  padding: 0;
}

.article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 36px 0;
}

/* REGLA GLOBAL RESPONSIVE PARA TODAS LAS IMÁGENES DENTRO DE LOS ARCHIVOS MD */
.article img {
  display: block;
  max-width: 100%;                  /* Impide que la imagen sea más ancha que la pantalla */
  height: auto;                     /* Mantiene la proporción visual intacta */
  margin: 24px auto;                /* Separa y centra la imagen en el cuerpo del texto */
  border-radius: var(--radius);     /* Redondeo de esquinas de 8px oficial de ATRIA */
  box-shadow: 0 4px 16px rgba(13, 27, 62, 0.06); /* Sombra elegante */
}

/* CALLOUTS — sintaxis: > [!NOTE] / [!WARNING] / [!TIP] */
.callout {
  display: flex;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius);
  margin: 24px 0;
  font-size: 14px;
  line-height: 1.65;
}

.callout-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.callout p { margin: 0; font-size: 14px; }
.callout strong { display: block; margin-bottom: 4px; font-size: 13px; font-family: var(--mono); letter-spacing: 0.5px; }

.callout.note { background: var(--accent-light); border-left: 3px solid var(--accent); color: #1a5f6e; }
.callout.warning { background: #fff7ed; border-left: 3px solid #f97316; color: #7c3d12; }
.callout.danger { background: #fff1f2; border-left: 3px solid #ef4444; color: #7f1d1d; }
.callout.tip { background: #f0fdf4; border-left: 3px solid #22c55e; color: #14532d; }

/* IMAGEN PLACEHOLDER */
.img-placeholder {
  background: var(--bg-soft);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--ink-light);
  font-size: 13px;
  margin: 24px 0;
  font-family: var(--mono);
}

/* STEPS */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 20px 0;
}

.steps li {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  counter-increment: step;
  position: relative;
}

.steps li::before {
  content: counter(step);
  width: 26px;
  height: 26px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 12px;
  font-family: var(--mono);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

/* ==========================================================================
   PÁGINA DE INICIO
   ========================================================================== */
.home-hero {
  margin-bottom: 48px;
}

.home-hero h1 {
  font-size: 32px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}

.home-hero p {
  font-size: 16px;
  color: var(--ink-mid);
  font-weight: 300;
  max-width: 520px;
  line-height: 1.7;
}

.modules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.module-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 18px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
  cursor: pointer;
}

.module-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 16px rgba(0,153,176,0.08);
  transform: translateY(-1px);
}

.module-card-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-light);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.module-card-icon svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.module-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 2px;
}

.module-card-desc {
  font-size: 12px;
  color: var(--ink-light);
  line-height: 1.4;
}

/* ==========================================================================
   BÚSQUEDA — RESULTADOS
   ========================================================================== */
.search-results h2 {
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 6px;
}

.search-results-meta {
  font-size: 13px;
  color: var(--ink-light);
  margin-bottom: 28px;
}

.result-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  text-decoration: none;
  display: block;
}

.result-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(0,153,176,0.08);
}

.result-card-title {
  font-size: 15px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 4px;
}

.result-card-excerpt {
  font-size: 13px;
  color: var(--ink-mid);
  line-height: 1.55;
}

.result-card-excerpt mark {
  background: #fef08a;
  color: var(--ink);
  border-radius: 2px;
  padding: 0 2px;
}

.no-results {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-light);
}

.no-results p { font-size: 14px; margin-top: 8px; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w); /* Sigue manteniendo el ancho de 272px para cuando se abra */
  }
  
  .sidebar.open {
    transform: translateX(0);
  }
  
  /* Ajuste de escala específico para que el logo quepa perfecto en la barra móvil */
  .brand-logo {
    max-height: 55px; /* En móvil limitamos ligeramente la altura máxima para que quepa mejor */
    margin-bottom: 8px;
  }
  
  .sidebar-close { display: block; }
  .overlay.visible { display: block; }
  .layout { margin-left: 0; }
  .topbar { display: flex; }
  .main { padding: 28px 20px; }
  .modules-grid { grid-template-columns: 1fr; }
}
