/* ============================================================
   NNAC Platform — Estilos principales
   ============================================================ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.6;
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; border: none; }
input, select, textarea { font-family: inherit; }

/* ── Layout principal ────────────────────────────────────────── */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--topbar-height) 1fr;
  min-height: 100vh;
}

.sidebar-overlay { display: none; }

/* Sidebar */
.sidebar {
  grid-row: 1 / -1;
  background: var(--bg-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-logo {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid rgba(255,255,255,.1);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo img { width: 40px; height: 40px; object-fit: contain; }

.sidebar-logo-text {
  font-family: var(--font-display);
  font-weight: var(--fw-extrabold);
  font-size: var(--text-lg);
  line-height: 1.2;
}

.sidebar-logo-text span {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--fw-normal);
  opacity: .7;
  font-family: var(--font-sans);
}

.sidebar-nav { flex: 1; padding: var(--space-4) 0; }

.nav-section-label {
  padding: var(--space-2) var(--space-6);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: .08em;
  opacity: .5;
  margin-top: var(--space-4);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-6);
  color: rgba(255,255,255,.8);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  transition: background var(--transition-fast), color var(--transition-fast);
  border-radius: 0;
  width: 100%;
  text-align: left;
  background: none;
}

.nav-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}

.nav-item.active {
  background: var(--dase-blue);
  color: #fff;
}

.nav-item .nav-icon { width: 20px; height: 20px; flex-shrink: 0; opacity: .9; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--nnac-coral);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: var(--fw-bold);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid rgba(255,255,255,.1);
  font-size: var(--text-xs);
  opacity: .85;
}

/* Topbar */
.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 var(--space-8);
  gap: var(--space-4);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-dark);
}

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--dase-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-bold);
  font-size: var(--text-base);
  flex-shrink: 0;
}

/* Main content */
.main-content {
  padding: var(--space-8);
  overflow-y: auto;
  max-width: 100%;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6);
  border: 1px solid var(--gray-100);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--gray-100);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--fw-semibold);
  color: var(--color-dark);
}

/* ── Stat cards (KPI) ───────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
  border-left: 4px solid var(--color-primary);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-card.green  { border-color: var(--color-success); }
.stat-card.yellow { border-color: var(--color-warning); }
.stat-card.coral  { border-color: var(--nnac-coral); }
.stat-card.teal   { border-color: var(--nnac-teal); }

.stat-label { font-size: var(--text-xs); color: var(--text-secondary); font-weight: var(--fw-medium); text-transform: uppercase; letter-spacing:.04em; }
.stat-value { font-size: var(--text-3xl); font-weight: var(--fw-extrabold); color: var(--color-dark); font-family: var(--font-display); line-height: 1; }
.stat-sub   { font-size: var(--text-xs); color: var(--text-secondary); }

/* ── Botones ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--fw-semibold);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  border: 2px solid transparent;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--dase-navy); text-decoration: none; color:#fff; }

.btn-secondary {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-secondary:hover { background: var(--color-primary); color: #fff; text-decoration: none; }

.btn-danger  { background: var(--color-error); color: #fff; }
.btn-danger:hover { background: #b71c1c; color:#fff; text-decoration:none; }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: var(--text-xs); }
.btn-lg { padding: var(--space-3) var(--space-8); font-size: var(--text-base); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-icon {
  background: none; border: none; border-radius: var(--radius-sm); color: var(--gray-500);
  font-size: 1.3rem; line-height: 1; min-width: 40px; min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.btn-icon:hover { background: var(--gray-100); color: var(--color-dark); }

/* ── Formularios ─────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: var(--space-1); }

.form-label {
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  color: var(--text-primary);
}

.form-control {
  padding: var(--space-3) var(--space-4);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30,136,199,.15);
}

.form-control.error { border-color: var(--color-error); }
.form-hint { font-size: var(--text-xs); color: var(--text-secondary); }
.form-error { font-size: var(--text-xs); color: var(--color-error); }

/* ── Tablas ────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-md); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table thead tr {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}

.table th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-weight: var(--fw-semibold);
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: var(--text-xs);
  letter-spacing: .05em;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-100);
  color: var(--text-primary);
}

.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr:last-child td { border-bottom: none; }

/* ── Badges / Pills ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
}

.badge-blue   { background: rgba(30,136,199,.12); color: var(--dase-blue); }
.badge-green  { background: rgba(63,166,68,.12);  color: var(--color-success); }
.badge-yellow { background: rgba(255,179,0,.15);  color: #9A6800; }
.badge-coral  { background: rgba(237,23,102,.10); color: var(--nnac-coral); }
.badge-gray   { background: var(--gray-100); color: var(--gray-500); }

/* ── Progress bar ───────────────────────────────────────────── */
.progress { background: var(--gray-200); border-radius: var(--radius-full); overflow: hidden; height: 8px; }
.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  transition: width var(--transition-slow);
}
.progress-bar.green  { background: var(--color-success); }
.progress-bar.yellow { background: var(--color-warning); }
.progress-bar.coral  { background: var(--nnac-coral); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.alert-error   { background: #FFEBEE; color: #B71C1C; border-left: 4px solid var(--color-error); }
.alert-success { background: #E8F5E9; color: #2E7D32; border-left: 4px solid var(--color-success); }
.alert-info    { background: #E3F2FD; color: #1565C0; border-left: 4px solid var(--dase-blue); }

/* ── Toggle / Checkbox asistencia ──────────────────────────── */
.check-toggle {
  appearance: none;
  width: 40px; height: 22px;
  background: var(--gray-300);
  border-radius: var(--radius-full);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast);
}
.check-toggle::after {
  content: '';
  position: absolute;
  left: 3px; top: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.check-toggle:checked { background: var(--color-success); }
.check-toggle:checked::after { transform: translateX(18px); }

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dase-navy) 0%, var(--dase-blue) 100%);
  padding: var(--space-4);
}

.login-card {
  background: #fff;
  border-radius: var(--radius-xl);
  padding: var(--space-10) var(--space-8);
  width: 100%;
  max-width: 420px;
  box-shadow: 0 24px 60px rgba(36,40,91,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}

.login-logo img { height: 84px; width: auto; margin: 0 auto var(--space-3); }

.login-logo h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--fw-extrabold);
  color: var(--color-dark);
}

.login-logo p { font-size: var(--text-sm); color: var(--text-secondary); }

.login-form { display: flex; flex-direction: column; gap: var(--space-5); }

/* ── Utilidades ─────────────────────────────────────────────── */
.flex   { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: var(--space-2); }
.gap-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.grid   { display: grid; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm  { font-size: var(--text-sm); }
.text-xs  { font-size: var(--text-xs); }
.text-muted { color: var(--text-secondary); }
.text-error { color: var(--color-error); }
.fw-bold { font-weight: var(--fw-bold); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mt-4  { margin-top: var(--space-4); }
.w-full { width: 100%; }

/* ── Responsive ─────────────────────────────────────────────── */
.btn-menu {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--topbar-height) 1fr;
  }

  .sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    z-index: 200;
    transition: left var(--transition-normal);
  }

  .sidebar.open { left: 0; }

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

  .sidebar-overlay.open { display: block; }

  .btn-menu { display: flex; }

  .main-content { padding: var(--space-4); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { padding: var(--space-6) var(--space-5); }
}

/* ── CSS Print — lista asistencia e informe participante ──── */
@media print {
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }

  .sidebar, .topbar, .btn-menu, .no-print,
  .nav-item, .sidebar-overlay { display: none !important; }

  .app-shell {
    grid-template-columns: 1fr !important;
    grid-template-rows: 1fr !important;
  }

  .main-content { padding: 0 !important; }

  .card { box-shadow: none !important; border: 1px solid #ccc !important; }

  .table th { background: #1E88C7 !important; color: white !important; }

  .check-toggle {
    appearance: none;
    width: 18px !important; height: 18px !important;
    border: 2px solid #333 !important;
    border-radius: 3px !important;
    background: white !important;
    display: inline-block !important;
  }

  .check-toggle:checked {
    background: #3FA644 !important;
    position: relative !important;
  }

  .check-toggle:checked::after {
    content: '✓' !important;
    position: absolute !important;
    top: -2px; left: 2px !important;
    font-size: 12px !important;
    color: white !important;
    font-weight: bold !important;
  }

  a { color: #1E88C7 !important; text-decoration: none !important; }

  @page {
    margin: 1.5cm;
    size: A4;
  }

  h1, h2 { page-break-after: avoid !important; }
  table   { page-break-inside: avoid !important; }
  tr      { page-break-inside: avoid !important; }
}

/* ── Footer institucional (lo genera assets/js/footer.js) ───────── */
.site-footer {
  display: block; width: 100%; max-width: 640px; margin: var(--space-8) auto 0;
  padding: var(--space-4) var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  text-align: center; font-size: var(--text-xs); line-height: 1.55; color: var(--text-secondary);
}
.site-footer p { margin: 2px 0; overflow-wrap: anywhere; }
.site-footer a { color: inherit; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; display: inline-block; padding: 6px 2px; }
.site-footer.on-dark, .site-footer.on-dark a { color: rgba(255,255,255,.92); }
.site-footer-logos {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: var(--space-3) var(--space-6);
  background: #fff; border-radius: var(--radius-lg); padding: var(--space-3) var(--space-5); margin: 0 auto var(--space-3);
  box-shadow: var(--shadow-sm); max-width: 100%;
}
.site-footer-logos img { height: 34px; width: auto; max-width: 100%; }
.site-footer-logos img[alt^="Muy"] { height: 46px; }        /* el escudo municipal lleva texto: necesita más altura */
.site-footer-copy { font-weight: 600; }

/* ── Modales propios (perfil, participante, envío de código) ───── */
.nnac-modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 400; display: flex; align-items: center; justify-content: center; padding: 16px; }
.nnac-modal-card { width: 100%; max-height: 92vh; max-height: 92dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.pf-fila { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Táctil y pantallas pequeñas ─────────────────────────────────── */
html { -webkit-text-size-adjust: 100%; }
button, a, .nav-item, .btn, select, input[type=checkbox], input[type=radio] { touch-action: manipulation; -webkit-tap-highlight-color: rgba(30,136,199,.15); }
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.acciones { display: flex; flex-wrap: wrap; gap: 6px; }
img { max-width: 100%; }

/* Pantallas táctiles: objetivos de toque ≥ 44 px y texto de campos ≥ 16 px (evita el zoom automático de iOS) */
@media (pointer: coarse) {
  .btn, .nav-item, .btn-icon, .btn-menu { min-height: 44px; }
  .btn-sm { min-height: 40px; padding-left: 14px; padding-right: 14px; }
  .btn-icon, .btn-menu { min-width: 44px; }
  .form-control, select, input, textarea { min-height: 44px; font-size: 16px; }
  .nav-item { padding-top: 12px; padding-bottom: 12px; }
  .table td .btn { margin: 2px 0; }
}

/* Tablet */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }
  .main-content { padding: var(--space-6); }
}

/* Celular y tablet vertical: menú lateral tipo cajón (ya existe) + ajustes */
@media (max-width: 768px) {
  .topbar { padding: 0 var(--space-3); padding-top: env(safe-area-inset-top, 0px); }
  .topbar-title { font-size: var(--text-base); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
  .topbar-user span, .topbar-user .text-sm { max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main-content { padding: var(--space-4) var(--space-3) var(--space-6); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: var(--space-4); }
  .pf-fila { grid-template-columns: 1fr; }
  .nnac-modal { padding: 0; align-items: flex-end; }
  .nnac-modal-card { max-width: 100% !important; max-height: 94dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px)); }
  .site-footer-logos { gap: var(--space-2) var(--space-4); padding: var(--space-2) var(--space-3); }
  .site-footer-logos img { height: 28px; }
  .site-footer-logos img[alt^="Muy"] { height: 38px; }
  .login-card { padding: var(--space-6) var(--space-4); }
}
@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr; }
  .flex.items-center.justify-between { flex-wrap: wrap; gap: var(--space-3); }
}
/* Sin animaciones si el usuario lo pide */
@media (prefers-reduced-motion: reduce) { * { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* Ocultar columnas secundarias en pantallas pequeñas + pestañas */
@media (max-width: 768px) { .hide-sm { display: none !important; } }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; border-bottom: 1px solid var(--gray-200); }
.tab { background: none; border: none; padding: 10px 16px; font-weight: 600; color: var(--text-secondary); border-bottom: 3px solid transparent; margin-bottom: -1px; min-height: 44px; }
.tab.active { color: var(--dase-blue); border-bottom-color: var(--dase-blue); }

/* Nada debe ensanchar la página: los contenidos anchos (tablas, matrices) hacen scroll dentro de su tarjeta */
.main-content { min-width: 0; }
.main-content .card { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.main-content .flex { flex-wrap: wrap; }
