/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Colors */
  --color-primary: #2c3e50;
  --color-secondary: #34495e;
  --color-accent: #e74c3c;
  --color-success: #27ae60;
  --color-warning: #f39c12;
  --color-info: #3498db;
  --color-light: #ecf0f1;
  --color-dark: #2c3e50;
  --color-white: #ffffff;
  --color-gray: #95a5a6;

  /* Categoría Colors */
  --color-presencia: #3498db;
  --color-hecho-victimizante: #e74c3c;

  /* Hecho Colors */
  --color-extorsion: #8B0000;
  --color-ataque: #FF0000;
  --color-reclutamiento: #800080;
  --color-amenaza: #FFA500;
  --color-desplazamiento: #5F9EA0;
  --color-infraestructura: #00008B;
  --color-allanamiento: #F08080;
  --color-homicidio: #000000;

  /* Spacing */
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 1rem;
  --spacing-lg: 1.5rem;
  --spacing-xl: 2rem;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.15);
  --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.2);
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--color-light);
  color: var(--color-dark);
  line-height: 1.6;
  overflow: hidden;
}

/* ===== MAP CONTAINER (FULLSCREEN) ===== */
.map-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

/* ===== OVERLAY PANELS ===== */
.overlay-panel {
  position: fixed;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 85vh;
  overflow: visible;
  transition: all 0.3s ease;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  cursor: pointer;
  user-select: none;
}

.panel-header h3 {
  font-size: 1.1rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.panel-toggle {
  background: transparent;
  border: none;
  color: var(--color-white);
  font-size: 1.2rem;
  cursor: pointer;
  padding: var(--spacing-xs);
  transition: transform 0.3s ease;
}

.panel-toggle:hover {
  transform: scale(1.1);
}

.panel-content {
  padding: var(--spacing-md);
  max-height: 70vh;
  overflow-y: auto;
  transition: max-height 0.3s ease, opacity 0.3s ease;
}

.panel-content.collapsed {
  max-height: 0;
  opacity: 0;
  padding: 0;
  overflow: hidden;
}

/* ===== FILTER PANEL ===== */
.filter-panel {
  top: 20px;
  right: 20px;
  max-width: 320px;
  min-width: 280px;
}

.filter-group {
  margin-bottom: var(--spacing-md);
}

.filter-label {
  display: block;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--color-secondary);
  font-size: 0.85rem;
}

.filter-select,
.filter-input {
  width: 100%;
  padding: var(--spacing-sm);
  border: 2px solid var(--color-gray);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.filter-select:focus,
.filter-input:focus {
  outline: none;
  border-color: var(--color-info);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.checkbox-label {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.9rem;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  margin-right: var(--spacing-sm);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.checkbox-text {
  font-weight: 500;
}

.filter-actions {
  margin-top: var(--spacing-lg);
}

.btn {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
}

.btn-primary {
  background-color: var(--color-success);
  color: var(--color-white);
}

.btn-primary:hover {
  background-color: #229954;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background-color: var(--color-gray);
  color: var(--color-white);
}

.btn-secondary:hover {
  background-color: #7f8c8d;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn-small {
  padding: var(--spacing-xs) var(--spacing-md);
  font-size: 0.85rem;
}

.filter-stats {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 2px solid var(--color-light);
  text-align: center;
}

.stat-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-info);
  color: var(--color-white);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.9rem;
}

/* ===== LEGEND PANEL ===== */
.legend-panel {
  bottom: 20px;
  left: 20px;
  max-width: 280px;
  min-width: 240px;
}

.legend-section {
  margin-bottom: var(--spacing-lg);
}

.legend-section:last-child {
  margin-bottom: 0;
}

.legend-section h4 {
  font-size: 0.9rem;
  margin-bottom: var(--spacing-sm);
  color: var(--color-secondary);
  font-weight: 600;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-xs) 0;
  font-size: 0.85rem;
}

.legend-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.legend-marker {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.marker-hecho-victimizante-demo {
  border: 3px solid var(--color-hecho-victimizante);
  background-color: rgba(231, 76, 60, 0.3);
}

.marker-presencia-demo {
  border: 2px dashed var(--color-presencia);
  background-color: rgba(52, 152, 219, 0.2);
}

/* ===== SETTINGS BUTTON ===== */
.settings-button {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 1000;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-white);
  font-size: 1.3rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-button:hover {
  transform: rotate(90deg) scale(1.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ===== MODAL OVERLAY ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.modal-overlay.active {
  display: flex;
}

.modal-container {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-lg);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-white);
}

.modal-header h2 {
  font-size: 1.4rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--color-white);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--spacing-xs);
  transition: transform 0.3s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close:hover {
  transform: rotate(90deg);
  background: rgba(255, 255, 255, 0.1);
}

.modal-tabs {
  display: flex;
  background: var(--color-light);
  border-bottom: 2px solid var(--color-gray);
}

.modal-tab {
  flex: 1;
  padding: var(--spacing-md);
  border: none;
  background: transparent;
  color: var(--color-secondary);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  border-bottom: 3px solid transparent;
}

.modal-tab:hover {
  background: rgba(52, 152, 219, 0.1);
}

.modal-tab.active {
  color: var(--color-info);
  background: var(--color-white);
  border-bottom-color: var(--color-info);
}

.modal-content {
  padding: var(--spacing-xl);
  overflow-y: auto;
  flex: 1;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.tab-placeholder {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--color-gray);
  font-size: 1rem;
}

.upload-area {
  border: 3px dashed var(--color-gray);
  border-radius: var(--radius-lg);
  padding: var(--spacing-xl);
  text-align: center;
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--color-info);
  background: rgba(52, 152, 219, 0.05);
}

.upload-area i {
  font-size: 3rem;
  color: var(--color-info);
  margin-bottom: var(--spacing-md);
  display: block;
}

.upload-area p {
  margin-bottom: var(--spacing-lg);
  color: var(--color-secondary);
}

.upload-area.drag-over {
  border-color: var(--color-success);
  background: rgba(46, 204, 113, 0.1);
}

.progress-bar {
  width: 100%;
  height: 30px;
  background: var(--color-light);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-info), var(--color-success));
  width: 0%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

#progress-text {
  text-align: center;
  color: var(--color-secondary);
  font-weight: 500;
}

/* FIX: Permitir múltiples alertas en el contenedor de resultados */
#upload-results {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.alert {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.alert-success {
  background: rgba(46, 204, 113, 0.1);
  color: var(--color-success);
  border-left: 4px solid var(--color-success);
}

/* NEW: Estilos para alertas de advertencia e información */
.alert-warning {
  background: rgba(243, 156, 18, 0.1);
  color: #d35400; /* Naranja más oscuro para mejor contraste */
  border-left: 4px solid var(--color-warning);
}

.alert-info {
  background: rgba(52, 152, 219, 0.1);
  color: var(--color-info);
  border-left: 4px solid var(--color-info);
}


/* ===== FORM STYLES ===== */
.form-container {
  max-width: 100%;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
}

.form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: var(--spacing-md);
}

.form-group label {
  font-weight: 600;
  color: var(--color-secondary);
  margin-bottom: var(--spacing-sm);
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: var(--spacing-sm);
  border: 2px solid var(--color-gray);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-info);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
  resize: vertical;
  font-family: inherit;
}

.form-actions {
  display: flex;
  gap: var(--spacing-md);
  margin-top: var(--spacing-lg);
  padding-top: var(--spacing-lg);
  border-top: 2px solid var(--color-light);
}

.form-actions .btn {
  flex: 1;
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ===== LIST/TABLE STYLES ===== */
.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

.list-header h3 {
  margin: 0;
  color: var(--color-secondary);
}

.list-controls {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.search-input {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 2px solid var(--color-gray);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  min-width: 200px;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-info);
}

#registros-table-container {
  overflow-x: auto;
  max-height: 500px;
  overflow-y: auto;
}

.registros-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius-md);
}

.registros-table thead {
  background: var(--color-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.registros-table th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  color: var(--color-secondary);
  border-bottom: 2px solid var(--color-gray);
  font-size: 0.9rem;
}

.registros-table td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--color-light);
  font-size: 0.9rem;
}

.registros-table tbody tr:hover {
  background: rgba(52, 152, 219, 0.05);
}

.cell-id {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--color-secondary);
}

.cell-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.btn-icon {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  background: transparent;
}

.btn-icon:hover {
  transform: scale(1.1);
}

.btn-icon-info {
  color: var(--color-info);
}

.btn-icon-info:hover {
  background: rgba(52, 152, 219, 0.1);
}

.btn-icon-warning {
  color: var(--color-warning);
}

.btn-icon-warning:hover {
  background: rgba(243, 156, 18, 0.1);
}

.btn-icon-danger {
  color: var(--color-danger);
}

.btn-icon-danger:hover {
  background: rgba(231, 76, 60, 0.1);
}

.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-presencia {
  background: rgba(149, 165, 166, 0.2);
  color: var(--color-secondary);
  border: 1px dashed var(--color-secondary);
}

.badge-afectacion {
  background: rgba(231, 76, 60, 0.1);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

/* ===== MARKER STYLES ===== */
.marker-hecho-victimizante {
  width: 40px;
  height: 40px;
  /* FIX: Usar la variable CSS --marker-color para el borde */
  border: 3px solid var(--marker-color);
  border-style: solid !important;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background-color: white;
  box-shadow: var(--shadow-md);
}
/* FIX: Aplicar el color del ícono usando la variable CSS */
.marker-hecho-victimizante i {
  color: var(--marker-color);
}

.marker-presencia {
  width: 35px;
  height: 35px;
  /* FIX: Usar la variable CSS --marker-color para el borde */
  border: 2px solid var(--marker-color);
  border-style: dashed !important;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background-color: white;
  box-shadow: var(--shadow-sm);
}
/* FIX: Aplicar el color del ícono usando la variable CSS */
.marker-presencia i {
  color: var(--marker-color);
  opacity: 0.8; /* Mantener una ligera transparencia para diferenciar */
}

/* ===== POPUP STYLES ===== */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 0;
}

.leaflet-popup-content {
  margin: 0;
}

.custom-popup {
  min-width: 280px;
  font-family: inherit;
}

.popup-header {
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: var(--color-white);
  padding: var(--spacing-md);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.popup-categoria {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-sm);
}

.popup-categoria.presencia {
  background-color: var(--color-presencia);
}

.popup-categoria.afectacion {
  background-color: var(--color-afectacion);
}

.popup-hecho {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.popup-content {
  padding: var(--spacing-md);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--color-light);
  gap: var(--spacing-md);
}

.popup-row:last-child {
  border-bottom: none;
}

.popup-label {
  font-weight: 600;
  color: var(--color-secondary);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.popup-value {
  color: var(--color-dark);
  font-size: 0.85rem;
  text-align: right;
}

.popup-link {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--color-info);
  color: var(--color-white);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.3s ease;
  width: 100%;
  justify-content: center;
}

.popup-link:hover {
  background-color: #2980b9;
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(44, 62, 80, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  z-index: 9999;
  color: var(--color-white);
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: var(--color-white);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: var(--spacing-md);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay p {
  font-size: 1.1rem;
  font-weight: 600;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
  /* Filtros en la parte inferior, estilo drawer */
  .filter-panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    max-width: 100%;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: none;
    overflow: visible;
  }

  /* Panel header MUY compacto en móvil (solo 48px de alto) */
  .filter-panel .panel-header {
    padding: 10px var(--spacing-md);
    min-height: 48px;
  }

  .filter-panel .panel-header h3 {
    font-size: 0.95rem;
  }

  .filter-panel .panel-toggle {
    font-size: 1rem;
  }

  /* Contenido de filtros más compacto */
  .filter-panel .panel-content {
    padding: var(--spacing-sm) var(--spacing-md);
    max-height: 50vh;
    overflow-y: auto;
  }

  /* IMPORTANTE: collapsed debe tener mayor especificidad */
  .filter-panel .panel-content.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding: 0;
    overflow: hidden;
  }

  /* Reducir spacing entre grupos de filtros */
  .filter-group {
    margin-bottom: var(--spacing-sm);
  }

  /* Labels más pequeños */
  .filter-label {
    font-size: 0.8rem;
    margin-bottom: 4px;
  }

  /* Inputs y selects más compactos */
  .filter-select,
  .filter-input {
    padding: 6px 8px;
    font-size: 0.85rem;
  }

  /* Stats badge más pequeño */
  .stat-badge {
    font-size: 0.8rem;
    padding: 4px 8px;
  }

  /* Checkbox labels más compactos */
  .checkbox-label {
    font-size: 0.85rem;
  }

  .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
  }

  /* Leyenda VISIBLE en móviles - posicionada en la parte superior izquierda */
  .legend-panel {
    display: block !important;
    top: 70px; /* Debajo del botón de settings */
    left: 10px;
    bottom: auto;
    max-width: 240px;
    min-width: 200px;
  }

  /* Panel header de leyenda más compacto en móvil */
  .legend-panel .panel-header {
    padding: 8px var(--spacing-sm);
    min-height: 40px;
  }

  .legend-panel .panel-header h3 {
    font-size: 0.85rem;
  }

  /* Contenido de leyenda más compacto */
  .legend-panel .panel-content {
    padding: var(--spacing-sm);
    max-height: 40vh;
    overflow-y: auto;
  }

  .legend-panel .panel-content.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding: 0;
    overflow: hidden;
  }

  /* Items de leyenda más pequeños */
  .legend-panel .legend-item {
    padding: 2px 0;
    font-size: 0.75rem;
    gap: var(--spacing-sm);
  }

  .legend-panel .legend-marker {
    width: 20px;
    height: 20px;
  }

  .legend-panel .legend-icon {
    font-size: 0.9rem;
    width: 20px;
  }

  .legend-panel .legend-section h4 {
    font-size: 0.8rem;
    margin-bottom: 4px;
  }

  .legend-panel .legend-section {
    margin-bottom: var(--spacing-sm);
  }

  /* Botón de configuración reposicionado */
  .settings-button {
    top: 10px;
    left: 10px;
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  .settings-button:hover {
    transform: rotate(90deg) scale(1.05);
  }

  /* Modal adaptado */
  .modal-container {
    width: 95%;
    max-height: 90vh;
  }

  .modal-header {
    padding: var(--spacing-md);
  }

  .modal-header h2 {
    font-size: 1rem;
  }

  .modal-content {
    padding: var(--spacing-md);
  }

  .modal-tabs {
    flex-wrap: wrap;
  }

  .modal-tab {
    padding: var(--spacing-sm);
    font-size: 0.8rem;
    flex: 1 1 auto;
    min-width: 33%;
    border-bottom: 2px solid transparent;
  }

  .modal-tab.active {
    border-bottom-color: var(--color-info);
  }
}

/* Pantallas muy pequeñas (smartphones en vertical) */
@media (max-width: 480px) {
  /* Filtros aún más compactos */
  .filter-panel {
    max-height: none;
  }

  .filter-panel .panel-header {
    padding: 8px var(--spacing-md);
    min-height: 44px;
  }

  .filter-panel .panel-header h3 {
    font-size: 0.9rem;
  }

  .filter-panel .panel-content {
    max-height: 40vh;
    padding: var(--spacing-xs) var(--spacing-sm);
    overflow-y: auto;
  }

  /* IMPORTANTE: collapsed debe tener mayor especificidad */
  .filter-panel .panel-content.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding: 0;
    overflow: hidden;
  }

  .filter-group {
    margin-bottom: 8px;
  }

  .filter-label {
    font-size: 0.75rem;
  }

  .filter-select,
  .filter-input {
    padding: 4px 6px;
    font-size: 0.8rem;
  }

  /* Leyenda VISIBLE también en pantallas muy pequeñas */
  .legend-panel {
    display: block !important;
    top: 60px;
    left: 8px;
    max-width: 200px;
    min-width: 180px;
  }

  .legend-panel .panel-header {
    padding: 6px var(--spacing-xs);
    min-height: 36px;
  }

  .legend-panel .panel-header h3 {
    font-size: 0.8rem;
  }

  .legend-panel .legend-item {
    font-size: 0.7rem;
  }

  .legend-panel .legend-marker {
    width: 18px;
    height: 18px;
  }

  .legend-panel .legend-icon {
    font-size: 0.8rem;
    width: 18px;
  }

  /* Popups más pequeños */
  .custom-popup {
    min-width: 220px;
  }

  .popup-header {
    padding: var(--spacing-sm);
  }

  .popup-hecho {
    font-size: 0.95rem;
  }

  .popup-content {
    padding: var(--spacing-sm);
  }

  .popup-row {
    flex-direction: column;
    gap: 2px;
    padding: 4px 0;
  }

  .popup-label,
  .popup-value {
    font-size: 0.8rem;
  }

  .popup-value {
    text-align: left;
  }

  /* Botón de settings más pequeño */
  .settings-button {
    width: 40px;
    height: 40px;
    font-size: 1rem;
  }
}

/* Landscape mode en móviles */
@media (max-width: 768px) and (orientation: landscape) {
  .filter-panel {
    max-height: none;
  }

  .filter-panel .panel-content {
    max-height: 70vh;
    overflow-y: auto;
  }

  /* IMPORTANTE: collapsed debe tener mayor especificidad */
  .filter-panel .panel-content.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding: 0;
    overflow: hidden;
  }

  .legend-panel {
    max-height: 40vh;
  }
}

/* Tablets en vertical */
@media (min-width: 481px) and (max-width: 768px) {
  .filter-panel {
    max-width: 100%;
  }

  /* Leyenda VISIBLE también en tablets */
  .legend-panel {
    display: block !important;
    top: 70px;
    left: 10px;
    max-width: 220px;
    min-width: 190px;
  }
}

/* ===== LEAFLET CLUSTER CUSTOMIZATION ===== */

/* Cluster de Presencia (Azul con borde punteado) */
.marker-cluster-presencia,
.marker-cluster-presencia-small,
.marker-cluster-presencia-medium,
.marker-cluster-presencia-large {
  background-color: rgba(52, 152, 219, 0.4);
  border: 3px dashed var(--color-presencia) !important;
}

.marker-cluster-presencia div,
.marker-cluster-presencia-small div,
.marker-cluster-presencia-medium div,
.marker-cluster-presencia-large div {
  background-color: rgba(52, 152, 219, 0.7);
  color: var(--color-white);
  font-weight: 700;
  font-size: 14px;
}

/* Cluster de Hecho Victimizante (Rojo con borde sólido) */
/* FIX: Renombrada la clase de 'afectacion' a 'hecho-victimizante' para que coincida con app.js */
.marker-cluster-hecho-victimizante,
.marker-cluster-hecho-victimizante-small,
.marker-cluster-hecho-victimizante-medium,
.marker-cluster-hecho-victimizante-large {
  background-color: rgba(231, 76, 60, 0.5);
  border: 3px solid var(--color-hecho-victimizante) !important;
}

.marker-cluster-hecho-victimizante div,
.marker-cluster-hecho-victimizante-small div,
.marker-cluster-hecho-victimizante-medium div,
.marker-cluster-hecho-victimizante-large div {
  background-color: rgba(231, 76, 60, 0.8);
  color: var(--color-white);
  font-weight: 700;
  font-size: 14px;
}

/* Cluster Mixto (cuando hay ambos tipos) */
.marker-cluster-mixto,
.marker-cluster-mixto-small,
.marker-cluster-mixto-medium,
.marker-cluster-mixto-large {
  background-color: rgba(155, 89, 182, 0.5);
  border: 3px solid #9b59b6 !important;
}

.marker-cluster-mixto div,
.marker-cluster-mixto-small div,
.marker-cluster-mixto-medium div,
.marker-cluster-mixto-large div {
  background-color: rgba(155, 89, 182, 0.8);
  color: var(--color-white);
  font-weight: 700;
  font-size: 14px;
}

/* Fallback para clusters genéricos */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: rgba(52, 152, 219, 0.6);
  border: 3px solid var(--color-info);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
  background-color: rgba(52, 152, 219, 0.8);
  color: var(--color-white);
  font-weight: 700;
  font-size: 14px;
}

/* ===== ERRORS TABLE STYLES ===== */
#upload-errors {
  background: rgba(231, 76, 60, 0.05);
  border: 2px solid rgba(231, 76, 60, 0.3);
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
}

.errors-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-sm);
  border-bottom: 2px solid rgba(231, 76, 60, 0.2);
}

.errors-header h4 {
  color: var(--color-accent);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0;
}

.errors-header h4 i {
  color: var(--color-accent);
}

#errors-count {
  background: var(--color-accent);
  color: var(--color-white);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.9rem;
  font-weight: 600;
}

.errors-table-container {
  max-height: 400px;
  overflow-y: auto;
  border-radius: var(--radius-sm);
  background: var(--color-white);
}

.errors-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.errors-table thead {
  position: sticky;
  top: 0;
  background: var(--color-accent);
  color: var(--color-white);
  z-index: 10;
}

.errors-table th {
  padding: var(--spacing-sm) var(--spacing-md);
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.errors-table td {
  padding: var(--spacing-sm) var(--spacing-md);
  border-bottom: 1px solid var(--color-light);
}

.errors-table tbody tr:hover {
  background: rgba(231, 76, 60, 0.05);
}

.errors-table tbody tr:last-child td {
  border-bottom: none;
}

.error-type {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  background: rgba(231, 76, 60, 0.1);
  color: var(--color-accent);
}

/* Scrollbar styling for errors table */
.errors-table-container::-webkit-scrollbar {
  width: 8px;
}

.errors-table-container::-webkit-scrollbar-track {
  background: var(--color-light);
  border-radius: var(--radius-sm);
}

.errors-table-container::-webkit-scrollbar-thumb {
  background: var(--color-accent);
  border-radius: var(--radius-sm);
}

.errors-table-container::-webkit-scrollbar-thumb:hover {
  background: #c0392b;
}

/* ===== ERROR ROW SEVERITY STYLES ===== */
.error-row {
  transition: background-color 0.2s ease;
}

.error-row.error-error {
  background: rgba(231, 76, 60, 0.1);
  border-left: 3px solid var(--color-accent);
}

.error-row.error-warning {
  background: rgba(243, 156, 18, 0.1);
  border-left: 3px solid var(--color-warning);
}

.error-row.error-info {
  background: rgba(52, 152, 219, 0.1);
  border-left: 3px solid var(--color-info);
}

.error-row:hover {
  opacity: 0.8;
}

/* ===== NOTIFICATION SYSTEM ===== */
.notification-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.notification {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 400px;
  pointer-events: all;
  animation: slideIn 0.3s ease-out;
  border-left: 4px solid;
}

@keyframes slideIn {
  from {
    transform: translateX(400px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(400px);
    opacity: 0;
  }
}

.notification-success {
  border-left-color: var(--color-success);
  color: var(--color-success);
}

.notification-error {
  border-left-color: var(--color-accent);
  color: var(--color-accent);
}

.notification-warning {
  border-left-color: var(--color-warning);
  color: var(--color-warning);
}

.notification-info {
  border-left-color: var(--color-info);
  color: var(--color-info);
}

.notification span {
  flex: 1;
  color: var(--color-dark);
}

.notification-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.notification-close:hover {
  opacity: 1;
}

/* ===== ERROR MODAL ===== */
.error-modal,
.confirm-modal,
.details-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 9999;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.error-modal-content,
.confirm-modal-content,
.details-modal-content {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 600px;
  max-height: 80vh;
  width: 90%;
  display: flex;
  flex-direction: column;
  animation: scaleIn 0.3s ease;
}

@keyframes scaleIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.error-modal-header,
.confirm-modal-header,
.details-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px;
  border-bottom: 1px solid var(--color-light);
}

.error-modal-header h3,
.confirm-modal-header h3,
.details-modal-header h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-accent);
  font-size: 1.25rem;
}

.confirm-modal-header h3 {
  color: var(--color-warning);
}

.details-modal-header h3 {
  color: var(--color-info);
}

.error-modal-close,
.details-modal-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--color-gray);
  transition: color 0.2s ease;
  font-size: 1.25rem;
}

.error-modal-close:hover,
.details-modal-close:hover {
  color: var(--color-dark);
}

.error-modal-body,
.confirm-modal-body,
.details-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.error-modal-body pre,
.details-modal-body pre {
  white-space: pre-wrap;
  word-wrap: break-word;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--color-dark);
}

.confirm-modal-body p {
  font-size: 1rem;
  color: var(--color-dark);
  line-height: 1.6;
}

.error-modal-footer,
.confirm-modal-footer,
.details-modal-footer {
  padding: 20px;
  border-top: 1px solid var(--color-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== RESPONSIVE MODALS ===== */
@media (max-width: 768px) {
  .error-modal-content,
  .confirm-modal-content,
  .details-modal-content {
    max-width: 95%;
    max-height: 90vh;
  }

  .notification {
    min-width: 250px;
    max-width: 320px;
  }

  .notification-container {
    right: 10px;
    top: 10px;
  }
}
