/* =========================================================
   BASE GENERAL
========================================================= */
body {
  margin: 0;
  font-family: "Raleway", sans-serif;
}

.principal {
  display: flex;
  height: 100vh;
  width: 100%;
}

#map {
  flex: 1;
}

/* =========================================================
   INPUTS Y SELECTS
========================================================= */
.control-estandar,
.input-con-boton input,
#rubroFilter,
#searchBox {
  height: 42px;
  padding: 0 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.control-estandar:focus,
.input-con-boton input:focus,
#rubroFilter:focus,
#searchBox:focus {
  outline: none;
  border-color: #007bff;
}

/* =========================================================
   INPUT CON BOTONES DE ACCIÓN
========================================================= */
.input-con-boton {
  position: relative;
  display: flex;
  align-items: center;
  width: auto;
}

#btn-geocode,
#clearDireccion {
  position: absolute;
  top: 7px;
  height: 28px;
  width: 28px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 14px;
  color: #666;
  transition: color 0.2s;
}

#clearDireccion {
  right: 35px;
  display: none;
}

#btn-geocode {
  right: 5px;
}

#btn-geocode:hover,
#clearDireccion:hover {
  color: #333;
}

/* =========================================================
   BOTONES DE ACCIÓN SUPERIORES
========================================================= */
#top-actions button,
#btn-cercanos,
#btn-toggle-cluster,
#btn-restaurar,
#btn-tema,
#btn-toggle-sidebar,
#btn-destacados {
  height: 42px;
  width: 42px;
  border: none;
  border-radius: 6px;
  font-size: 18px;
  background-color: #e9ecef;
  color: #333;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, transform 0.1s ease;
}

#top-actions button:hover {
  background-color: #d6d8db;
  transform: scale(1.05);
}

#btn-destacados.active i {
  color: #ff8c00;
}

/* =========================================================
   ICONOS LEAFLET PERSONALIZADOS
========================================================= */
.custom-fa-icon {
  text-align: center;
  font-size: 2rem;
  line-height: 1;
}

.custom-fa-icon.destacado i {
  color: #ff8c00;
  text-shadow: 0 0 4px #000;
}

.custom-fa-icon.resaltado i {
  color: #0067d5;
}

/* =========================================================
   LISTADO (SIDEBAR)
========================================================= */


#sidebar-derecho.oculto {
  display: none;
}

#comercioList {
  flex: 1;
  list-style: none;
  padding: 12px;
  margin: 0;
  overflow-y: auto;
}

#comercioList li {
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-bottom: 10px;
  padding: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

#comercioList li:hover {
  background: #f1f1f1;
}

.li-titulo {
  font-weight: 600;
  margin-bottom: 4px;
}

.li-sub {
  font-size: 0.9rem;
  opacity: 0.85;
}

.btn-cerrar-sidebar {
  position: absolute;
  top: 10px;
  right: 10px;
  background: transparent;
  border: none;
  font-size: 20px;
  color: #666;
  cursor: pointer;
  transition: color 0.2s;
}

.btn-cerrar-sidebar:hover {
  color: #333;
}

/* =========================================================
   CONTROLES SUPERIORES
========================================================= */
#top-controls {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: rgba(255, 255, 255, 0.9);
  padding: 12px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  z-index: 1001;
}

/* =========================================================
   TEMA OSCURO
========================================================= */
.dark-theme {
  background-color: #1e1e1e;
  color: #f1f1f1;
}

.dark-theme #top-controls,
.dark-theme #sidebar-derecho {
  background-color: rgba(30, 30, 30, 0.95);
}

.dark-theme .control-estandar,
.dark-theme .input-con-boton input {
  background-color: #3a3a3a;
  border-color: #555;
  color: #f1f1f1;
}

.dark-theme #top-actions button {
  background-color: #444;
  color: #f1f1f1;
}

.dark-theme #comercioList li {
  background-color: #2c2c2c;
  border-color: #444;
  color: #f1f1f1;
}

.dark-theme #comercioList li:hover {
  background-color: #3a3a3a;
}
/* ===== Reubicación de los botones + y - de Leaflet ===== */
.leaflet-top.leaflet-left {
  top: 80px; /* espacio debajo de tu barra de controles */
  left: 10px; /* margen lateral */
  z-index: 1002;
}
.leaflet-control-zoom{
  display: none;
}
#btn-fullscreen.active i {
  color: #007bff;
}

/* =========================================================
   RESPONSIVE
========================================================= */
@media (max-width: 1024px) {
  #top-controls {
    flex-wrap: wrap;
    width: 80%;
    gap: 6px;
    padding: 8px;
    top: 60px;
  }

  #top-controls input,
  #top-controls select,
  #top-controls button {
    height: 38px;
    font-size: 13px;
  }
}
/* =========================
   📱 Responsive móvil (≤768px)
   ========================= */
@media (max-width: 768px) {
  .leaflet-top.leaflet-left {
    top: auto;
    bottom: 120px; /* se ubican arriba del menú inferior municipal */
    left: 10px;
  }
  /* Contenedor principal del menú */
  #top-controls {
    position: static;
    transform: none;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 8px 10px;
    gap: 10px;
    box-sizing: border-box;
    overflow-x: hidden; /* evita desbordes */
    border-radius: 0;
  }

  /* Asegura que los elementos hijos nunca excedan el ancho */
  #top-controls > * {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* Inputs y select al 100% */
  #searchBox,
  #rubroFilter,
  .input-con-boton,
  .input-con-boton input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    height: 42px;
    font-size: 14px;
  }

  /* Ajuste del select para texto largo */
  #rubroFilter {
    white-space: normal;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  /* Grupo de botones al final, también dentro del ancho */
  #top-actions {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    gap: 6px;
    box-sizing: border-box;
  }

  #top-actions button {
    flex: 1 1 0;
    height: 44px;
    font-size: 18px;
    border-radius: 8px;
  }

  /* Sidebar adaptado */
  #sidebar-derecho {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 30vh;
    border-radius:0;
    padding: 10px;
    z-index: 500;
  }

  /* Evita que el contenedor principal cree desbordes */
  .principal {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  #map {
    flex: 1 1 auto;
    width: 100%;
    max-width: 100%;
  }
  
  /* === Contenedor general del sidebar === */
  aside#sidebar-derecho {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    height: auto !important;
    max-height: 40vh !important;
    background: rgba(255, 255, 255, 0.97) !important;
    border-radius: 14px 14px 0 0 !important;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.2) !important;
    display: block !important;
    overflow: hidden !important;
    z-index: 1000 !important;
  }

  /* === Lista horizontal scrollable === */
  aside#sidebar-derecho ul#comercioList {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
    gap: 10px !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    padding: 12px 16px !important;
    margin: 0 !important;
    list-style: none !important;
    scroll-snap-type: x mandatory !important;
    -webkit-overflow-scrolling: touch !important;
  }

  /* === Cada comercio como tarjeta === */
  aside#sidebar-derecho ul#comercioList li {
    flex: 0 0 240px !important;
    max-width: 240px !important;
    background: #fff !important;
    border: 1px solid #ccc !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    padding: 10px !important;
    scroll-snap-align: start !important;
    transition: all 0.2s ease !important;
  }

  aside#sidebar-derecho ul#comercioList li:hover {
    transform: translateY(-3px) !important;
  }

  /* === Textos dentro de las tarjetas === */
  aside#sidebar-derecho ul#comercioList li .li-titulo {
    font-weight: 600 !important;
    font-size: 1rem !important;
    margin-bottom: 4px !important;
  }

  aside#sidebar-derecho ul#comercioList li p,
  aside#sidebar-derecho ul#comercioList li a {
    font-size: 0.85rem !important;
    line-height: 1.3 !important;
  }

  /* === Ocultar botón cerrar === */
  aside#sidebar-derecho .btn-cerrar-sidebar {
    display: none !important;
  }
}
/* === Forzar menú horizontal en escritorio === */
@media (min-width: 769px) {
  #top-controls {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    gap: 10px;
  }

  #top-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  /* Asegura que los botones tengan tamaño consistente */
  #top-actions button {
    width: 42px;
    height: 42px;
    font-size: 18px;
  }

  /* Ajusta los inputs para que mantengan proporción */
  #searchBox,
  #rubroFilter,
  .input-con-boton {
    width: 240px;
  }
    /* El contenedor pasa a la parte inferior */
  #sidebar-derecho {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: auto;
    max-height: 40vh; /* controla altura máxima */
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    overflow: hidden;
    z-index: 500;
  }

  /* El listado se muestra como carrusel horizontal */
  #comercioList {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 16px;
    margin: 0;
    list-style: none;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }

  /* Cada comercio como una tarjeta compacta */
  #comercioList li {
    flex: 0 0 260px; /* ancho de cada tarjeta */
    min-width: 240px;
    max-width: 280px;
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px;
    scroll-snap-align: start;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  #comercioList li:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
  }

  /* Ajustes de texto y enlaces dentro de las tarjetas */
  #comercioList li .li-titulo {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 4px;
  }

  #comercioList li p,
  #comercioList li a {
    font-size: 0.9rem;
    line-height: 1.3;
  }

  /* Oculta el botón cerrar (innecesario en mobile horizontal) */
  .btn-cerrar-sidebar {
    display: none;
  }
}
/* Tutorial Overlay */
.tutorial-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  font-family: 'Raleway', sans-serif;
}

.tutorial-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.tutorial-modal {
  background: white;
  border-radius: 20px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  position: relative;
  z-index: 100000;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(50px) scale(0.9);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.tutorial-header {
  text-align: center;
  margin-bottom: 25px;
  border-bottom: 2px solid #f0f0f0;
  padding-bottom: 15px;
}

.tutorial-header h2 {
  color: #2c3e50;
  margin: 0 0 8px 0;
  font-weight: 700;
  font-size: 1.8rem;
}

.tutorial-header span {
  color: #7f8c8d;
  font-size: 0.9rem;
  font-weight: 500;
}

.tutorial-content {
  margin: 25px 0;
  min-height: 200px;
  display: flex;
  align-items: center;
}

.tutorial-slide {
  text-align: center;
  animation: slideFade 0.4s ease;
}

@keyframes slideFade {
  from { 
    opacity: 0;
    transform: translateX(20px);
  }
  to { 
    opacity: 1;
    transform: translateX(0);
  }
}

.tutorial-icon {
  font-size: 3rem;
  margin-bottom: 20px;
  display: block;
}

.tutorial-slide h3 {
  color: #2c3e50;
  margin: 0 0 15px 0;
  font-size: 1.4rem;
  font-weight: 600;
}

.tutorial-slide p {
  color: #5d6d7e;
  line-height: 1.6;
  margin: 0;
  font-size: 1rem;
}

.tutorial-element-highlight {
  position: fixed;
  border: 3px solid #3498db;
  border-radius: 8px;
  pointer-events: none;
  z-index: 9998;
  transition: all 0.3s ease;
}
@keyframes pulseHighlight {
  0%, 100% { border-color: #3498db; }
  50% { border-color: #2980b9; }
}

.tutorial-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 25px;
}

.tutorial-btn {
  padding: 12px 24px;
  border: none;
  border-radius: 10px;
  font-family: 'Raleway', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.tutorial-btn-primary {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
}

.tutorial-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.tutorial-btn-secondary {
  background: #ecf0f1;
  color: #2c3e50;
}

.tutorial-btn-secondary:hover {
  background: #d5dbdb;
  transform: translateY(-2px);
}

.tutorial-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.tutorial-progress {
  flex: 1;
  max-width: 200px;
}

.progress-bar {
  background: #ecf0f1;
  border-radius: 10px;
  height: 6px;
  overflow: hidden;
}

.progress-fill {
  background: linear-gradient(135deg, #3498db, #2980b9);
  height: 100%;
  border-radius: 10px;
  transition: width 0.3s ease;
  width: 0%;
}

.tutorial-skip {
  position: absolute;
  top: 15px;
  right: 20px;
  background: none;
  border: none;
  color: #7f8c8d;
  cursor: pointer;
  font-size: 0.9rem;
  transition: color 0.3s ease;
}

.tutorial-skip:hover {
  color: #e74c3c;
}

/* Botón para reactivar tutorial */
#btn-tutorial {
  position: fixed;
  bottom: 0px;
  right: 0px;
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: white;
  border: none;
  border-radius: 5px;
  width: 150px;
  height: 40px;
  cursor: pointer;
  z-index: 9999;
  font-size: 1.5rem;
  transition: all 0.3s ease;
}

#btn-tutorial:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 25px rgba(52, 152, 219, 0.6);
}

/* Responsive */
@media (max-width: 768px) {
  .tutorial-modal {
    padding: 20px;
    margin: 20px;
  }
  
  .tutorial-footer {
    flex-direction: column;
    gap: 15px;
  }
  
  .tutorial-progress {
    max-width: none;
    width: 100%;
  }
  
  .tutorial-btn {
    width: 100%;
    justify-content: center;
  }
  
  #btn-tutorial {
    bottom: 10px;
    right: 10px;
    width: 50px;
    height: 50px;
    font-size: 1.3rem;
  }
}