/* =======================================================
   📱 Mobile Components - EncuentraIglesias
   Modales, Bottom Sheets y Carruseles optimizados para móvil
======================================================== */

/* =======================================================
   🎯 MODAL FULLSCREEN - Para Estados
======================================================== */
.ei-modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ei-modal-overlay.active {
  display: block;
  opacity: 1;
}

.ei-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ei-modal.active {
  display: flex;
  transform: translateY(0);
}

/* Header del modal */
.ei-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
  flex-shrink: 0;
}

.ei-modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.ei-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #6b7280;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.2s;
}

.ei-modal-close:hover,
.ei-modal-close:focus {
  color: #1f2937;
}

/* Buscador dentro del modal */
.ei-modal-search {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}

.ei-modal-search input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.ei-modal-search input:focus {
  outline: none;
  border-color: #f7b500;
  box-shadow: 0 0 0 3px rgba(247, 181, 0, 0.1);
}

/* Contenido scrollable */
.ei-modal-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0;
}

/* Items del listado */
.ei-modal-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  color: #1f2937;
  transition: background-color 0.15s;
}

.ei-modal-item:hover,
.ei-modal-item:active {
  background-color: #f9fafb;
}

.ei-modal-item-text {
  flex: 1;
  font-size: 1rem;
  font-weight: 500;
}

.ei-modal-item-count {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 600;
  background: #f3f4f6;
  padding: 4px 10px;
  border-radius: 12px;
}

.ei-modal-item-icon {
  margin-right: 8px;
  font-size: 1.25rem;
  color: #f7b500;
}

/* =======================================================
   📋 BOTTOM SHEET - Para Denominaciones
======================================================== */
.ei-bottom-sheet {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}

.ei-bottom-sheet.active {
  display: flex;
  transform: translateY(0);
}

/* Handle visual para indicar que se puede arrastrar */
.ei-bottom-sheet-handle {
  width: 40px;
  height: 4px;
  background: #d1d5db;
  border-radius: 2px;
  margin: 12px auto 8px;
  flex-shrink: 0;
}

.ei-bottom-sheet-header {
  padding: 8px 20px 16px;
  text-align: center;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ei-bottom-sheet-back {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  color: #1f2937;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.ei-bottom-sheet-back:hover,
.ei-bottom-sheet-back:active {
  color: #f7b500;
}

.ei-bottom-sheet-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
  margin: 0;
}

.ei-bottom-sheet-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
}

/* Grid de denominaciones dentro del bottom sheet */
.ei-bottom-sheet-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.ei-bottom-sheet-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 16px 12px;
  background: #f9fafb;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  text-decoration: none;
  color: #1f2937;
  transition: all 0.2s;
}

.ei-bottom-sheet-item:hover,
.ei-bottom-sheet-item:active {
  background: #fff;
  border-color: #f7b500;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
}

.ei-bottom-sheet-item-icon {
  font-size: 2rem;
  color: #f7b500;
  margin-bottom: 8px;
}

.ei-bottom-sheet-item-name {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.ei-bottom-sheet-item-count {
  font-size: 0.75rem;
  color: #6b7280;
}

/* =======================================================
   🎠 CARRUSEL - Para Iglesias Destacadas
======================================================== */
.ei-carousel-container {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.ei-carousel {
  position: relative;
  overflow-x: clip;
  overflow-y: visible;
  min-height: 480px;
  padding: 10px 0 0; /* Indicators placed outside by JS */
  touch-action: auto; /* Let vertical scroll pass through to page */
}

.ei-carousel .ei-carousel-item {
  position: absolute;
  width: 80%;
  max-width: 340px;
  left: 50%;
  top: 10px;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transform-style: preserve-3d;
}

.ei-carousel .ei-carousel-item .featured-card-link,
.ei-carousel .ei-carousel-item .denomination_card {
  width: 100%;
  height: 100%;
}

/* Golden border on active/center card */
.ei-carousel .ei-carousel-item.active .featured-card,
.ei-carousel .ei-carousel-item.active .denomination_card {
  border: 2px solid #f7c948;
  background: radial-gradient(circle at center, #fffdf5 0%, #ffffff 70%);
  box-shadow:
    0 10px 24px rgba(218, 165, 32, 0.25),
    0 0 20px rgba(247, 201, 72, 0.25);
}

.ei-carousel::-webkit-scrollbar {
  display: none; /* Chrome, Safari */
}

.ei-carousel-item {
  flex: 0 0 85%;
  scroll-snap-align: center;
  scroll-snap-stop: always;
}

/* Flechas de navegación sutiles (solo en mobile) */
.ei-carousel-nav {
  position: absolute;
  top: 60%; /* Movido más abajo */
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5e7eb;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.2s;
  opacity: 0.8;
}

.ei-carousel-nav:active {
  transform: translateY(-50%) scale(0.95);
  opacity: 1;
}

.ei-carousel-nav-prev {
  left: 8px;
}

.ei-carousel-nav-next {
  right: 8px;
}

.ei-carousel-nav i {
  color: #1f2937;
  font-size: 1rem;
}

/* Indicadores (dots) del carrusel */
.ei-carousel-indicators {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  padding-bottom: 8px;
  position: relative;
  z-index: 20;
}

/* Contador de posición */
.ei-carousel-counter {
  font-size: 0.95rem;
  color: #4b5563;
  font-weight: 700;
  margin-left: 12px;
  user-select: none;
}

.ei-carousel-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d1d5db;
  border: none;
  padding: 0;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ei-carousel-indicator.active {
  background: #f7b500;
  width: 24px;
  border-radius: 4px;
  transform: scale(1.1);
}

/* Botón CTA "Ver todas" al final del carrusel */
.ei-carousel-cta {
  flex: 0 0 85%;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 280px;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  border: 2px dashed #d1d5db;
  border-radius: 16px;
  padding: 32px 20px;
  text-align: center;
}

.ei-carousel-cta-content {
  max-width: 200px;
}

.ei-carousel-cta h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1f2937;
  margin-bottom: 8px;
}

.ei-carousel-cta p {
  font-size: 0.875rem;
  color: #6b7280;
  margin-bottom: 16px;
}

.ei-carousel-cta .btn {
  display: inline-block;
  padding: 10px 20px;
  background: #f7b500;
  color: #1f2937;
  border-radius: 8px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.2s;
}

.ei-carousel-cta .btn:active {
  transform: scale(0.95);
}

/* =======================================================
   🔘 BOTONES TRIGGER - Para abrir modales en móvil
======================================================== */
.ei-mobile-trigger {
  display: none; /* Oculto por defecto */
  width: 100%;
  padding: 14px 20px;
  background: var(--gold, #f7b500);
  color: #1f2430;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 8px 18px rgba(217, 160, 40, 0.25);
  text-align: center;
  position: relative;
}

.ei-mobile-trigger:hover,
.ei-mobile-trigger:active {
  filter: brightness(1.05);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(217, 160, 40, 0.3);
}

.ei-mobile-trigger-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
  transition: transform 0.2s;
}

.ei-mobile-trigger:active .ei-mobile-trigger-icon {
  transform: translateY(-50%) scale(0.9);
}

/* =======================================================
   📱 MEDIA QUERIES - Mostrar en móvil
======================================================== */
@media (max-width: 768px) {
  /* Mostrar botones trigger solo en móvil */
  .ei-mobile-trigger {
    display: block;
  }

  /* Ocultar grids originales en móvil */
  body.is-mobile .states_grid,
  body.is-mobile .denominations_grid {
    display: none !important;
  }

  /* Mostrar carrusel solo en móvil */
  body.is-mobile .denominations_grid.ei-carousel {
    display: flex !important;
  }
  
  /* Ajustar altura del carrusel para destacadas */
  .ei-carousel-item .denomination_card,
  .ei-carousel-item .church-card {
    height: 100%;
  }
  
  /* 📦 COMPACTAR SECCIÓN FEATURED CHURCHES EN MÓVIL */
  
  /* Título más compacto */
  body.is-mobile #featured-title {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }
  
  /* Descripción más corta */
  body.is-mobile .section_title p {
    font-size: 0.875rem;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  
  /* Selector más compacto */
  body.is-mobile .featured-country-selector {
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
  }
  
  body.is-mobile .featured-country-selector label {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
  }
  
  /* Ocultar "Location detected" si coincide con selección */
  body.is-mobile #country-detected.match-selected {
    display: none;
  }
  
  body.is-mobile #country-detected {
    font-size: 0.8rem;
    margin-top: 0.25rem;
  }
  
  /* Reducir espacio entre selector y carrusel */
  body.is-mobile .section_title {
    margin-bottom: 1rem;
  }
  
  /* Fijar altura de cards en carrusel para evitar corte */
  body.is-mobile .ei-carousel-item .denomination_card.featured-card {
    display: flex;
    flex-direction: column;
    min-height: 280px;
    margin-top: 0;
  }
  
  /* Asegurar que el contenido no se corte */
  body.is-mobile .ei-carousel-item .featured-card h3 {
    margin-top: 0;
    padding-top: 0;
  }
  
  /* Agregar espacio adicional al contenedor del carrusel */
  body.is-mobile .ei-carousel-container {
    padding-top: 8px;
  }
}

/* =======================================================
   🖥️ DESKTOP - Mantener diseño original
======================================================== */
@media (min-width: 769px) {
  .ei-modal,
  .ei-bottom-sheet,
  .ei-modal-overlay {
    display: none !important;
  }
  
  .ei-carousel-indicators,
  .ei-carousel-nav {
    display: none !important;
  }
}

/* =======================================================
   ♿ ACCESIBILIDAD
======================================================== */
.ei-modal-close:focus,
.ei-bottom-sheet-item:focus,
.ei-modal-item:focus,
.ei-mobile-trigger:focus {
  outline: 2px solid #f7b500;
  outline-offset: 2px;
}

/* Animaciones */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Mensaje cuando no hay resultados */
.ei-modal-empty {
  padding: 40px 20px;
  text-align: center;
  color: #6b7280;
}

.ei-modal-empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.ei-modal-empty-text {
  font-size: 1rem;
  line-height: 1.5;
}
