/* ===============================
   VARIABLES GLOBALES
   =============================== */
:root {
  --primary: #F7921E;
  --primary-dark: #e07d0e;
  --secondary: #8b5cf6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --dark-bg: #252525;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

/* ===============================
   RESET Y BASE
   =============================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--dark-bg);
  color: var(--gray-900);
}

/* ===============================
   LAYOUT PRINCIPAL - GRID
   =============================== */
#app {
  display: grid;
  grid-template-columns: 360px 1fr 340px;
  grid-template-rows: 1fr auto;
  grid-template-areas: 
    "izquierdo mapa derecho"
    "inferior mapa derecho";
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--dark-bg);
}

/* Panel Izquierdo */
#panel-izquierdo {
  grid-area: izquierdo;
  background: linear-gradient(rgba(0,0,0,0.7), rgba(0,0,0,0.7)), url('assets/parque-sm.jpg');
  background-size: cover;
  background-position: center;
  overflow-y: auto;
  box-shadow: 5px 0 8px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.panel-izquierdo-contenido {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

/* Panel Derecho */
#panel-derecho {
  grid-area: derecho;
  background: white;
  border-left: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: -2px 0 8px rgba(0, 0, 0, 0.1);
  z-index: 10;
  height: 100%; /* Ocupa todo el alto */
}

.panel-derecho-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
}

.panel-derecho-header h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.resultados-count {
  background: var(--gray-100);
  padding: 4px 10px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
}

.lista-comercios {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* Panel Inferior */
#panel-inferior {
  position: absolute;
  bottom: 0;
  left: 35%;
  background: white;
  border-top: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  z-index: 20;
  box-shadow: var(--shadow-md);
}

/* Mapa */
#map {
  grid-area: mapa;
  height: 100%;
  width: 100%;
  background: var(--gray-100);
  z-index: 1;
}

/* ===============================
   SECCIONES DEL PANEL IZQUIERDO
   =============================== */
.logo-container {
  text-align: center;
  margin-bottom: 10px;
}

.logo {
  max-width: 150px;
  height: auto;
}

.seccion {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.2s;
  box-shadow: var(--shadow-md);
}

.seccion h3, .seccion h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0 0 12px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.seccion h3 i, .seccion h4 i {
  color: var(--primary);
  font-size: 16px;
}

/* Buscador */
.buscador-section {
  background: var(--primary);
}

.buscador-section h3, .buscador-section h3 i {
  color: white;
}

.input-group {
  display: flex;
  gap: 8px;
}

#inputDireccion {
  flex: 1;
  padding: 12px 16px;
  font-size: 14px;
  border: 1px solid white;
  border-radius: var(--radius-md);
  background: white;
  transition: all 0.2s;
}

#inputDireccion:focus {
  outline: none;
  border-color: var(--dark-bg);
  box-shadow: 0 0 0 3px rgba(37, 37, 37, 0.2);
}

#btnBuscar {
  width: auto;
  padding: 12px 20px;
  background: var(--dark-bg);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

#btnBuscar:hover {
  background: #3a3a3a;
  transform: translateY(-1px);
}

.status {
  margin-top: 8px;
  font-size: 12px;
  color: white;
  opacity: 0.9;
}

/* Control de Radio */
.radio-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.radio-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
}

.radio-control {
  padding: 4px 0;
}

#radioSlider {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) 20%, var(--gray-200) 20%);
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

#radioSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: white;
  border: 2px solid var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: all 0.2s;
  margin-top: -7px;
}

#radioSlider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-lg);
}

.radio-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--gray-500);
}

.radio-botones {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.radio-btn {
  flex: 1;
  padding: 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  color: var(--gray-700);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.radio-btn:hover {
  background: var(--gray-200);
  transform: translateY(-1px);
}

/* Capas Públicas */
.capas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.toggle-icon {
  font-size: 14px;
  color: var(--gray-500);
  transition: transform 0.2s;
}

.capas-content {
  margin-top: 16px;
}

.capas-acciones {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.btn-capas {
  flex: 1;
  padding: 6px 12px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 30px;
  font-size: 12px;
  cursor: pointer;
  color: var(--gray-700);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-capas:hover {
  background: var(--gray-200);
}

.capas-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.capa-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: white;
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  transition: all 0.2s;
}

.capa-item:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.capa-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

.capa-item label {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-800);
}

.color-indicator {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  opacity: 0.6;
}

.capas-loading {
  text-align: center;
  padding: 20px;
  color: var(--gray-500);
  font-size: 13px;
}

/* Filtros */
.filtros-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.btn-filtros {
  padding: 8px 16px;
  background: var(--dark-bg);
  color: white;
  border: 1px solid var(--dark-bg);
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-filtros:hover {
  background: var(--primary);
  border-color: var(--primary);
}

.filtros-activos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.tag-filtro {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 4px 12px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-filtro i {
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s;
  font-size: 12px;
}

.tag-filtro i:hover {
  opacity: 1;
}

/* Parcela y Usos */
.parcela-content, .usos-content {
  font-size: 13px;
}

.usos-content {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-permitido {
  background: linear-gradient(135deg, #86efac 0%, #4ade80 100%);
  color: #14532d;
  border: 1px solid #22c55e;
}

/* ===============================
   TARJETAS DE COMERCIOS
   =============================== */
.comercio-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.comercio-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.comercio-nombre {
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 4px;
  font-size: 15px;
}

.comercio-direccion {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.comercio-usos {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.comercio-usos li {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 4px 10px;
  border-radius: 30px;
  font-size: 11px;
  font-weight: 500;
}

/* ===============================
   KPIs COMPACTOS Y EXPANDIDOS
   =============================== */
.kpi-compactos {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 12px;
  padding: 12px 20px;
  align-items: center;
  background: white;
}

.kpi-item {
  text-align: center;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
  border: 1px solid var(--gray-200);
  transition: all 0.2s;
}

.kpi-item:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.kpi-valor {
  font-size: 22px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.kpi-etiqueta {
  font-size: 11px;
  color: var(--gray-600);
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.kpi-expandir {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  box-shadow: var(--shadow-sm);
}

.kpi-expandir:hover {
  background: var(--primary-dark);
  transform: scale(1.1);
}

.kpi-expandir i {
  transition: transform 0.3s;
}

.kpi-expandir.rotated i {
  transform: rotate(45deg);
}

.kpis-expandido {
  border-top: 1px solid var(--gray-200);
  background: white;
  max-height: 300px;
  overflow-y: auto;
  animation: slideDown 0.3s ease;
}

.kpis-expandido-contenido {
  padding: 20px;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===============================
   MODAL DE FILTROS
   =============================== */
#modalFiltros {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: white;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  padding: 24px;
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-subtitulo {
  color: var(--gray-500);
  font-size: 13px;
}

.modal-acciones {
  display: flex;
  gap: 8px;
}

.btn-seleccion {
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

#btnSeleccionarTodos {
  background: var(--primary);
  color: white;
}

#btnDeseleccionarTodos {
  background: var(--gray-100);
  color: var(--gray-600);
  border: 1px solid var(--gray-200);
}

#buscarUsosModal {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 16px;
}

#buscarUsosModal:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(247, 146, 30, 0.1);
}

.categoria-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.categoria-tab {
  padding: 8px 16px;
  background: var(--gray-100);
  color: var(--gray-700);
  border: none;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.categoria-tab:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.categoria-tab.activo {
  background: var(--primary);
  color: white;
}

.usos-container {
  max-height: 400px;
  overflow-y: auto;
  padding: 4px;
}

.subcategoria-block {
  margin-bottom: 20px;
  background: white;
  border-radius: var(--radius-lg);
  padding: 16px;
  border: 1px solid var(--gray-200);
}

.subcategoria-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.subcategoria-header h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subcategoria-count {
  background: var(--gray-100);
  color: var(--gray-600);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
}

.btn-subcategoria {
  background: transparent;
  border: 1px solid var(--gray-200);
  border-radius: 30px;
  padding: 4px 12px;
  font-size: 11px;
  color: var(--gray-500);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-subcategoria:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.usos-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.uso-item {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.uso-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.uso-label {
  padding: 6px 14px;
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-200);
  border-radius: 30px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.uso-label:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.uso-label.checked {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-200);
}

.btn-cancelar {
  padding: 10px 20px;
  border: 1px solid var(--gray-200);
  background: white;
  color: var(--gray-600);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancelar:hover {
  background: var(--gray-50);
}

.btn-aplicar {
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-aplicar:hover {
  background: var(--primary-dark);
}

/* ===============================
   CONTROLES DEL MAPA
   =============================== */
.leaflet-control-attribution,
.leaflet-control-zoom {
  display: none !important;
}

.leaflet-control-zoom {
  display: block !important;
  border: none !important;
  box-shadow: var(--shadow-md) !important;
  border-radius: var(--radius-md) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  background: white !important;
  color: var(--gray-900) !important;
  border: none !important;
  width: 40px !important;
  height: 40px !important;
  line-height: 40px !important;
  font-size: 18px !important;
  transition: all 0.2s;
}

.leaflet-control-zoom a:hover {
  background: var(--gray-100) !important;
  color: var(--primary) !important;
}

.custom-marker {
  background: transparent;
  border: none;
  filter: drop-shadow(0 4px 3px rgba(0, 0, 0, 0.2));
}

/* ===============================
   SCROLL PERSONALIZADO
   =============================== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(200,200,200,0.6));
  border-radius: 10px;
  backdrop-filter: blur(6px);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(180,180,180,0.9));
}

/* ===============================
   UTILIDADES
   =============================== */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.bg-primary { background: var(--primary); }
.bg-success { background: var(--success); }

/* ===============================
   SUGERENCIA DE PARCELAS
   =============================== */
.sugerencia-section {
  position: absolute;
  top: 0;
  left: 20%;
  animation: slideIn 0.3s ease;
  margin-bottom: 16px;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sugerencia-section:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(245, 158, 11, 0.2);
}

.comparacion-section {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Popup personalizado para parcelas sugeridas */
.leaflet-popup-content {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  min-width: 200px;
}

.leaflet-popup-content button {
  font-family: 'Inter', sans-serif;
  transition: all 0.2s;
}

.leaflet-popup-content button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}
/* ===============================
   LOADING INDICATOR
   =============================== */
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: white;
  min-height: 200px;
}

.loading-spinner {
  position: relative;
  width: 80px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.loading-spinner i {
  color: var(--primary);
  opacity: 0.8;
  z-index: 2;
  animation: pulse 0.5s ease-in-out infinite;
}

.spinner {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 4px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 16px;
  animation: fadeInOut 2s ease-in-out infinite;
}

.loading-progress {
  width: 200px;
  height: 4px;
  background: var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
}

.loading-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 10px;
  animation: progress 1.5s ease-in-out infinite;
  width: 30%;
}

/* Loading skeleton para cards (opcional, más sutil) */
.loading-skeleton {
  padding: 16px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  margin-bottom: 12px;
}

.skeleton-line {
  height: 16px;
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
  margin-bottom: 8px;
}

.skeleton-line:last-child {
  width: 60%;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
}

@keyframes fadeInOut {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

@keyframes progress {
  0% { width: 30%; margin-left: 0; }
  50% { width: 70%; margin-left: 30%; }
  100% { width: 30%; margin-left: 70%; }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
