/* =======================================================
   🎨 SEARCH AUTOCOMPLETE STYLES
   Estilos para el dropdown de sugerencias tipo Google
   ======================================================= */

/* Contenedor principal del autocomplete */
.ei-autocomplete-wrapper {
  position: relative;
  display: inline-block;
  width: 100%;
  max-width: 100%;
}

/* Fix para formularios */
form .ei-autocomplete-wrapper {
  display: inline-flex;
  flex: 1;
  width: auto;
}

/* Dropdown de sugerencias */
.ei-autocomplete-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  z-index: 999999999 !important;
  max-height: 480px;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  min-width: 320px;
  width: 100%;
}

/* Ajustes para home.php - móvil: más compacto */
@media (max-width: 768px) {
  .hero .ei-autocomplete-dropdown {
    max-height: 280px !important;
    max-width: calc(100vw - 32px) !important;
    left: 16px !important;
    right: 16px !important;
    width: auto !important;
    min-width: 0 !important;
  }
  
  .hero .ei-autocomplete-item {
    padding: 8px 12px !important;
    gap: 8px !important;
  }
  
  .hero .ei-autocomplete-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 0.8rem !important;
  }
  
  .hero .ei-autocomplete-text {
    font-size: 0.85rem !important;
  }
  
  .hero .ei-autocomplete-subtitle {
    font-size: 0.75rem !important;
  }
  
  .hero .ei-autocomplete-section-title {
    padding: 6px 12px 4px !important;
    font-size: 0.7rem !important;
  }
}

.ei-autocomplete-dropdown.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Scrollbar personalizado */
.ei-autocomplete-dropdown::-webkit-scrollbar {
  width: 8px;
}

.ei-autocomplete-dropdown::-webkit-scrollbar-track {
  background: #f1f3f5;
  border-radius: 0 12px 12px 0;
}

.ei-autocomplete-dropdown::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

.ei-autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* Sección del dropdown */
.ei-autocomplete-section {
  padding: 8px 0;
  border-bottom: 1px solid #e5e7eb;
}

.ei-autocomplete-section:last-child {
  border-bottom: none;
}

/* Título de sección */
.ei-autocomplete-section-title {
  padding: 8px 16px 6px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #002b5c;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ei-autocomplete-section-title i {
  font-size: 0.8rem;
  color: #002b5c;
}

/* Item de sugerencia */
.ei-autocomplete-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  color: inherit;
  gap: 12px;
  border-radius: 8px;
  margin: 0 8px;
}

.ei-autocomplete-item:hover,
.ei-autocomplete-item.active {
  background: #eef6ff;
  transform: translateX(2px);
}

.ei-autocomplete-item.active {
  background: #dbeafe;
}

/* Icono de sugerencia */
.ei-autocomplete-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f9fc;
  border-radius: 8px;
  color: #4b5563;
  font-size: 0.95rem;
}

.ei-autocomplete-item:hover .ei-autocomplete-icon,
.ei-autocomplete-item.active .ei-autocomplete-icon {
  background: #e5e9f0;
  color: #153b73;
}

/* Texto de sugerencia */
.ei-autocomplete-content {
  flex: 1;
  min-width: 0;
}

.ei-autocomplete-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: #1f2937;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ei-autocomplete-subtitle {
  font-size: 0.82rem;
  color: #6b7280;
  line-height: 1.3;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge de tipo (opcional) */
.ei-autocomplete-badge {
  flex-shrink: 0;
  padding: 4px 8px;
  background: #f3f4f6;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Mensaje de "sin resultados" */
.ei-autocomplete-empty {
  padding: 24px 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.9rem;
}

.ei-autocomplete-empty i {
  display: block;
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.4;
}

/* Loading state */
.ei-autocomplete-loading {
  padding: 20px 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.9rem;
}

.ei-autocomplete-loading i {
  display: inline-block;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Footer del dropdown (opcional) */
.ei-autocomplete-footer {
  padding: 10px 16px;
  background: #f9fafb;
  border-top: 1px solid #e5e7eb;
  font-size: 0.75rem;
  color: #9ca3af;
  text-align: center;
  border-radius: 0 0 12px 12px;
}

/* Highlight de texto coincidente */
.ei-autocomplete-highlight {
  font-weight: 600;
  color: #153b73;
}

/* Responsive: móvil */
@media (max-width: 768px) {
  .ei-autocomplete-wrapper {
    width: 100%;
    max-width: 100%;
  }

  .ei-autocomplete-dropdown {
    position: absolute !important;
    top: calc(100% + 4px) !important;
    left: -20% !important;
    right: auto !important;
    bottom: auto !important;
    max-height: 40vh;
    border-radius: 16px;
    min-width: unset;
    width: 170%;
    margin-top: 0;
    transform: none;
  }

  .ei-autocomplete-item {
    padding: 14px 16px;
  }

  .ei-autocomplete-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }

  .ei-autocomplete-text {
    font-size: 1rem;
  }

  .ei-autocomplete-subtitle {
    font-size: 0.85rem;
  }

  /* Fix para formularios en móvil */
  form .ei-autocomplete-wrapper {
    width: 100%;
    max-width: 100%;
  }
}

/* Animación para items */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.ei-autocomplete-item {
  animation: slideIn 0.2s ease;
}

/* Diferentes estilos según el tipo */
.ei-autocomplete-item[data-type="state"] .ei-autocomplete-icon {
  background: #eff6ff;
  color: #2563eb;
}

.ei-autocomplete-item[data-type="city"] .ei-autocomplete-icon {
  background: #fef3c7;
  color: #d97706;
}

.ei-autocomplete-item[data-type="denomination"] .ei-autocomplete-icon {
  background: #f3e8ff;
  color: #7c3aed;
}

.ei-autocomplete-item[data-type="church"] .ei-autocomplete-icon {
  background: #ecfdf5;
  color: #059669;
}

.ei-autocomplete-item[data-type="recent"] .ei-autocomplete-icon {
  background: #f1f5f9;
  color: #64748b;
}

/* Hover states mejorados */
.ei-autocomplete-item[data-type="state"]:hover .ei-autocomplete-icon {
  background: #dbeafe;
}

.ei-autocomplete-item[data-type="city"]:hover .ei-autocomplete-icon {
  background: #fde68a;
}

.ei-autocomplete-item[data-type="denomination"]:hover .ei-autocomplete-icon {
  background: #e9d5ff;
}

.ei-autocomplete-item[data-type="church"]:hover .ei-autocomplete-icon {
  background: #d1fae5;
}

.ei-autocomplete-item[data-type="recent"]:hover .ei-autocomplete-icon {
  background: #e2e8f0;
}

/* Botón de limpiar historial */
.ei-autocomplete-clear-history {
  background: none;
  border: 1px solid #cbd5e0;
  color: #64748b;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 8px;
  margin: 8px 12px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ei-autocomplete-clear-history:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #475569;
}

.ei-autocomplete-clear-history i {
  font-size: 0.7rem;
}

/* Accesibilidad: focus visible */
.ei-autocomplete-item:focus-visible {
  outline: 2px solid #f7c948;
  outline-offset: -2px;
}

/* Dark mode support (opcional) */
/* Force light theme always — ignore browser dark mode */
.ei-autocomplete-dropdown,
.ei-autocomplete-wrapper {
  color-scheme: light;
}
