/* ========================================
   ESTILOS PARA COMPONENTES GEOGRÁFICOS
   ======================================== */

/* TEMA CLARO - Para panel izquierdo con fondo blanco */
.geografico-component.light-theme {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
  color: #1e293b !important;
}

.geografico-component.light-theme select {
  background-color: #ffffff !important;
  color: #1e293b !important;
  border-color: #d1d5db !important;
}

.geografico-component.light-theme select:focus {
  border-color: #06b6d4 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1) !important;
}

.geografico-component.light-theme select[data-selected="True"] {
  border-color: #06b6d4 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1) !important;
  background-color: #f1f5f9 !important;
}

.geografico-component.light-theme select option {
  background-color: #ffffff !important;
  color: #1e293b !important;
}

.geografico-component.light-theme .distrito-option,
.geografico-component.light-theme .municipio-option,
.geografico-component.light-theme .seccion-option {
  background-color: #ffffff !important;
  border-color: #e5e7eb !important;
  color: #374151 !important;
}

.geografico-component.light-theme .distrito-option:hover,
.geografico-component.light-theme .municipio-option:hover,
.geografico-component.light-theme .seccion-option:hover {
  background-color: #f9fafb !important;
  border-color: #d1d5db !important;
}

.geografico-component.light-theme .distrito-option.selected,
.geografico-component.light-theme .municipio-option.selected,
.geografico-component.light-theme .seccion-option.selected {
  background-color: #f3f4f6 !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

.geografico-component.light-theme .distrito-checkbox,
.geografico-component.light-theme .municipio-checkbox,
.geografico-component.light-theme .seccion-checkbox {
  background-color: #ffffff !important;
  border-color: #d1d5db !important;
}

.geografico-component.light-theme .distrito-option.selected .distrito-checkbox,
.geografico-component.light-theme
  .municipio-option.selected
  .municipio-checkbox,
.geografico-component.light-theme .seccion-option.selected .seccion-checkbox {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
}

.geografico-component.light-theme .distrito-name,
.geografico-component.light-theme .municipio-name,
.geografico-component.light-theme .seccion-name {
  color: #374151 !important;
}

/* Estilos para textos en tema claro */
.geografico-component.light-theme h3,
.geografico-component.light-theme h4,
.geografico-component.light-theme p,
.geografico-component.light-theme span,
.geografico-component.light-theme label {
  color: #1e293b !important;
}

.geografico-component.light-theme .text-cyan-400 {
  color: #0891b2 !important;
}

/* TEMA OSCURO - Para componentes con fondo slate-900 */
.geografico-component.dark-theme {
  background-color: #0f172a !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

.geografico-component.dark-theme select {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
  border-color: #475569 !important;
}

.geografico-component.dark-theme select:focus {
  border-color: #06b6d4 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1) !important;
}

.geografico-component.dark-theme select[data-selected="True"] {
  border-color: #06b6d4 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1) !important;
  background-color: #334155 !important;
}

.geografico-component.dark-theme select option {
  background-color: #1e293b !important;
  color: #f1f5f9 !important;
}

.geografico-component.dark-theme .distrito-option,
.geografico-component.dark-theme .municipio-option,
.geografico-component.dark-theme .seccion-option {
  background-color: #1e293b !important;
  border-color: #475569 !important;
  color: #f1f5f9 !important;
}

.geografico-component.dark-theme .distrito-option:hover,
.geografico-component.dark-theme .municipio-option:hover,
.geografico-component.dark-theme .seccion-option:hover {
  background-color: #334155 !important;
  border-color: #64748b !important;
}

.geografico-component.dark-theme .distrito-option.selected,
.geografico-component.dark-theme .municipio-option.selected,
.geografico-component.dark-theme .seccion-option.selected {
  background-color: #475569 !important;
  border-color: #06b6d4 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2) !important;
}

.geografico-component.dark-theme .distrito-checkbox,
.geografico-component.dark-theme .municipio-checkbox,
.geografico-component.dark-theme .seccion-checkbox {
  background-color: #1e293b !important;
  border-color: #64748b !important;
}

.geografico-component.dark-theme .distrito-option.selected .distrito-checkbox,
.geografico-component.dark-theme .municipio-option.selected .municipio-checkbox,
.geografico-component.dark-theme .seccion-option.selected .seccion-checkbox {
  background-color: #06b6d4 !important;
  border-color: #06b6d4 !important;
}

.geografico-component.dark-theme .distrito-name,
.geografico-component.dark-theme .municipio-name,
.geografico-component.dark-theme .seccion-name {
  color: #f1f5f9 !important;
}

/* Contenedor principal - PREVENIR EXPANSIÓN HORIZONTAL */
.geografico-component {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

/* Asegurar que todos los elementos hijos respeten el ancho del contenedor */
.geografico-component * {
  box-sizing: border-box !important;
}

/* Grid de distritos - SOLO para la lista de distritos */
.geografico-component .distritos-grid {
  width: 100% !important;
  min-width: 0 !important;
}

/* Labels de distritos - permitir que el grid controle el ancho */
.geografico-component .distritos-grid > label {
  min-width: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* Texto truncado para nombres largos */
.geografico-component .truncate {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Botones - mantener ancho completo */
.geografico-component button {
  width: 100% !important;
  max-width: 100% !important;
}

/* Select de tipo de obra - estilos mejorados */
.geografico-component select {
  appearance: none !important;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
  background-position: right 0.75rem center !important;
  background-repeat: no-repeat !important;
  background-size: 1.5em 1.5em !important;
  padding-right: 2.5rem !important;
  transition: all 0.2s ease !important;
}

.geografico-component select:focus {
  outline: none !important;
  border-color: #06b6d4 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1) !important;
}

.geografico-component select[data-selected="True"] {
  border-color: #06b6d4 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.1) !important;
  background-color: #334155 !important;
}

.geografico-component select option {
  background-color: #1e293b !important;
  color: #ffffff !important;
  padding: 0.5rem !important;
}

.geografico-component select option:hover {
  background-color: #06b6d4 !important;
}

/* Estilos para las opciones de selección (distritos, municipios, secciones) */
.geografico-component .distrito-option,
.geografico-component .municipio-option,
.geografico-component .seccion-option {
  display: flex !important;
  align-items: center !important;
  padding: 0.75rem 1rem !important;
  background-color: #ffffff !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 0.5rem !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  min-height: 3rem !important;
}

.geografico-component .distrito-option:hover,
.geografico-component .municipio-option:hover,
.geografico-component .seccion-option:hover {
  background-color: #f9fafb !important;
  border-color: #d1d5db !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

.geografico-component .distrito-option.selected,
.geografico-component .municipio-option.selected,
.geografico-component .seccion-option.selected {
  background-color: #f3f4f6 !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Checkbox personalizado */
.geografico-component .distrito-checkbox,
.geografico-component .municipio-checkbox,
.geografico-component .seccion-checkbox {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 1.25rem !important;
  height: 1.25rem !important;
  border-radius: 50% !important;
  border: 2px solid #d1d5db !important;
  background-color: #ffffff !important;
  margin-right: 0.75rem !important;
  transition: all 0.2s ease !important;
  flex-shrink: 0 !important;
}

.geografico-component .distrito-option.selected .distrito-checkbox,
.geografico-component .municipio-option.selected .municipio-checkbox,
.geografico-component .seccion-option.selected .seccion-checkbox {
  background-color: #3b82f6 !important;
  border-color: #3b82f6 !important;
  transform: scale(1.1) !important;
}

/* Nombre de la opción */
.geografico-component .distrito-name,
.geografico-component .municipio-name,
.geografico-component .seccion-name {
  color: #374151 !important;
  font-weight: 600 !important;
  font-size: 0.875rem !important;
  text-transform: uppercase !important;
  letter-spacing: 0.025em !important;
  flex: 1 !important;
  min-width: 0 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* Contenedores con scroll */
.geografico-component .distritos-grid-container,
.geografico-component .municipios-grid-container,
.geografico-component .secciones-grid-container {
  border: 1px solid #e5e7eb !important;
  border-radius: 0.5rem !important;
  background-color: #f9fafb !important;
  padding: 1rem !important;
}

/* Scrollbar personalizado */
.geografico-component .custom-scrollbar::-webkit-scrollbar {
  width: 8px !important;
}

.geografico-component .custom-scrollbar::-webkit-scrollbar-track {
  background: #f1f5f9 !important;
  border-radius: 4px !important;
}

.geografico-component .custom-scrollbar::-webkit-scrollbar-thumb {
  background: #cbd5e1 !important;
  border-radius: 4px !important;
}

.geografico-component .custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8 !important;
}

/* Estilos para el componente de datos seleccionados desplegable */
.geografico-component .datos-seleccionados-header {
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  padding: 0.5rem !important;
  border-radius: 0.375rem !important;
}

.geografico-component .datos-seleccionados-header:hover {
  background-color: rgba(6, 182, 212, 0.1) !important;
}

.geografico-component .datos-seleccionados-header:active {
  transform: scale(0.98) !important;
}

.geografico-component .datos-seleccionados-arrow {
  transition: transform 0.3s ease !important;
}

.geografico-component .datos-seleccionados-arrow.rotated {
  transform: rotate(180deg) !important;
}

.geografico-component .datos-seleccionados-content {
  transition: all 0.3s ease !important;
}

.geografico-component .datos-seleccionados-badge {
  background: linear-gradient(135deg, #06b6d4, #3b82f6) !important;
  box-shadow: 0 2px 4px rgba(6, 182, 212, 0.3) !important;
}

/* Prevenir scroll horizontal */
.geografico-component {
  overflow-x: hidden !important;
  overflow-y: visible !important;
}

/* Responsive para pantallas pequeñas */
@media (max-width: 640px) {
  .geografico-component .distritos-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ========================================
   ESTILOS PARA ANÁLISIS GEOGRÁFICO
   ======================================== */

/* Estilos personalizados para el scrollbar */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: #334155;
  border-radius: 3px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #64748b;
  border-radius: 3px;
  transition: background 0.2s ease;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Animaciones personalizadas */
@keyframes slideDown {
  from {
    max-height: 0;
    opacity: 0;
  }
  to {
    max-height: 24rem;
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    max-height: 24rem;
    opacity: 1;
  }
  to {
    max-height: 0;
    opacity: 0;
  }
}

/* Efectos de hover mejorados */
.group:hover .group-hover\:scale-110 {
  transform: scale(1.1);
}

.group:hover .group-hover\:rotate-12 {
  transform: rotate(12deg);
}

/* Transiciones suaves para todos los elementos */
.geografico-component * {
  transition-property: all;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
  transition-duration: 200ms;
}

/* Estilos específicos para las barras desplegables */
.geografico-accordion {
  transition: all 0.3s ease-in-out;
}

.geografico-accordion.open {
  max-height: 24rem;
  opacity: 1;
}

.geografico-accordion.closed {
  max-height: 0;
  opacity: 0;
}

/* Efectos de hover para botones */
.geografico-btn-hover {
  transition: all 0.2s ease;
}

.geografico-btn-hover:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

/* Estilos para el scroll interno */
.geografico-scroll-container {
  max-height: 12rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #64748b #334155;
}

/* Estilos para elementos seleccionados */
.geografico-selected {
  border-color: #06b6d4 !important;
  background-color: #475569 !important;
  box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.2) !important;
}

/* Estilos para el botón de agregar capa */
.geografico-add-layer {
  background: linear-gradient(135deg, #8b5cf6, #ec4899, #8b5cf6);
  background-size: 200% 200%;
  animation: gradientShift 3s ease infinite;
}

@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.geografico-add-layer:hover {
  background-size: 150% 150%;
  transform: scale(1.05);
}

/* Efectos de brillo para botones */
.geografico-shine {
  position: relative;
  overflow: hidden;
}

.geografico-shine::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  transition: left 0.5s;
}

.geografico-shine:hover::before {
  left: 100%;
}

/* ========================================
   SELECTOR DE DIVISIONES GEOGRÁFICAS - TEMA OSCURO
   ======================================== */

/* Variables específicas para componentes geográficos oscuros */
:root {
  --geografico-dark-primary: var(--primary-600);
  --geografico-dark-secondary: var(--gray-400);
  --geografico-dark-background: #1e293b; /* bg-slate-800 - panel oscuro */
  --geografico-dark-text: var(--white);
  --geografico-dark-border: #374151; /* border-gray-700 - bordes oscuros */
  --geografico-dark-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.geografico-selector-section {
  margin-bottom: 1.5rem;
  background: var(--geografico-dark-background);
  border-radius: 8px;
  padding: 1.25rem;
  border: 1px solid var(--geografico-dark-border);
  box-shadow: var(--geografico-dark-shadow);
}

.geografico-selector-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--geografico-dark-text);
  margin-bottom: 0.75rem;
}

.geografico-selector-container {
  position: relative;
  margin-bottom: 1rem;
}

.geografico-select {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 0.75rem;
  border: 2px solid var(--geografico-dark-border);
  border-radius: 6px;
  background-color: #475569; /* bg-slate-600 */
  color: var(--geografico-dark-text);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.geografico-select:focus {
  outline: none;
  border-color: var(--geografico-dark-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.geografico-select:hover {
  border-color: #94a3b8; /* border-slate-400 */
}

.geografico-select-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--geografico-dark-secondary);
  pointer-events: none;
  transition: transform 0.2s ease-in-out;
}

.geografico-elements-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--geografico-dark-border);
  border-radius: 6px;
  background-color: var(--geografico-dark-background);
}

.geografico-elements-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--geografico-dark-text);
  padding: 0.75rem;
  background-color: #334155; /* bg-slate-700 */
  border-bottom: 1px solid var(--geografico-dark-border);
  margin: 0;
}

.geografico-element-item {
  padding: 0.75rem;
  color: var(--geografico-dark-text);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  border-bottom: 1px solid var(--geografico-dark-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.geografico-element-item:last-child {
  border-bottom: none;
}

.geografico-element-item:hover {
  background-color: #475569; /* bg-slate-600 */
}

.geografico-element-item.selected {
  background-color: var(--geografico-dark-primary);
  color: var(--white);
  font-weight: 600;
}

.geografico-element-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.geografico-element-name {
  font-weight: 500;
}

.geografico-element-id {
  font-size: 0.75rem;
  opacity: 0.7;
}

.geografico-element-selected-icon {
  color: var(--white);
}

/* Estados de carga geográficos */
.geografico-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--geografico-dark-secondary);
  font-size: 0.875rem;
  gap: 0.5rem;
}

.geografico-loading-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--geografico-dark-border);
  border-top: 2px solid var(--geografico-dark-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.geografico-empty-state {
  padding: 2rem;
  text-align: center;
  color: var(--geografico-dark-secondary);
  font-size: 0.875rem;
}

/* ========================================
   MAPA GEOGRÁFICO CON LEAFLET
   ======================================== */

.geografico-map-container {
  flex: 1;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--geografico-dark-shadow);
  background: var(--geografico-dark-background);
}

/* Placeholder inicial del mapa */
.geografico-map-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  background-color: var(--geografico-dark-background);
  padding: 2rem;
  text-align: center;
}

.geografico-placeholder-icon {
  margin-bottom: 1.5rem;
}

.geografico-placeholder-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--geografico-dark-text);
  margin-bottom: 0.5rem;
}

.geografico-placeholder-text {
  font-size: 1rem;
  color: var(--geografico-dark-secondary);
  max-width: 400px;
}

/* Loader del mapa */
.geografico-map-loader-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(30, 41, 59, 0.9);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.geografico-loader-spinner {
  width: 3rem;
  height: 3rem;
  border: 4px solid var(--geografico-dark-border);
  border-top: 4px solid var(--geografico-dark-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}

.geografico-loader-text {
  color: var(--geografico-dark-text);
  font-size: 0.875rem;
  font-weight: 500;
  margin: 0;
}

/* Estilos específicos para el contenedor del mapa Leaflet */
#mapa-geografico-container {
  width: 100% !important;
  height: 100% !important;
  position: relative;
  z-index: 1;
}

#mapa-geografico-container .leaflet-container {
  width: 100% !important;
  height: 100% !important;
}

/* Controles del mapa */
#mapa-geografico-container .leaflet-control-container {
  position: relative;
  z-index: 200 !important;
}

#mapa-geografico-container .leaflet-popup,
#mapa-geografico-container .leaflet-tooltip {
  z-index: 250 !important;
}
