/* ==========================================================================
   tokens.css — Design Tokens globales (WebForge Precision Engine)
   Centraliza :root para todo renewal. Importado ANTES de becado.css/dashboard.css.
   Mantiene retrocompatibilidad: no elimina variables existentes, solo unifica.
   ========================================================================== */

:root {
  /* --- Identidad Fundación Herencia Viva --- */
  --fhv-brand-green: #52aa31;
  --fhv-brand-blue: #356091;
  --fhv-brand-yellow: #fbbc13;

  /* --- Paleta primaria (hereda FHV) --- */
  --color-primary: var(--fhv-brand-blue, #356091);
  --color-primary-dark: #2a4d74;
  --color-primary-light: #eaf0f7;
  --color-success: var(--fhv-brand-green, #52aa31);
  --color-success-dark: #3d7e25;
  --color-success-light: #e7f7ee;
  --color-accent: #0d6efd;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #0ea5e9;
  --color-purple: #8b5cf6;

  /* --- Compat: becado.css espera --bec-* --- */
  --bec-primary: var(--color-success);
  --bec-primary-dark: var(--color-success-dark);
  --bec-primary-light: var(--color-success-light);
  --bec-accent: var(--color-accent);
  --bec-warning: var(--color-warning);
  --bec-danger: var(--color-danger);
  --bec-info: var(--color-info);
  --bec-purple: var(--color-purple);

  /* --- Neutros — fondo blanco para premium (era #f4f6fb) --- */
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-border: #e4e8f0;
  --color-text: #0f172a;
  --color-text-soft: #475569;
  --color-muted: #94a3b8;

  /* Compat bec- */
  --bec-bg: var(--color-bg);
  --bec-surface: var(--color-surface);
  --bec-border: var(--color-border);
  --bec-text: var(--color-text);
  --bec-text-soft: var(--color-text-soft);
  --bec-muted: var(--color-muted);

  /* --- Tipografía --- */
  --font-sans: "Lato", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --bec-font: var(--font-sans);
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;

  /* --- Espaciado (4px scale) --- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-6: 1.5rem;
  --space-8: 2rem;

  /* --- Radios & sombras --- */
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;
  --bec-radius: var(--radius);
  --bec-radius-sm: var(--radius-sm);
  --shadow-sm: 0 2px 6px rgba(53, 96, 145, 0.1);
  --shadow: 0 10px 30px rgba(53, 96, 145, 0.16);
  --shadow-lg: 0 18px 45px rgba(53, 96, 145, 0.24);
  --bec-shadow-sm: var(--shadow-sm);
  --bec-shadow: var(--shadow);
  --bec-shadow-lg: var(--shadow-lg);

  /* --- Transiciones --- */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --fhv-transition: var(--transition);

  /* --- Layout --- */
  --navbar-h: 62px;
  --sidebar-w: 225px;
  --content-max: 1440px;
  --fhv-navbar-h: var(--navbar-h);
  --fhv-sidebar-w: var(--sidebar-w);

  /* --- Z-index scale --- */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* Dark mode: respeta prefers-color-scheme, toggle JS puede añadir .dark */
@media (prefers-color-scheme: dark) {
  :root:not(.light) {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-text: #e2e8f0;
    --color-text-soft: #94a3b8;
    --bec-bg: var(--color-bg);
    --bec-surface: var(--color-surface);
    --bec-border: var(--color-border);
    --bec-text: var(--color-text);
    --bec-text-soft: var(--color-text-soft);
  }
}
:root.dark {
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-border: #334155;
  --color-text: #e2e8f0;
  --color-text-soft: #94a3b8;
  --bec-bg: var(--color-bg);
  --bec-surface: var(--color-surface);
  --bec-border: var(--color-border);
  --bec-text: var(--color-text);
  --bec-text-soft: var(--color-text-soft);
}

/* Alto contraste (WCAG) — activado con <html class="high-contrast"> */
:root.high-contrast {
  --color-primary: #0000ee;
  --color-text: #000000;
  --color-bg: #ffffff;
  --color-border: #000000;
}

/* Reset suave moderno */
*, *::before, *::after { box-sizing: border-box; }
html { scrollbar-gutter: stable; }
body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Helpers de accesibilidad y animación */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ═══════════════════════════════════════════════════════════════
   CONTRASTE 2026-10-21 — legibilidad real de títulos y textos
   Auditoría WCAG sobre fondos #fff / #fcfcfc / #f8fafc / #f1f5f9:
     text-zinc-400  #a1a1aa → 2.5:1  ❌ INVISIBLE
     text-slate-400 #94a3b8 → 2.5:1  ❌ INVISIBLE
     text-gray-400  #9ca3af → 2.5:1  ❌ INVISIBLE
     text-zinc-500  #71717a → 4.6:1  ⚠️ falla en gris claro
     .text-muted    #6c757d → 4.5:1  ⚠️ falla en #f8fafc
     #475569 (slate-600) → 7.2:1  ✅ AA en todos los fondos
   Verificado: ninguno de estos grises se usa sobre fondo oscuro
   (sidebar/footer usan text-white-*), por eso el fix es global.
   ═══════════════════════════════════════════════════════════════ */
.text-zinc-300, .text-zinc-400, .text-zinc-500,
.text-slate-300, .text-slate-400, .text-slate-500,
.text-gray-300, .text-gray-400, .text-gray-500 {
  color: #475569 !important;
}
/* .text-muted (Bootstrap/SB Admin) sube a AA; el footer oscuro conserva el suyo */
.text-muted { color: #475569 !important; }
.fhv-footer .text-muted { color: inherit !important; }
/* Iconos decorativos dentro de inputs: suben a gris legible */
input::placeholder, textarea::placeholder, select::placeholder { color: #475569; opacity: 1; }

/* ═══ BASE DE TEXTO LEGIBLE 2026-10-14 ═══
   El tema SB Admin deja algunos contenedores (modales, paneles) heredando un gris
   lavado, por eso textos como "Donante:" quedaban casi invisibles aunque el elemento
   no tuviera ninguna clase de color. Se fija una base oscura SOLO en contenedores
   de fondo claro; los que tienen fondo oscuro traen su propio color (inline/class).
   Verificado: ninguna .card-premium usa fondo oscuro. */
main,
.modal-content,
.modal-body,
.becado-panel,
.card-premium {
  color: #0f172a;
}

/* Overrides del tema SB Admin (styles.css carga ANTES que tokens.css):
   sus grises Wash-out fallan AA sobre fondos claros. */
.card-text,
caption,
.blockquote-footer {
  color: #475569 !important;
}
/* Texto de validación de formularios (verde/rojo del tema) */
.valid-feedback,
.was-validated .form-control:valid,
.was-validated .form-control.is-valid {
  color: #166534 !important;
}
.invalid-feedback,
.was-validated .form-control:invalid,
.was-validated .form-control.is-invalid {
  color: #b91c1c !important;
}
/* Icono de "Salir" en el menú de usuario */
.fhv-user-menu .dropdown-item.fhv-logout i {
  color: #b91c1c !important;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
