@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

/* =========================================================
   ESTILOS BASE
   ========================================================= */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  font-family: "DM Sans", Arial, sans-serif;
  background-color: #f8f9fa;
  color: #212529;
  overflow: hidden;
}

/* =========================================================
   MAPA (100% PANTALLA)
   ========================================================= */
#map {
  height: 100vh;
  width: 100vw;
  position: relative;
  z-index: 1;
}

/* =========================================================
   SIDEBAR FLOTANTE
   ========================================================= */
#sidebar {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 320px;
  max-height: 90vh;
  background-color: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  padding: 24px;
  overflow-y: auto;
  z-index: 1000;
  backdrop-filter: blur(8px);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

/* LOGO VALLE COLORETE */
#sidebar-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 14px;
}

#sidebar-logo img {
  width: 70px;
  max-width: 100%;
  height: auto;
  display: block;
  transition: width 0.3s ease;
}

/* =========================================================
   CAMPOS DE FILTRO
   ========================================================= */
#sidebar label {
  display: block;
  margin-top: 12px;
  margin-bottom: 5px;
  font-weight: 600;
  font-size: 0.9rem;
  color: #333;
}

#sidebar input,
#sidebar select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  background-color: #fff;
  font-size: 0.9rem;
  color: #212529;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#sidebar input::placeholder {
  color: #999;
}

#sidebar input:focus,
#sidebar select:focus {
  border-color: #767bfc;
  outline: none;
  box-shadow: 0 0 4px rgba(118, 123, 252, 0.3);
}

/* Flecha personalizada de selects */
#sidebar select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 10px 28px 10px 12px;
  background-image: url("data:image/svg+xml;charset=UTF-8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6'><path fill='%23767bfc' d='M0 0l5 6 5-6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 10px;
  background-origin: content-box;
}

/* =========================================================
   BOTONES
   ========================================================= */
#sidebar button {
  padding: 10px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  color: white;
  font-size: 0.9rem;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

#sidebar button:hover {
  transform: scale(1.02);
}

#btn-filtrar {
  background-color: #767bfc;
  width: 48%;
}

#btn-filtrar:hover {
  background-color: #5f64e8;
}

#btn-limpiar {
  background-color: #6c757d;
  width: 48%;
}

#btn-limpiar:hover {
  background-color: #5a6268;
}

/* =========================================================
   CONTADOR Y LEYENDA FLOTANTE
   ========================================================= */
#resultados-conteo {
  margin-top: 16px;
  font-size: 0.9rem;
  color: #444;
  font-style: italic;
}

/* Leyenda flotante */
#leyenda-flotante {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  padding: 10px 14px;
  z-index: 1000;
  width: 160px;
  font-family: 'DM Sans', sans-serif;
}

#leyenda-flotante h3 {
  margin: 0 0 6px 0;
  font-size: 0.95rem;
  color: #333;
  text-align: center;
  font-weight: 600;
}

.leyenda-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #444;
  margin: 3px 0;
}

.leyenda-item img {
  width: 16px;
  height: 26px;
  object-fit: contain;
}

/* =========================================================
   SCROLLBAR
   ========================================================= */
#sidebar::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-thumb {
  background-color: rgba(118, 123, 252, 0.3);
  border-radius: 10px;
}

/* =========================================================
   BOTÓN MÓVIL
   ========================================================= */
#toggleSidebar {
  position: absolute;
  top: 15px;
  left: 15px;
  z-index: 1500;
  background-color: #767bfc;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  display: none;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

#toggleSidebar:hover {
  background-color: #5f64e8;
}

/* =========================================================
   CONTROLES LEAFLET (ZOOM) - ARRIBA DERECHA
   ========================================================= */
.leaflet-control-container .leaflet-top.leaflet-left {
  top: 20px !important;
  bottom: auto !important;
  left: auto !important;
  right: 20px !important;
}

/* =========================================================
   RESPONSIVIDAD
   ========================================================= */
@media (max-width: 768px) {
  #toggleSidebar {
    display: block;
  }

  #sidebar {
    transform: translateX(-110%);
    opacity: 0;
  }

  #sidebar.visible {
    transform: translateX(0);
    opacity: 1;
  }

  #sidebar {
    width: 80%;
    max-width: 320px;
  }

  /* Logo más pequeño en móvil */
  #sidebar-logo img {
    width: 50px;
  }

  /* Leyenda en una fila al pie */
  #leyenda-flotante {
    bottom: 5px;
    left: 5px;
    right: 5px;
    width: auto;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 6px 10px;
    border-radius: 10px;
  }

  #leyenda-flotante h3 {
    display: none;
  }

  .leyenda-item {
    flex-direction: row;
    font-size: 0.8rem;
    margin: 0 4px;
  }

  .leyenda-item img {
    width: 14px;
    height: 24px;
  }
}
