/* =========================================================
   CENESTUR INFORMA - SISTEMA DE DISEÑO BASE Y PWA
   Tema Claro, Armonioso y Sin Daño Visual (AGENTCSS)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

/* =========================================================
   1. DESIGN TOKENS / VARIABLES CSS
   ========================================================= */
:root {
  /* Paleta cromática oficial - Modo Claro Institucional */
  --color-bg-base: #f8fafc;
  --color-bg-surface: #ffffff;
  --color-bg-surface-hover: #f1f5f9;
  --color-bg-surface-elevated: #ffffff;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-subtle: rgba(37, 99, 235, 0.08);

  --color-accent: #f59e0b;
  --color-accent-hover: #d97706;
  --color-accent-subtle: rgba(245, 158, 11, 0.08);

  --color-danger: #ef4444;
  --color-danger-subtle: rgba(239, 68, 68, 0.08);

  --color-success: #10b981;
  --color-success-subtle: rgba(16, 185, 129, 0.08);

  --color-border: #e2e8f0;
  --color-border-hover: #cbd5e1;

  /* Jerarquía de texto (WCAG AA) */
  --color-text-main: #0f172a;
  --color-text-secondary: #334155;
  --color-text-muted: #64748b;
  --color-text-dim: #94a3b8;

  /* Tipografías oficiales */
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  --font-title: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
  --font-mono: 'IBM Plex Mono', SFMono-Regular, Menlo, monospace;

  /* Escala de radios */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Sombras suaves y limpias */
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 10px 25px rgba(15, 23, 42, 0.08);
  --shadow-primary: 0 4px 14px rgba(37, 99, 235, 0.15);

  /* Transiciones */
  --transition-fast: 150ms ease;
  --transition-base: 220ms cubic-bezier(0.16, 1, 0.3, 1);

  color-scheme: light;
}

/* =========================================================
   2. RESET Y BASES
   ========================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  background-color: #f8fafc;
  background-image: none;
  color: #0f172a;
  font-family: var(--font-main);
  line-height: 1.5;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* =========================================================
   3. HEADER / NAVBAR GLOBAL
   ========================================================= */
.app-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  position: sticky;
  top: 0;
  /* Debe quedar debajo de los modales Bootstrap y de su fondo oscuro. */
  z-index: 1030 !important;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-img {
  height: 38px;
  width: auto;
  max-width: 240px;
  object-fit: contain;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.btn-header-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid #e2e8f0;
  color: #475569;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn-header-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.home-section-heading {
  font-family: var(--font-title);
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: #0f172a;
}

.home-section-subheading {
  font-size: 0.86rem;
  color: #64748b;
}

.brand-title {
  margin: 0;
  color: #0f172a;
  font-family: var(--font-title);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Botón de Acceso al Panel Administrativo */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-admin:hover {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #0f172a;
}

/* Botón Kebab y Menú Desplegable */
.btn-kebab {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background-color: #f1f5f9;
  color: #334155;
  border: 1px solid #cbd5e1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-kebab:hover, .btn-kebab:focus {
  background-color: #e2e8f0;
  color: #0f172a;
  border-color: #94a3b8;
  outline: none;
}

.menu-kebab-dropdown {
  width: min(300px, calc(100vw - 16px));
  min-width: min(220px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  overflow: hidden;
  border-radius: 12px !important;
  background-color: #ffffff;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.12) !important;
  margin-top: 6px !important;
  z-index: 1040 !important;
}

.menu-kebab-dropdown .dropdown-item {
  font-size: 0.88rem;
  font-weight: 500;
  color: #334155;
  border-radius: 8px;
  padding: 8px 14px;
  margin: 2px 6px;
  width: calc(100% - 12px);
  min-width: 0;
  max-width: calc(100% - 12px);
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.3;
  transition: all var(--transition-fast);
}

.menu-kebab-dropdown .dropdown-item > i {
  flex: 0 0 auto;
}

.menu-kebab-dropdown .dropdown-item > span {
  min-width: 0;
}

.menu-kebab-dropdown .dropdown-item:hover,
.menu-kebab-dropdown .dropdown-item:focus {
  background-color: #f1f5f9;
  color: #0f172a;
}

.menu-kebab-dropdown .dropdown-divider {
  border-color: #f1f5f9;
}

/* =========================================================
   Indicador y Banner de Conexión (Online / Offline)
   ========================================================= */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: all 150ms ease;
  border: 1px solid #e2e8f0;
  background: transparent;
  color: #475569;
  user-select: none;
}

.status-indicator.online {
  background: transparent;
  color: #475569;
  border-color: #e2e8f0;
}

.status-indicator.online .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #10b981;
}

.status-indicator.offline {
  background: transparent;
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
}

.status-indicator.offline .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: #ef4444;
}

.connection-banner {
  width: 100%;
  transition: all 0.3s ease;
  font-weight: 500;
}

.connection-banner.offline {
  background-color: #fef2f2;
  color: #991b1b;
  border-bottom: 1px solid #fecaca;
}

.connection-banner.online {
  background-color: #ecfdf5;
  color: #065f46;
  border-bottom: 1px solid #a7f3d0;
}

/* =========================================================
   4. LAYOUT CONTENEDOR Y VISTAS SPA
   ========================================================= */
main.container {
  max-width: 1040px;
  padding-top: 28px;
  padding-bottom: 70px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fadeIn 0.22s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.view-header h2 {
  margin: 0;
  color: #0f172a;
  font-family: var(--font-title);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* Botón Volver */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-back:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
  transform: translateX(-2px);
}

/* =========================================================
   5. MENÚ PRINCIPAL (CUADRÍCULA 6 ACCESOS - ESTILO LINEAR / STRIPE)
   ========================================================= */
.menu-card {
  height: 100%;
  min-height: 146px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  color: #0f172a;
  padding: 22px 22px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: background-color 150ms ease,
              border-color 150ms ease,
              transform 150ms ease;
  user-select: none;
}

.menu-card:hover {
  background: #f8fafc;
  transform: translateY(-2px);
  border-color: #cbd5e1;
}

.menu-card-body {
  width: 100%;
  margin-top: 14px;
}

.menu-title {
  margin: 0 0 3px 0;
  color: #0f172a;
  font-family: var(--font-title);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.menu-subtitle {
  margin: 0;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.35;
}

/* Iconos limpios y minimalistas sin cuadros de colores saturados detrás */
.menu-icon-box {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0;
  margin-bottom: 0;
  transition: color 150ms ease, transform 150ms ease;
}

.icon-blue   { color: #3b82f6; }
.icon-amber  { color: #d97706; }
.icon-purple { color: #8b5cf6; }
.icon-green  { color: #10b981; }
.icon-gold   { color: #eab308; }
.icon-sky    { color: #0ea5e9; }

.menu-card:hover .menu-icon-box {
  transform: translateX(2px);
}

/* =========================================================
   6. CARDS DE CONTENIDO (ANUNCIOS, EVENTOS, DOCS)
   ========================================================= */
.item-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  transition: transform var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.item-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
  transform: translateY(-2px);
}

.item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #64748b;
}

.item-title {
  margin-bottom: 8px;
  color: #0f172a;
  font-family: var(--font-title);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.item-body {
  margin: 0;
  color: #334155;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-line;
}

/* Botón Marcador / Guardar */
.btn-bookmark {
  background: transparent;
  border: 0;
  color: #94a3b8;
  font-size: 1.25rem;
  cursor: pointer;
  padding: 4px;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.btn-bookmark:hover {
  color: #f59e0b;
  transform: scale(1.15);
}

.btn-bookmark.saved {
  color: #f59e0b;
}

/* =========================================================
   Bloque de Fechas Múltiples (PWA)
   ========================================================= */
.feria-fechas-bloque {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
}

.feria-fecha-item-pwa {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  transition: border-color var(--transition-fast);
}

.feria-fecha-item-pwa:hover {
  border-color: #cbd5e1;
}

/* Galería de Fotos */
.photo-card {
  height: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.photo-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.photo-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.photo-caption {
  padding: 12px 14px;
  background: #ffffff;
}

.photo-caption strong {
  display: block;
  font-size: 0.95rem;
  color: #0f172a;
  margin-bottom: 2px;
}

.photo-caption small {
  color: #64748b;
  font-size: 0.82rem;
}

/* Botón Descarga */
.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-download:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

/* Mensajes de lista vacía */
.empty-msg {
  text-align: center;
  padding: 48px 20px;
  color: #64748b;
  background: #ffffff;
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  margin-top: 12px;
  font-size: 0.95rem;
}

/* =========================================================
   7. SCROLLBARS Y RESPONSIVE
   ========================================================= */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

@media (max-width: 576px) {
  main.container {
    padding-top: 20px;
    padding-left: 14px;
    padding-right: 14px;
  }
  .brand-title {
    font-size: 1.05rem;
  }
  .view-header h2 {
    font-size: 1.25rem;
  }
  .menu-card {
    padding: 20px 12px;
  }
  .menu-icon-box {
    width: 54px;
    height: 54px;
    font-size: 1.5rem;
  }
  .menu-title {
    font-size: 0.95rem;
  }
  .map-responsive-container {
    height: 290px;
  }
}

/* =========================================================
   Mapa Institucional Google Maps
   ========================================================= */
.map-responsive-container {
  position: relative;
  width: 100%;
  height: 380px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  background-color: #f1f5f9;
}

.map-responsive-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* =========================================================
   Banner de Instalación PWA (App)
   ========================================================= */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: #ffffff;
  border-top: 1px solid #e2e8f0;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.08);
  z-index: 1050;
  animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  padding: 14px 0;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}

.install-banner-content {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
}

.install-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  object-fit: contain;
  background: #ffffff;
  padding: 4px;
}

.install-text {
  display: flex;
  flex-direction: column;
}

.install-text strong {
  font-size: 0.95rem;
  color: #0f172a;
  line-height: 1.2;
}

.install-text span {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2px;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* =========================================================
   Tarjeta de Instalación Home (PWA)
   ========================================================= */
.home-install-card {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%) !important;
  border-radius: 14px !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.2) !important;
}

.install-card-icon-box {
  background: rgba(255, 255, 255, 0.2);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
}

.install-card-title {
  color: #ffffff !important;
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.install-card-subtitle {
  color: rgba(255, 255, 255, 0.85) !important;
  font-size: 0.82rem;
}

.install-card-btn {
  background-color: #ffffff !important;
  color: #1d4ed8 !important;
  border: none !important;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.install-card-btn:hover {
  background-color: #f1f5f9 !important;
  color: #1e40af !important;
  transform: translateY(-1px);
}

/* ==============================================================================
   DISEÑO MODO OSCURO PROFESIONAL (ESTILO LINEAR / VERCEL / STRIPE / APPLE)
   - Fondo sólido profundo: #0E1116 (cero degradados radiales de IA)
   - Tarjetas sutiles: #171A21 con borde fino 1px #262B36 (cero neón)
   - Iconos limpios sin cajas de colores detrás
   - Texto: Blanco roto #F3F4F6 para títulos y Gris #9CA3AF para subtítulos
   ============================================================================== */
[data-theme="dark"] {
  --color-bg-base: #0E1116;
  --color-bg-surface: #171A21;
  --color-bg-surface-hover: #1E222B;
  --color-bg-surface-elevated: #171A21;

  --color-primary: #3b82f6;
  --color-primary-hover: #60a5fa;
  --color-primary-subtle: rgba(59, 130, 246, 0.12);

  --color-border: #262B36;
  --color-border-hover: #363D4D;

  --color-text-main: #F3F4F6;
  --color-text-secondary: #D1D5DB;
  --color-text-muted: #9CA3AF;
  --color-text-dim: #6B7280;

  color-scheme: dark;
}

/* 1. Fondo Sólido Profundo (#0E1116) sin degradados radiales */
[data-theme="dark"] body {
  background-color: #0E1116 !important;
  background-image: none !important;
  color: #F3F4F6 !important;
}

/* 2. Barra Superior (Header) sobria y limpia */
[data-theme="dark"] .app-header {
  background: rgba(14, 17, 22, 0.88) !important;
  border-bottom: 1px solid #262B36 !important;
  box-shadow: none !important;
}

/* Logo CENESTUR en blanco/gris claro monocromo para no competir con la UI */
[data-theme="dark"] .brand-logo-img {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  filter: brightness(0) invert(0.92);
  opacity: 0.95;
}

/* Etiqueta "ESTUDIANTES" sobria con borde sutil sin morado brillante */
[data-theme="dark"] .brand-badge {
  background: #171A21 !important;
  color: #9CA3AF !important;
  border: 1px solid #262B36 !important;
  box-shadow: none !important;
}

/* Botones secundarios en el Header ("¿Cómo funciona?" y "Online") */
[data-theme="dark"] .btn-header-secondary {
  background: transparent !important;
  border: 1px solid #262B36 !important;
  color: #D1D5DB !important;
}

[data-theme="dark"] .btn-header-secondary:hover {
  background: #171A21 !important;
  border-color: #363D4D !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .status-indicator,
[data-theme="dark"] .status-indicator.online {
  background: transparent !important;
  border: 1px solid #262B36 !important;
  color: #D1D5DB !important;
}

[data-theme="dark"] .status-indicator.online .status-dot {
  background-color: #10b981 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .status-indicator.offline {
  background: transparent !important;
  border: 1px solid rgba(239, 68, 68, 0.4) !important;
  color: #F87171 !important;
}

/* Botón Kebab y menú desplegable */
[data-theme="dark"] .btn-kebab {
  background-color: transparent !important;
  border: 1px solid #262B36 !important;
  color: #D1D5DB !important;
  box-shadow: none !important;
}

[data-theme="dark"] .btn-kebab:hover,
[data-theme="dark"] .btn-kebab:focus {
  background-color: #171A21 !important;
  border-color: #363D4D !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .menu-kebab-dropdown {
  background-color: #171A21 !important;
  border: 1px solid #262B36 !important;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55) !important;
}

[data-theme="dark"] .menu-kebab-dropdown .dropdown-item {
  color: #D1D5DB !important;
}

[data-theme="dark"] .menu-kebab-dropdown .dropdown-item:hover,
[data-theme="dark"] .menu-kebab-dropdown .dropdown-item:focus {
  background-color: #202530 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .menu-kebab-dropdown .dropdown-divider {
  border-color: #262B36 !important;
}

/* 3. Jerarquía Tipográfica en el Home */
[data-theme="dark"] .home-section-heading,
[data-theme="dark"] .view-header h2 {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .home-section-subheading {
  color: #9CA3AF !important;
}

[data-theme="dark"] .view-header {
  border-bottom-color: #262B36 !important;
}

/* 4. Tarjetas del Menú Principal (#171A21 y borde #262B36 sin brillos ni neón) */
[data-theme="dark"] .menu-card {
  background: #171A21 !important;
  border: 1px solid #262B36 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .menu-card:hover {
  background: #1D212A !important;
  border-color: #384050 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .menu-title {
  color: #F3F4F6 !important;
  font-weight: 600 !important;
}

[data-theme="dark"] .menu-subtitle {
  color: #9CA3AF !important;
}

/* Iconos limpios y desaturados sin cuadros de fondo */
[data-theme="dark"] .menu-icon-box {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

[data-theme="dark"] .icon-blue   { color: #93C5FD !important; }
[data-theme="dark"] .icon-amber  { color: #FCD34D !important; }
[data-theme="dark"] .icon-purple { color: #C4B5FD !important; }
[data-theme="dark"] .icon-green  { color: #6EE7B7 !important; }
[data-theme="dark"] .icon-gold   { color: #FDE047 !important; }
[data-theme="dark"] .icon-sky    { color: #7DD3FC !important; }

[data-theme="dark"] .menu-card:hover .menu-icon-box {
  color: #F3F4F6 !important;
}

/* 5. Tarjetas de Contenido Interno (Comunicados, Eventos, Documentos, Institucional) */
[data-theme="dark"] .item-card {
  background: #171A21 !important;
  border: 1px solid #262B36 !important;
  box-shadow: none !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .item-card:hover {
  background: #1B1F27 !important;
  border-color: #363D4D !important;
  box-shadow: none !important;
}

[data-theme="dark"] .item-title {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .item-meta {
  color: #9CA3AF !important;
}

[data-theme="dark"] .item-body {
  color: #D1D5DB !important;
}

/* Tarjeta de Instalación Home sobria (sin azul eléctrico saturado) */
.home-install-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  color: #0f172a !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03) !important;
}

.install-card-icon-box {
  background: #f1f5f9 !important;
  color: #334155 !important;
  border: 1px solid #e2e8f0;
}

.install-card-title {
  color: #0f172a !important;
}

.install-card-subtitle {
  color: #64748b !important;
}

.install-card-btn {
  background-color: #0f172a !important;
  color: #ffffff !important;
}

[data-theme="dark"] .home-install-card {
  background: #171A21 !important;
  border: 1px solid #262B36 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .install-card-icon-box {
  background: #202530 !important;
  border-color: #2E3442 !important;
  color: #E5E7EB !important;
}

[data-theme="dark"] .install-card-title {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .install-card-subtitle {
  color: #9CA3AF !important;
}

[data-theme="dark"] .install-card-btn {
  background-color: #F3F4F6 !important;
  color: #0E1116 !important;
}

/* Botones de navegación e interfaz */
[data-theme="dark"] .btn-back {
  background-color: #171A21 !important;
  border-color: #262B36 !important;
  color: #D1D5DB !important;
}

[data-theme="dark"] .btn-back:hover {
  background-color: #202530 !important;
  border-color: #363D4D !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .btn-download {
  background: #202530 !important;
  border: 1px solid #2E3442 !important;
  color: #E5E7EB !important;
}

[data-theme="dark"] .btn-download:hover {
  background: #2B3140 !important;
  border-color: #3E4759 !important;
  color: #FFFFFF !important;
}

/* Galería de Fotos */
.photo-card-clickable {
  cursor: pointer;
  position: relative;
}

.photo-thumb-wrapper {
  position: relative;
  overflow: hidden;
}

.photo-card-clickable img {
  transition: transform 0.3s ease;
}

.photo-card-clickable:hover img {
  transform: scale(1.04);
}

.photo-zoom-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(14, 17, 22, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #F3F4F6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.2s ease;
}

[data-theme="dark"] .photo-card {
  background-color: #171A21 !important;
  border: 1px solid #262B36 !important;
  box-shadow: none !important;
}

[data-theme="dark"] .photo-caption {
  background-color: #171A21 !important;
  border-top: 1px solid #262B36 !important;
}

[data-theme="dark"] .photo-caption strong {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .photo-caption small {
  color: #9CA3AF !important;
}

/* Cronograma de eventos y estados vacíos */
[data-theme="dark"] .feria-fechas-bloque {
  background: #0E1116 !important;
  border-color: #262B36 !important;
}

[data-theme="dark"] .feria-fecha-item-pwa {
  background: #171A21 !important;
  border-color: #262B36 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .empty-msg {
  background: #171A21 !important;
  border: 1px dashed #262B36 !important;
  color: #9CA3AF !important;
}

/* Adaptación de clases utilitarias y formularios */
[data-theme="dark"] .login-card {
  background-color: #171A21 !important;
  border: 1px solid #262B36 !important;
  box-shadow: none !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .form-control {
  background-color: #0E1116 !important;
  border-color: #262B36 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .form-control:focus {
  background-color: #0E1116 !important;
  color: #F3F4F6 !important;
  border-color: #4B5563 !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .input-group-text {
  background-color: #171A21 !important;
  border-color: #262B36 !important;
  color: #9CA3AF !important;
}

[data-theme="dark"] .google-btn {
  background-color: #171A21 !important;
  border-color: #262B36 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .google-btn:hover {
  background-color: #202530 !important;
  border-color: #363D4D !important;
}

[data-theme="dark"] .text-dark {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary {
  color: #9CA3AF !important;
}

[data-theme="dark"] .border-top,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border,
[data-theme="dark"] .border-light-subtle {
  border-color: #262B36 !important;
}

[data-theme="dark"] .bg-light,
[data-theme="dark"] .bg-light-subtle {
  background-color: #0E1116 !important;
  color: #D1D5DB !important;
}

[data-theme="dark"] .bg-white {
  background-color: #171A21 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .btn-light {
  background-color: #202530 !important;
  border-color: #2E3442 !important;
  color: #E5E7EB !important;
}

[data-theme="dark"] .btn-light:hover {
  background-color: #2A303D !important;
  color: #FFFFFF !important;
}

[data-theme="dark"] .bg-primary-subtle,
[data-theme="dark"] .bg-success-subtle,
[data-theme="dark"] .bg-warning-subtle,
[data-theme="dark"] .bg-info-subtle,
[data-theme="dark"] .bg-secondary-subtle {
  background-color: #202530 !important;
  color: #D1D5DB !important;
  border-color: #2E3442 !important;
}

/* ==============================================================================
   OPTIMIZACIÓN PARA DISPOSITIVOS APPLE (iOS / iPadOS / macOS Safari) Y MODALES
   ============================================================================== */
.app-header {
  padding-top: env(safe-area-inset-top, 0px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
}

body {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

.install-banner {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

@supports (-webkit-touch-callout: none) {
  input, select, textarea {
    font-size: 16px !important;
  }
}

.apple-step-card,
.how-it-works-step {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
}

.apple-step-badge {
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 8px;
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
}

.how-it-works-icon {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

/* Guía adaptable: el encabezado queda fijo y solo el contenido interno desplaza. */
#modal-how-it-works .modal-dialog {
  width: auto;
}

#modal-how-it-works .modal-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow: hidden !important;
}

#modal-how-it-works .modal-header {
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 12px;
}

#modal-how-it-works .modal-header > .d-flex,
#modal-how-it-works .modal-header > .d-flex > div:last-child,
#modal-how-it-works .how-it-works-step > div:last-child {
  min-width: 0;
}

#modal-how-it-works .modal-header > .d-flex {
  flex: 1 1 auto;
  overflow: hidden;
}

#modal-how-it-works .modal-content,
#modal-how-it-works .modal-body > .row,
#modal-how-it-works .modal-body > .row > * {
  min-width: 0;
  max-width: 100%;
}

#modal-how-it-works .modal-title,
#modal-how-it-works .modal-header small,
#modal-how-it-works .how-it-works-step span {
  overflow-wrap: anywhere;
}

#modal-how-it-works .modal-body {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#modal-how-it-works .btn-close {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  padding: 0.75rem;
  margin: -0.5rem -0.5rem 0 auto;
  position: relative;
  z-index: 2;
}

@media (max-width: 575.98px) {
  .app-header .container {
    max-width: 100%;
    padding-left: 10px;
    padding-right: 10px;
    gap: 8px;
  }

  .app-header .brand {
    min-width: 0;
    flex: 1 1 auto;
    gap: 6px;
  }

  .brand-logo-img {
    width: auto;
    height: 32px;
    max-width: clamp(112px, 35vw, 150px);
  }

  .brand-badge {
    padding: 2px 5px;
    font-size: 0.58rem;
    letter-spacing: 0.025em;
    white-space: nowrap;
  }

  .app-header .container > .d-flex:last-child {
    flex: 0 0 auto;
    gap: 6px !important;
  }

  .status-indicator {
    gap: 5px;
    padding: 5px 8px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  #modal-how-it-works {
    padding: 0 !important;
  }

  #modal-how-it-works .modal-dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    min-height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    margin: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  #modal-how-it-works .modal-content {
    width: 100%;
    max-height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    border-radius: 14px !important;
  }

  #modal-how-it-works .modal-header {
    padding: 14px 14px 8px !important;
  }

  #modal-how-it-works .modal-header img {
    width: 32px !important;
    height: 32px !important;
  }

  #modal-how-it-works .modal-title {
    font-size: 1rem;
    line-height: 1.25;
  }

  #modal-how-it-works .modal-header small {
    display: block;
    margin-top: 2px;
    font-size: 0.74rem;
    line-height: 1.3;
  }

  #modal-how-it-works .modal-body {
    padding: 10px 14px 14px !important;
  }

  #modal-how-it-works .modal-body > .row {
    --bs-gutter-y: 0.65rem;
  }

  #modal-how-it-works .how-it-works-step {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    gap: 10px;
    padding: 11px;
    border-radius: 10px;
  }

  #modal-how-it-works .how-it-works-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 1rem;
  }

  #modal-how-it-works .how-it-works-step strong {
    font-size: 0.88rem;
    line-height: 1.3;
  }

  #modal-how-it-works .how-it-works-step span {
    display: block;
    font-size: 0.8rem;
    line-height: 1.42;
  }

  #modal-how-it-works .modal-body > .border-top {
    flex-direction: column;
    align-items: stretch !important;
    margin-top: 12px !important;
    padding-top: 12px !important;
  }

  #modal-how-it-works .modal-body > .border-top .d-flex,
  #modal-how-it-works .modal-body > .border-top .btn {
    width: 100%;
  }

  #modal-how-it-works .modal-body > .border-top .btn {
    min-height: 42px;
    white-space: normal;
  }
}

@media (max-width: 389.98px) {
  .app-header .brand-badge {
    display: none;
  }

  .brand-logo-img {
    max-width: 150px;
  }
}

@media (max-width: 339.98px) {
  .status-indicator {
    width: 34px;
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
  }

  .status-indicator .status-text {
    display: none;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  #modal-how-it-works .modal-dialog {
    align-items: flex-start;
  }

  #modal-how-it-works .modal-header {
    padding-top: 10px !important;
  }

  #modal-how-it-works .modal-header small {
    display: none;
  }
}

.tour-active-highlight {
  position: relative;
  z-index: 20 !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px #3b82f6 !important;
  outline: 3px solid #3b82f6 !important;
  outline-offset: 3px;
}

/* El borde normal del modo oscuro usa !important y tiene mayor especificidad.
   Esta regla conserva un contorno luminoso y claramente visible durante la guía. */
[data-theme="dark"] .menu-card.tour-active-highlight {
  background-color: #1b2431 !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.4),
              0 0 22px rgba(59, 130, 246, 0.42) !important;
  outline-color: #93c5fd !important;
}

.tour-floating-bar {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 460px);
  background: #171A21;
  color: #F3F4F6;
  border-radius: 14px;
  padding: 16px 18px;
  z-index: 1070;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid #262B36;
}

[data-theme="dark"] #modal-notification-prompt .modal-content,
[data-theme="dark"] #modal-apple-install .modal-content,
[data-theme="dark"] #modal-how-it-works .modal-content,
[data-theme="dark"] .swal2-popup {
  background-color: #171A21 !important;
  color: #F3F4F6 !important;
  border: 1px solid #262B36 !important;
}

[data-theme="dark"] .apple-step-card,
[data-theme="dark"] .how-it-works-step {
  background-color: #0E1116 !important;
  border-color: #262B36 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .modal-content .btn-close:not(.btn-close-white) {
  filter: invert(1) grayscale(100%) brightness(200%);
}

[data-theme="dark"] .install-banner {
  background-color: #171A21 !important;
  border-top: 1px solid #262B36 !important;
}

[data-theme="dark"] .install-text strong {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .install-text span {
  color: #9CA3AF !important;
}

/* Banner Flotante de Actualización de la Aplicación (Estilo Linear) */
.app-update-toast {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: min(94%, 460px);
  background: #171A21;
  color: #F3F4F6;
  border: 1px solid #262B36;
  border-radius: 12px;
  padding: 12px 16px;
  z-index: 1085;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  animation: updateToastIn 0.25s ease-out;
}

.update-toast-icon {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 8px;
  background: #202530;
  border: 1px solid #2E3442;
  color: #93C5FD;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
}

@keyframes updateToastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 16px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
