@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* Reset y base */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Outfit', sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
}

.container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header estilizado */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 1000;
}

.header img {
  height: 50px;
  width: auto;
  object-fit: contain;
  transition: transform 0.2s ease;
}

.header img:hover {
  transform: scale(1.03);
}

.logo-izq {
  height: 50px;
}

.logo-centro {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  height: 48px;
}

/* Sección superior: Mapa + Filtros */
.top-section {
  display: flex;
  flex: 1;
  min-height: 0;
  padding: 16px;
  gap: 16px;
  background-color: #f1f5f9;
}

/* Contenedor del Mapa */
#map {
  flex: 3;
  height: 100%;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  z-index: 1;
}

/* Contenedor del Sidebar de Filtros */
#sidebar {
  flex: 1;
  max-width: 340px;
  min-width: 280px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-radius: 16px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  padding: 24px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

#sidebar h2 {
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
  color: #0f172a;
  border-bottom: 2px solid #3b82f6;
  padding-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#sidebar h2::before {
  content: '';
  font-size: 18px;
}

/* Grupos de filtros individuales */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-group label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Dropdowns personalizados y premium */
.filter-group select {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: #334155;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.filter-group select:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.filter-group select:focus {
  outline: none;
  border-color: #3b82f6;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Date picker estilizado */
.filter-group input[type="date"] {
  width: 100%;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  color: #334155;
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.filter-group input[type="date"]:hover {
  background-color: #f1f5f9;
  border-color: #94a3b8;
}

.filter-group input[type="date"]:focus {
  outline: none;
  border-color: #3b82f6;
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Botón Limpiar Filtros */
#btn-limpiar {
  margin-top: auto;
  padding: 12px 18px;
  width: 100%;
  background-color: #ef4444;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px 0 rgba(239, 68, 68, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#btn-limpiar:hover {
  background-color: #dc2626;
  box-shadow: 0 4px 6px 0 rgba(220, 38, 38, 0.3);
  transform: translateY(-1px);
}

#btn-limpiar:active {
  transform: translateY(0);
}

/* Tabla de eventos */
.tabla-container {
  overflow-y: auto;
  height: 38vh;
  padding: 16px 24px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
}

.tabla-container h3 {
  margin: 0 0 12px 0;
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tabla-container h3::before {
  content: '📅';
}

/* Tabla modernizada */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: 12px;
  background: white;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px -2px rgba(0, 0, 0, 0.02);
  border: 1px solid #e2e8f0;
  overflow: hidden;
}

th {
  background-color: #1e3a8a;
  color: white;
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid #e2e8f0;
}

td, th {
  padding: 14px 16px;
  font-size: 14px;
  text-align: left;
}

tr {
  transition: background-color 0.15s ease;
}

tr:nth-child(even) {
  background-color: #f8fafc;
}

tr:hover {
  background-color: #f1f5f9;
}

td {
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

tr:last-child td {
  border-bottom: none;
}

/* Estilo personalizado de Popup en Leaflet */
.leaflet-popup-content-wrapper {
  border-radius: 12px !important;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1) !important;
  border: 1px solid #e2e8f0;
}

.popup {
  font-family: 'Outfit', sans-serif;
  color: #334155;
  padding: 4px;
}

.popup h4 {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  color: #1e3a8a;
  border-bottom: 1px solid #f1f5f9;
  padding-bottom: 4px;
}

.popup div {
  font-size: 12px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.popup strong {
  color: #475569;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Leaflet controles */
.leaflet-bar {
  border: none !important;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

.leaflet-bar a {
  background-color: #fff !important;
  border: 1px solid #e2e8f0 !important;
  color: #475569 !important;
  transition: all 0.2s ease;
}

.leaflet-bar a:hover {
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

/* Responsive - Tablets */
@media screen and (max-width: 1024px) {
  html, body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
  }

  .container {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .header {
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding: 10px 16px;
  }

  .logo-centro {
    position: static;
    transform: none;
    order: -1;
  }

  .top-section {
    flex-direction: column;
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 12px;
    gap: 12px;
  }

  #map {
    height: 400px;
    flex: none;
    min-height: unset;
  }

  #sidebar {
    max-width: 100%;
    min-width: 0;
    flex: none;
    border-radius: 12px;
  }

  .tabla-container {
    height: auto;
    max-height: none;
    overflow: visible;
    padding: 12px 16px;
  }

  .tabla-container table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Responsive - Phones */
@media screen and (max-width: 600px) {
  .header {
    padding: 8px 12px;
    gap: 8px;
  }

  .header img {
    height: 36px;
  }

  .logo-izq {
    height: 36px;
  }

  .logo-centro {
    height: 32px;
  }

  .top-section {
    padding: 8px;
    gap: 8px;
  }

  #map {
    height: 280px;
    border-radius: 10px;
  }

  #sidebar {
    padding: 16px;
    border-radius: 10px;
    gap: 12px;
  }

  #sidebar h2 {
    font-size: 17px;
  }

  .filter-group select {
    padding: 8px 12px;
    font-size: 13px;
  }

  #btn-limpiar {
    padding: 10px 14px;
    font-size: 13px;
  }

  .tabla-container {
    padding: 8px 10px;
  }

  .tabla-container h3 {
    font-size: 15px;
  }

  td, th {
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }

  .tabla-container table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 600px;
  }

  /* Leaflet popup ajustado para móvil */
  .leaflet-popup-content-wrapper {
    max-width: 240px !important;
  }

  .popup h4 {
    font-size: 13px;
  }

  .popup div {
    font-size: 11px;
  }
}
