/* ============================================================
   layout.css — componentes compartidos entre 2+ páginas: reset base,
   header/brand/footer (armados por layout.js), sidebar (armado por
   sidebar.js), botones/inputs/tablas/dropzone/etc. Si algo de acá solo
   lo usa una página, no pertenece aquí — bajarlo al .css específico de
   esa página. Ver docs/ARCHITECTURE.md y COMPONENTS.md.
   ============================================================ */

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  padding: 40px 20px;
}

a.back { display: inline-block; font-size: 12.5px; color: var(--gray); text-decoration: none; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 16px; margin-bottom: 4px; }
.brand img { height: 56px; width: auto; }
h1 { font-size: 20px; letter-spacing: 0.02em; margin: 0; color: var(--ink); }
.subtitle { color: var(--gray); font-size: 13.5px; margin: 6px 0 28px 0; }

/* Header persistente (todas las páginas salvo login), armado por layout.js */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--line);
}
.app-header-left { display: flex; align-items: center; gap: 16px; }
.app-header-logo { height: 40px; width: auto; display: block; }
.app-header-sep { width: 1px; height: 28px; background: var(--line); }
.app-header-title { color: var(--gray); font-size: 15px; font-weight: 500; }
.app-header-right { display: flex; align-items: center; gap: 12px; font-size: 13.5px; flex-wrap: wrap; }
.app-header-email { color: var(--gray); font-size: 13px; }
.btn-outline {
  display: inline-block;
  padding: 9px 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-outline:hover { background: var(--gray-light); border-color: var(--gray); }

/* Sub-hub de módulos — hub-*.html y osde-consulta.html (desambiguación) */
.module-list { display: flex; flex-direction: column; gap: 12px; }
.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  padding: 18px 22px;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s;
}
.module-row:hover { background: var(--line-subtle); }
.module-row-title { font-size: 15px; font-weight: 600; }
.module-row-desc { font-size: 12px; color: var(--gray); margin-top: 3px; }
.module-row-arrow { color: var(--gray); font-size: 18px; flex-shrink: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 3px solid var(--red);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 20px;
  overflow-x: auto;
}
/* Cuando no hay .subtitle entre el h1 y el primer bloque, el h1 (margin:0)
   necesita este espacio para no quedar pegado al borde superior. */
h1 + .card,
h1 + .tabs,
h1 + .report-grid {
  margin-top: 20px;
}
label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray);
  margin-bottom: 6px;
}
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
input[type="file"] {
  width: 100%;
  font-size: 13px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
}
.hint { font-size: 12px; color: var(--gray-dim); margin-top: 4px; }
#log {
  font-family: var(--mono);
  font-size: 12.5px;
  white-space: pre-wrap;
  line-height: 1.6;
  margin-top: 18px;
}
.ok { color: var(--ok); }
.err { color: var(--error); font-weight: 600; }

/* --- Botones --- */
button {
  padding: 10px 18px;
  background: var(--red);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--sans);
  cursor: pointer;
}
button:hover { background: var(--red-dark); }
button:disabled { background: var(--gray); cursor: not-allowed; }
button.secundario { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.secundario:hover { background: var(--gray-light); }
/* Botón de texto chico (ej. "Limpiar filtros") */
button.chico { padding: 4px 10px; font-size: 12px; }
/* Botón cuadrado de ícono (ej. ✕ borrar fila en una tabla) */
button.btn-icon { padding: 4px 8px; font-size: 15px; line-height: 1; }
/* CTA de ancho completo — para pantallas de una sola acción
   (login, generadores de archivo) en vez del botón compacto por
   defecto, que es para pantallas con varias acciones lado a lado. */
button.btn-full {
  width: 100%;
  padding: 14px;
  margin-top: 8px;
  font-size: 14px;
  letter-spacing: 0.03em;
}

/* --- Inputs de formulario --- */
input[type="text"],
input[type="number"],
input[type="date"],
input[type="month"],
input[type="email"],
input[type="password"],
select {
  width: 100%;
  font-size: 14px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--mono);
  background: var(--paper);
  color: var(--ink);
}
select { font-family: var(--sans); }

/* --- Grillas de formulario --- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 900px) {
  .grid4 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 700px) {
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
}

.acciones { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }

/* --- Tablas --- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray);
  padding: 8px 6px;
  border-bottom: 2px solid var(--line);
}
td { padding: 8px 6px; border-bottom: 1px solid var(--line-subtle); vertical-align: middle; color: var(--table-text); }
tr:hover td { background: var(--gray-light); }

/* Tabla densa editable (ej. previsualización de carga, tablas de Admin) —
   contexto genuinamente distinto de una tabla de lectura: más columnas,
   inputs embebidos, necesita menos aire por fila a propósito. */
.tabla-compacta { font-size: 12.5px; }
.tabla-compacta th { font-size: 10.5px; padding: 8px 5px; }
.tabla-compacta td { padding: 5px; }
.tabla-compacta td input[type="text"],
.tabla-compacta td input[type="number"],
.tabla-compacta td input[type="date"],
.tabla-compacta td select {
  font-size: 12px;
  padding: 5px 6px;
  border-radius: 4px;
}

/* --- Zona de carga con drag & drop --- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 56px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--paper);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--red); background: var(--line-subtle); }
.dropzone-text { font-size: 16px; font-weight: 600; color: var(--ink); margin: 0 0 6px 0; }
.dropzone-sub { font-size: 13px; color: var(--gray); margin: 0; }
.dropzone-filename { font-size: 12.5px; color: var(--ok); margin-top: 6px; }

/* --- Resumen de métricas (tarjetas de números grandes) --- */
.resumen { display: flex; gap: 24px; margin-bottom: 18px; font-size: 13px; flex-wrap: wrap; }
.resumen strong { display: block; font-size: 22px; color: var(--ink); }
.resumen .venc strong { color: var(--warn); }

/* --- Chips de filtro --- */
.chip { padding: 8px 14px; background: var(--gray-light); color: var(--gray); font-size: 12.5px; font-weight: 600; cursor: pointer; border-radius: 6px; }
.chip.activo { background: var(--ink); color: white; }

/* --- Barra de proporción horizontal --- */
.barra { height: 8px; background: var(--gray-light); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.barra-fill { height: 100%; background: var(--red); }

.empty-state { color: var(--gray); font-size: 13px; }

/* --- Pills de estado — mismo tamaño en todo el sitio, cada página
   usa el nombre semántico que corresponda a su propio dominio. --- */
.estado-tag { font-size: 10.5px; text-transform: uppercase; padding: 3px 9px; border-radius: 4px; font-weight: 700; white-space: nowrap; display: inline-block; }
.estado-alta, .estado-ok, .estado-pagada { background: var(--ok-light); color: var(--ok); }
.estado-baja, .estado-error, .estado-existe, .estado-vencida { background: var(--red-light); color: var(--warn); }
.estado-neutro, .estado-nueva, .estado-pendiente { background: var(--gray-light); color: var(--gray); }

.tipo-tag { font-size: 10.5px; text-transform: uppercase; padding: 2px 8px; border-radius: 4px; font-weight: 600; }
.downloads { margin-top: 18px; display: none; }
.downloads a {
  display: block;
  padding: 12px 16px;
  background: var(--red-light);
  border: 1px solid var(--red);
  border-radius: 6px;
  color: var(--red-dark);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}
.downloads a:hover { background: var(--red); color: white; }

@media (max-width: 480px) {
  body { padding: 24px 14px; }
  .brand img { height: 44px; }
  .card { padding: 18px; }
  .app-header { padding-bottom: 12px; margin-bottom: 20px; }
  .app-header-logo { height: 32px; }
  .app-header-sep { height: 22px; }
}

/* Reportes: gráficos CSS, sin librerías — reportes-afiliados.html y
   reportes-prestaciones.html */
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.report-grid .card { margin-bottom: 0; }
.report-card-title { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 18px 0; }

.chart-bar-row { margin-bottom: 16px; }
.chart-bar-row:last-child { margin-bottom: 0; }
.chart-bar-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.chart-bar-label .valor { font-weight: 600; color: var(--ink); }
.chart-bar-track { height: 8px; background: var(--line-subtle); border-radius: 4px; overflow: hidden; }
.chart-bar-fill { height: 100%; background: var(--red); border-radius: 4px; }

.chart-bars-vertical { display: flex; align-items: flex-end; gap: 18px; height: 200px; padding-top: 24px; }
.chart-bar-col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; height: 100%; }
.chart-bar-col-value { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.chart-bar-col-bar { width: 100%; max-width: 44px; background: var(--red); border-radius: 4px 4px 0 0; }
.chart-bar-col-label { font-size: 11.5px; color: var(--gray); margin-top: 8px; }

.chart-donut-wrap { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.chart-donut { width: 160px; height: 160px; border-radius: 50%; flex-shrink: 0; }
.chart-legend { display: flex; flex-direction: column; gap: 10px; font-size: 13px; flex: 1; min-width: 140px; }
.chart-legend-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chart-legend-item .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; flex-shrink: 0; }
.chart-legend-item .nombre { display: flex; align-items: center; color: var(--ink); }
.chart-legend-item .valor { color: var(--gray); font-weight: 600; }

@media (max-width: 700px) {
  .report-grid { grid-template-columns: 1fr; }
  .chart-donut-wrap { flex-direction: column; align-items: flex-start; }
}

/* ============================================================
   Sidebar de navegación compartido — construido en runtime por
   sidebar.js a partir de nav-config.js, no vive en el HTML de cada
   página. Ver docs/ARCHITECTURE.md.
   ============================================================ */
.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 260px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 100;
  padding: 24px 0 16px;
  transition: transform var(--motion-duration) var(--motion-ease);
}
.sidebar-brand { display: block; padding: 0 20px 20px; }
.sidebar-brand img { height: 32px; width: auto; display: block; }
.sidebar-nav { display: flex; flex-direction: column; }
.sidebar-group { margin-bottom: 4px; }
.sidebar-group-title {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray);
  padding: 16px 20px 6px;
  margin: 0;
  text-decoration: none;
}
a.sidebar-group-title:hover { color: var(--ink); }
a.sidebar-group-title.activo { color: var(--red-dark); }
.sidebar-link {
  display: block;
  padding: 8px 20px;
  font-size: 13.5px;
  color: var(--ink);
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar-link:hover { background: var(--line-subtle); }
.sidebar-link.activo {
  background: var(--red-light);
  color: var(--red-dark);
  border-left-color: var(--red);
  font-weight: 600;
}
.sidebar-footer { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

.sidebar-toggle {
  display: none;
  width: 32px;
  height: 32px;
  margin-right: 12px;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--gray-light); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 99;
}

body.con-sidebar { padding-left: 280px; }

@media (max-width: 900px) {
  body.con-sidebar { padding-left: 20px; }
  .app-sidebar { transform: translateX(-100%); }
  .app-sidebar.abierto { transform: translateX(0); }
  .sidebar-toggle { display: inline-block; }
  .sidebar-backdrop.visible { display: block; }
}

/* ============================================================
   View Transitions entre páginas — navegación tradicional (<a href>,
   recarga real de documento), no SPA. Habilitado por el meta tag
   view-transition en cada HTML. En browsers sin soporte estas reglas
   se ignoran solas, sin fallback en JS.
   ============================================================ */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--motion-duration);
  animation-timing-function: var(--motion-ease);
}

/* El sidebar no debe parpadear/reiniciar entre páginas: se lo nombra
   para que el browser lo trate como el mismo elemento persistente en
   vez de cruzarlo en fade junto con el resto del documento. */
.app-sidebar { view-transition-name: app-sidebar; }
::view-transition-old(app-sidebar),
::view-transition-new(app-sidebar) {
  animation: none;
  mix-blend-mode: normal;
}
