/* ==========================================================================
   Variables y Configuración Global (WCAG 2.1 AA Compliant)
   ========================================================================== */
:root {
  --primary-blue: #0F172A;
  --secondary-red: #C8102E;
  --secondary-red-hover: #A00C23;
  --bg-light: #F8FAFC;
  --bg-white: #FFFFFF;
  --text-main: #0F172A;
  --text-muted: #475569;
  --border-color: #E2E8F0;
  --focus-ring: #0284C7;
  
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
  --base-font-size: 100%; /* 16px por defecto */
}

/* Restablecimiento Básico y Accesible */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--base-font-size);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-light);
  color: var(--text-main);
  line-height: 1.6;
  font-weight: 400;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
}

/* Utilidad para Lector de Pantalla */
.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;
}

/* Enlace de Salto (Accessibility Skip Link) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 10px;
  background: var(--secondary-red);
  color: #fff;
  padding: 8px 16px;
  z-index: 9999;
  font-weight: 600;
  border-radius: 0 0 4px 4px;
  transition: top 0.2s ease;
  text-decoration: none;
}
.skip-link:focus {
  top: 0;
}

/* Foco de Teclado Visible e Inconfundible (WCAG 2.4.7) */
:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 3px;
}

/* ==========================================================================
   Barra de Accesibilidad
   ========================================================================== */
.accessibility-bar {
  background-color: #1E293B;
  color: #fff;
  padding: 6px 0;
  font-size: 0.875rem;
}
.accessibility-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}
.btn-acc {
  background: transparent;
  border: 1px solid #64748B;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
.btn-acc:hover {
  background: #334155;
}

/* ==========================================================================
   Header y Navegación
   ========================================================================== */
.site-header {
  background-color: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1000;
}
.header-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 0;
}
.logo-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo-text-bold {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary-blue);
}
.logo-tag {
  background-color: var(--secondary-red);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 3px;
}
.main-nav ul {
  display: flex;
  list-style: none;
  gap: 1.5rem;
}
.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.5rem;
  border-bottom: 2px solid transparent;
}
.nav-link:hover, .nav-link.nav-link-active {
  color: var(--primary-blue);
  border-bottom-color: var(--secondary-red);
}

.header-search form {
  display: flex;
}
.header-search input {
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px 0 0 4px;
}
.header-search button {
  background: var(--primary-blue);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
}

.mobile-menu-toggle {
  display: none;
}

/* ==========================================================================
   Breadcrumb
   ========================================================================== */
.breadcrumb-nav {
  background-color: #F1F5F9;
  padding: 0.75rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--border-color);
}
.breadcrumb {
  display: flex;
  list-style: none;
  gap: 0.5rem;
}
.breadcrumb li+li::before {
  content: "/";
  padding-right: 0.5rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--primary-blue);
  text-decoration: none;
}
.breadcrumb a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Page Header (Páginas Internas como legal.php)
   ========================================================================== */
.page-header-section {
  background-color: var(--bg-white);
  padding: 3rem 0 2rem 0;
  border-bottom: 1px solid var(--border-color);
}
.page-header-section h1 {
  font-size: 2.25rem;
  color: var(--primary-blue);
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}
.page-header-subtitle {
  font-size: 1.125rem;
  color: var(--text-muted);
  max-width: 800px;
}

/* ==========================================================================
   Filtros de Normativa
   ========================================================================== */
.legal-filter-section {
  padding: 1.5rem 0;
  background-color: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
}
.filter-bar {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 240px;
}
.filter-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-blue);
}
.form-control {
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.95rem;
}

/* ==========================================================================
   Hero Section & Teaser
   ========================================================================== */
.hero-section {
  padding: 4rem 0;
  background-color: var(--bg-white);
}
.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: center;
}
.badge {
  background: #E0F2FE;
  color: #0369A1;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 0.5rem;
}
.hero-content h1 {
  font-size: 2.25rem;
  color: var(--primary-blue);
  line-height: 1.2;
  margin-bottom: 1rem;
}
.hero-subtitle {
  font-size: 1.125rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.hero-actions {
  display: flex;
  gap: 1rem;
}
.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  text-decoration: none;
  border-radius: 6px;
  transition: background 0.2s, transform 0.1s;
  border: none;
  cursor: pointer;
}
.btn-primary {
  background-color: var(--secondary-red);
  color: #fff;
}
.btn-primary:hover {
  background-color: var(--secondary-red-hover);
}
.btn-secondary {
  background-color: var(--primary-blue);
  color: #fff;
}
.btn-outline {
  border: 1px solid var(--primary-blue);
  color: var(--primary-blue);
}
.btn-outline:hover {
  background-color: var(--primary-blue);
  color: #fff;
}

.legal-teaser-section {
  padding: 3rem 0;
  background-color: var(--bg-white);
}
.teaser-card {
  background-color: #F1F5F9;
  border-left: 5px solid var(--secondary-red);
  padding: 2rem;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2rem;
}
.teaser-content h2 {
  font-size: 1.5rem;
  color: var(--primary-blue);
  margin-bottom: 0.5rem;
}

.dashboard-mockup {
  background: var(--primary-blue);
  color: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.mockup-header {
  font-weight: 700;
  border-bottom: 1px solid #334155;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}
.mockup-card {
  background: #1E293B;
  padding: 0.75rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
}
.mockup-card span {
  color: #4ADE80;
  font-weight: 600;
}

/* ==========================================================================
   Secciones Generales y Grids
   ========================================================================== */
.metrics-section, .pillars-section, .platforms-section, .resources-section, .faq-section {
  padding: 4rem 0;
}
.section-header {
  text-align: center;
  margin-bottom: 2.5rem;
}
.section-header h2 {
  font-size: 1.875rem;
  color: var(--primary-blue);
}

.metrics-grid, .pillars-grid, .platforms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.metric-card, .pillar-card, .platform-card {
  background: var(--bg-white);
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}
.metric-number {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--secondary-red);
  display: block;
}
.pillar-icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.platform-card {
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
  display: block;
}
.platform-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.resources-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.resource-item {
  background: var(--bg-white);
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.resource-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.file-type {
  background: #FEE2E2;
  color: var(--secondary-red);
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  margin-right: 1rem;
}

/* FAQ Accordion */
.faq-accordion {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.faq-item {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}
.faq-trigger {
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--primary-blue);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.faq-content {
  padding: 0 1.25rem 1.25rem 1.25rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  background-color: var(--primary-blue);
  color: #fff;
  padding-top: 3rem;
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 2rem;
  padding-bottom: 2rem;
}
.site-footer a {
  color: #CBD5E1;
  text-decoration: none;
}
.site-footer a:hover {
  color: #fff;
}
.footer-bottom {
  background-color: #020617;
  padding: 1rem 0;
  font-size: 0.875rem;
}

/* ==========================================================================
   Modo de Alto Contraste (Activación mediante JS)
   ========================================================================== */
body.high-contrast {
  background-color: #000000 !important;
  color: #FFFFFF !important;
}
body.high-contrast .site-header,
body.high-contrast .metric-card,
body.high-contrast .pillar-card,
body.high-contrast .platform-card,
body.high-contrast .resource-item,
body.high-contrast .news-card,
body.high-contrast .news-detail,
body.high-contrast .plans-table-wrapper,
body.high-contrast .admin-login-card,
body.high-contrast .faq-item,
body.high-contrast .hero-section,
body.high-contrast .page-header-section,
body.high-contrast .legal-filter-section,
body.high-contrast .breadcrumb-nav {
  background-color: #000000 !important;
  color: #FFFFFF !important;
  border: 2px solid #FFFF00 !important;
}
body.high-contrast a, 
body.high-contrast h1, 
body.high-contrast h2, 
body.high-contrast h3,
body.high-contrast .faq-trigger {
  color: #FFFF00 !important;
}
body.high-contrast .btn-primary {
  background-color: #FFFF00 !important;
  color: #000000 !important;
  font-weight: 800;
}
body.high-contrast .form-control {
  background-color: #000000;
  color: #FFFFFF;
  border-color: #FFFF00;
}

/* Responsive (Mobile/Tablet) */
@media (max-width: 768px) {
  .hero-grid { grid-template-columns: 1fr; }
  .mobile-menu-toggle { display: block; background: none; border: none; font-size: 1.5rem; cursor: pointer; }
  .main-nav { display: none; width: 100%; }
  .main-nav.is-open { display: block; }
  .main-nav ul { flex-direction: column; gap: 0; }
  .resource-item { flex-direction: column; align-items: flex-start; gap: 1rem; }
  .teaser-card { flex-direction: column; align-items: flex-start; }
}

/* ==========================================================================
   Noticias (Página pública)
   ========================================================================== */
.news-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.5rem;
}
.news-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}
.news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.news-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
  height: 100%;
}
.news-card-image {
  aspect-ratio: 16 / 9;
  background: #F1F5F9;
  overflow: hidden;
}
.news-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.news-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: #E2E8F0;
}
.news-card-body {
  padding: 1.25rem;
}
.news-date {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}
.news-card-body h3 {
  font-size: 1.125rem;
  color: var(--primary-blue);
  margin-bottom: 0.5rem;
  line-height: 1.35;
}
.news-card-body p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 0.75rem;
}
.news-read-more {
  color: var(--secondary-red);
  font-weight: 600;
  font-size: 0.9rem;
}
.filter-actions {
  flex-direction: row;
  align-items: flex-end;
  gap: 0.75rem;
  flex: 0;
  min-width: auto;
}

/* ==========================================================================
   Planes (Página planes.php)
   ========================================================================== */
.plans-table-wrapper {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-x: auto;
  max-width: 960px;
  margin: 0 auto;
}
.plans-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.plans-table th,
.plans-table td {
  padding: 1rem 1.25rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: top;
}
.plans-table th:first-child,
.plans-table td:first-child,
.plans-table th:last-child,
.plans-table td:last-child {
  text-align: center;
}
.plans-table th {
  font-weight: 600;
  color: var(--primary-blue);
  background: #F8FAFC;
}
.plans-table tbody tr:last-child td {
  border-bottom: none;
}
.plans-table tbody tr:hover {
  background: #F8FAFC;
}
.plans-table td:first-child {
  width: 120px;
  font-weight: 600;
  color: var(--secondary-red);
}
.plans-table td:last-child {
  width: 160px;
  white-space: nowrap;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  background: var(--bg-white);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
}
.empty-state .btn {
  margin-top: 1rem;
}

/* Detalle de noticia */
.news-detail-section {
  padding: 3rem 0 4rem;
}
.news-detail {
  max-width: 800px;
  margin: 0 auto;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.news-detail-image img {
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  display: block;
}
.news-detail-content {
  padding: 2rem;
  color: var(--text-main);
  line-height: 1.8;
  font-size: 1.05rem;
}
.news-detail-footer {
  padding: 0 2rem 2rem;
}
.breadcrumb {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--primary-blue);
  text-decoration: none;
}
.breadcrumb a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Panel de Administración
   ========================================================================== */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: var(--bg-light);
}
.admin-login-card {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.admin-login-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.9rem;
}
.admin-login-footer a {
  color: var(--primary-blue);
}
.admin-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 0;
}
.admin-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.admin-header-inner h1 {
  font-size: 1.5rem;
  color: var(--primary-blue);
  margin-top: 0.35rem;
}
.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.admin-user {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.admin-main {
  padding: 2rem 0 3rem;
}
.admin-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.admin-form-wide {
  max-width: 720px;
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2rem;
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary-blue);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-help {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}
.btn-block {
  width: 100%;
  text-align: center;
}
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}
.btn-danger {
  background: #DC2626;
  color: #fff;
  border: none;
  text-decoration: none;
  display: inline-block;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
}
.btn-danger:hover {
  background: #B91C1C;
  color: #fff;
}
.alert {
  padding: 1rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}
.alert-error {
  background: #FEE2E2;
  color: #991B1B;
  border: 1px solid #FECACA;
}
.alert-success {
  background: #DCFCE7;
  color: #166534;
  border: 1px solid #BBF7D0;
}
.error-list {
  margin-left: 1.25rem;
}
.section-header-left {
  text-align: left;
}
.admin-table-section {
  background: var(--bg-white);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
}
.admin-table-wrapper {
  overflow-x: auto;
}
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.admin-table th,
.admin-table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.admin-table th {
  font-weight: 600;
  color: var(--primary-blue);
  background: #F8FAFC;
}
.admin-thumb {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border-color);
}
.admin-no-image {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.admin-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.status-badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
}
.status-visible {
  background: #DCFCE7;
  color: #166534;
}
.status-oculto {
  background: #F1F5F9;
  color: #64748B;
}
.current-image-preview {
  margin-bottom: 0.75rem;
}
.current-image-preview img {
  max-width: 240px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  display: block;
  margin-bottom: 0.35rem;
}
.current-image-preview p {
  font-size: 0.8rem;
  color: var(--text-muted);
}
.admin-back-link {
  margin-top: 1.5rem;
  font-size: 0.9rem;
}
.admin-back-link a {
  color: var(--primary-blue);
}

@media (max-width: 768px) {
  .form-row { grid-template-columns: 1fr; }
  .admin-header-inner { flex-direction: column; align-items: flex-start; }
  .filter-actions { width: 100%; }
}