@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@700&display=swap');

/* =========================
   RESET / BASE
========================= */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  max-width: 100%;
  overflow-x: hidden; /* evita “zoom out” por overflow horizontal */
}

:root{
  --tap-min: 44px;
  --tap-min-mobile: 54px;
  --control-radius: 12px;  /* “cuadrado suave” */
  --panel-shadow: 0 6px 16px rgba(0,0,0,.05);
}

/* =========================
   POIs UI (tabs + filtros)
========================= */
.poi-tabs-container {
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}

.poi-tabs {
  display: flex;
  gap: 10px;
}

.poi-tab {
  padding: 10px 18px;
  min-height: var(--tap-min);
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: var(--control-radius);
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.poi-tab.active {
  background-color: #007bff;
  color: #fff;
  border-color: #007bff;
}

.poi-content { display: none; }
.poi-content.active {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.poi-search-container { margin-bottom: 10px; }

.poi-search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  min-height: var(--tap-min);
}

.poi-category-selector { margin-bottom: 10px; }

.poi-category-selector select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background-color: #fff;
  font-size: 14px;
  min-height: var(--tap-min);
}

/* Categorías en resultados */
.poi-category {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  margin-right: 5px;
  background-color: #f0f0f0;
  color: #333;
}

.additional-info {
  font-size: 12px;
  color: #666;
  margin-top: 3px;
}

/* Ajustes específicos restaurantes/hoteles */
#restaurantesTable, #hotelesTable {
  width: 100%;
  border-collapse: collapse;
}

#restaurantesTable tr, #hotelesTable tr { border-bottom: 1px solid #e0e0e0; }
#restaurantesTable tr:last-child, #hotelesTable tr:last-child { border-bottom: none; }

#restaurantesTable .direccion-content { min-width: 250px; }

#restaurantesTable .valoracion {
  display: inline-block;
  background-color: #ffc107;
  color: #000;
  padding: 2px 5px;
  border-radius: 3px;
  font-weight: 700;
  margin-left: 10px;
}

#restaurantesTable .tipo-restaurante {
  display: inline-block;
  background-color: #28a745;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  margin-right: 5px;
}

#hotelesTable .estrellas {
  color: #ffc107;
  font-size: 14px;
  margin-right: 5px;
}

#hotelesTable .precio-noche {
  display: inline-block;
  background-color: #007bff;
  color: #fff;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
}

#restaurantesTable .kmtd,
#hotelesTable .kmtd {
  float: right;
  background-color: #f8f9fa;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

/* =========================
   HEADER
========================= */
header {
  position: relative;
  padding: 10px;
}

.impactante {
  font-family: 'Roboto', sans-serif;
  text-align: center;
  font-weight: 700;
  font-size: 4em;
  color: #2c3e50;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  padding: 0;
}

.telegram-link {
  position: absolute;
  top: 10px;
  right: 10px;
}

.telegram-logo {
  width: 54px;
  height: auto;
}

.apk-link {
  position: absolute;
  top: 10px;
  left: 10px;
}

.apk-logo {
  width: 54px;
  height: auto;
}

/* =========================
   MAP + LAYOUT
========================= */
.results-map-container {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  padding: 0;
  width: min(1560px, 82vw);   /* en desktop se ve como antes, sin romper móviles */
  max-width: 1560px;
  height: 80vh;
  position: relative;
  overflow: hidden;
  z-index: 1;
  margin: 0 auto;
  border-radius: 20px;
  box-shadow: 0 0 16px rgb(240, 240, 240);
  border: 1px solid rgb(240, 240, 240);
}

.results-map-container .col-md-5,
.results-map-container .col-md-7 {
  padding-left: 0;
  padding-right: 0;
  height: 100%;
}

.results-map-container .col-md-7 .p-3 {
  padding: 0 !important;
  height: 100%;
}

.containermap { height: 100%; }

#mapid {
  width: 100%;
  height: 100%;
  min-height: 0; /* evita “alto fijo” que descuadra en algunos dispositivos */
}

/* =========================
   TABLAS / RESULTADOS
========================= */
table {
  width: 100%;
  border-collapse: collapse;
}

.trtabla { border-bottom: 1px solid #ddd; }
.trtabla:last-child { border-bottom: none; }

.selected-row {
  background-color: #f0f8ff;
  border: 1px solid #007bff;
}

.direccion-container {
  display: flex;
  align-items: center;
}

#tab_logo {
  margin-right: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.logomtd {
  width: 35px;
  height: 35px;
  display: block;
}

.direccion-content {
  flex-grow: 1;
  min-width: 0; /* CLAVE: permite encoger dentro del contenedor */
}

.nombrestation {
  font-size: 14px;
  font-weight: 900;
  min-width: 0;
  width: auto;
}

.direccion, .codp, .provin { font-size: 12px; }

.kmtd {
  margin-left: 25px;
  cursor: pointer;
  border-radius: 8px;
  position: static;
  padding: 0;
  font-weight: 600;
  font-size: 15px;
  text-align: start;
  font-family: Verdana;
}

#txcountresultados { font-size: 20px; }

#resultados {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100% - var(--panel-top-h, 260px));
}

/* =========================
   FUEL TYPES
========================= */
#fuelTypes { margin: 20px 0; }

.fuelType {
  padding: 3px 5px;
  margin: 0 1px;
  cursor: pointer;
  display: inline-block;
  border-radius: 5px;
  font-weight: 700;
}

.fuelType.active {
  background-color: #00954f;
  color: #fff;
}

/* Precios en listado */
.price-contenttabla {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 8px;
  font-size: 19px;
  font-weight: 600;
  font-family: Verdana;
  color: #fff;
  margin-bottom: 3px;
}

/* Colores por combustible */
.price-content.gasolina95, .price-contenttabla.gasolina95, .fuelType.SP95, th.trpopupa.gasolina95 { background-color: #007bff !important; }
.price-content.gasoleoA,   .price-contenttabla.gasoleoA,   .fuelType.DieselA, th.trpopupa.gasoleoA { background-color: #6c757d !important; }
.price-content.gasolina98, .price-contenttabla.gasolina98, .fuelType.SP98, th.trpopupa.gasolina98 { background-color: #28a745 !important; }
.price-content.gasoleoPremium, .price-contenttabla.gasoleoPremium, .fuelType.DieselPlus, th.trpopupa.gasoleoPremium { background-color: #dc3545 !important; }
.price-content.gasoleoB, .price-contenttabla.gasoleoB, .fuelType.DieselB, th.trpopupa.gasoleoB { background-color: #17a2b8 !important; }
.price-content.glp, .price-contenttabla.glp, .fuelType.GPL, th.trpopupa.glp { background-color: #ffc107 !important; }

/* =========================
   POPUPS LEAFLET
========================= */
.leaflet-popup-content { width: 250px !important; }

.leaflet-popup-content-wrapper, .leaflet-popup-tip { width: 270px; }
.leaflet-popup-content-wrapper { background-color: #ffffff94; }

.popup {
  font-family: Arial, sans-serif;
  font-size: 14px;
  background-color: #ffffffe0;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  border-color: none;
}

.custom-table2 {
  width: 100%;
  border-collapse: separate;
}

.custom-table td, .custom-table th {
  border: 1px solid #ddd;
  padding: 8px;
}

.imgpopup { width: 100px; height: auto; }

.h2popup {
  font-size: 12px;
  margin: 0;
  font-weight: 900;
}

.dirpopup, .horpopup { font-size: 12px; margin: 0; }

.trpopupa {
  background-color: #f7f7f7;
  text-align: center;
  border-radius: 4px;
  font-size: 12px;
  margin: 0;
  padding: 3px;
  width: 20px;
  font-family: Verdana;
}

.trpopupb td {
  background-color: transparent;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  border-radius: 4px;
}

.abierto {
  font-size: 12px;
  margin: 0;
  background-color: #0EFB64;
  border-radius: 4px;
  padding-right: 1px;
  width: 52px;
  filter: drop-shadow(0px 0px 3px #26ffb69c) drop-shadow(0px 0px 4px #26ffb6d4);
  text-align: center;
}

.cerrado {
  font-size: 12px;
  color: #fff;
  margin: 0;
  background-color: #FB0E0E;
  border-radius: 4px;
  padding-right: 1px;
  width: 52px;
  filter: drop-shadow(0px 0px 3px rgba(0,0,0,0.3)) drop-shadow(0px 0px 4px rgba(0,0,0,0.5));
  text-align: center;
}

/* Links GPS */
.gps-link-container {
  text-align: center;
  margin-top: 10px;
}

.gps-link-container a {
  display: inline-flex;
  align-items: center;
  margin-right: 10px;
  text-decoration: none;
  color: inherit;
  font-size: 16px;
}

.gps-link-container img { margin-right: 5px; }

/* =========================
   MARKERS / SPINNER
========================= */
.custom-icon {
  position: relative;
  display: inline-block;
  background: transparent;
  border: none;
}

.marker-container {
  text-align: center;
  position: relative;
}

.marker-icon { width: 38px; height: auto; }

.price-label {
  background-color: #00954f;
  color: #fff;
  padding: 3px;
  border-radius: 5px;
  font-size: 12px;
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
}

.spinner-container {
  display: flex;
  justify-content: center;
  padding: 20px;
}

.loading-text {
  text-align: center;
  margin-top: 10px;
  color: #007bff;
}

/* Icono activo (dorado) */
.icon-dorado {
  background-color: gold;
  border-radius: 50%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-dorado img {
  width: 24px;
  height: auto;
  filter: drop-shadow(0 0 5px gold);
}

/* =========================
   BARRA SUPERIOR PANEL IZQUIERDO
========================= */
.location-container {
  display: flex;
  border: 2px solid #9e9e9e;
  border-radius: 14px;
  overflow: hidden;
  max-width: 74%;
  box-shadow: 2px 2px 10px #20293115;
  flex: 0 0 75%;
  align-items: center;
  min-height: var(--tap-min);
}

#location {
  min-width: var(--tap-min);
  min-height: var(--tap-min);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0;
  font-size: 2rem;
  color: #6bc2e8;
}

.location-selects {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.custom-button {
  display: inline-flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-align: left;
  margin: 0;
  padding: 10px 14px;
  min-height: var(--tap-min);
  border-radius: var(--control-radius);
  gap: 10px;
  z-index: 1000;
  border: 1px solid #d3d3d3;
  background-color: #ececec;
  filter: drop-shadow(2px 4px 6px #ececec);
  flex: 0 0 25%;
}

.location-container, .custom-button { box-sizing: border-box; }

/* No mates todos los .form-control (rompía selects de categorías). */
.location-container .form-control{
  border: 0;
  box-shadow: none;
  min-height: var(--tap-min);
  padding: 10px 12px;
}

#precioresultcab {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Sticky cabecera del panel */
#col1 .fixed-top-content {
  position: sticky;
  top: 0;
  z-index: 2000;
  background: #fff;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid rgba(0,0,0,.06);
  box-shadow: var(--panel-shadow);
}

/* Para que el highlight no quede “tapado” por la cabecera */
.trtabla { scroll-margin-top: calc(var(--panel-top-h, 260px) + 12px); }

/* Botón flotante (base) */
.btn-floating {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 5000;
  display: none; /* se muestra por media query */
}

.toggle-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.toggle-label{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  user-select: none;
}

.toggle-label input[type="checkbox"]{
  width: 18px;
  height: 18px;
}

.top-panel-toggle{
  min-height: var(--tap-min);
  padding: 10px 14px;
  border-radius: var(--control-radius);
  border: 1px solid rgba(0,0,0,.12);
  box-shadow: 0 2px 8px rgba(0,0,0,.05);
}

/* =========================
   COLLAPSE PANEL SUPERIOR
   - Oculta selects/tabs/filtros y deja solo el toggle-row
========================= */
#col1 .fixed-top-content.is-collapsed {
  /* mantenemos sticky + separación */
  padding: 10px 12px;
  gap: 0;
}

/* Ocultamos TODOS los hijos del panel superior excepto el toggle-container */
#col1 .fixed-top-content.is-collapsed > :not(.toggle-container) {
  display: none !important;
}

/* Micro “header” limpio cuando está colapsado */
#col1 .fixed-top-content.is-collapsed .toggle-container{
  justify-content: space-between;
}


/* =========================
   RESPONSIVE “MÓVIL REAL”
========================= */
@media (max-width: 991.98px) {

  .results-map-container {
    display: block;
    width: 100%;
    max-width: 100%;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    border: 0;
    overflow: hidden;
    height: calc(100dvh - var(--app-header-h, 80px));
  }

  #col1, #col2 {
    width: 100%;
    height: 100%;
    padding: 10px;
    max-width: 100%;
    overflow-x: hidden;
  }

  #col1.d-none, #col2.d-none { display: none !important; }
  #col1.d-block, #col2.d-block { display: block !important; }

  #col2 .p-3 {
    height: 100%;
    padding: 0 !important;
  }

  .containermap { height: 100%; }

  #mapid {
    height: 100%;
    width: 100%;
    min-height: 100%;
  }

  .location-selects {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  .location-container,
  .custom-button {
    width: 100% !important;
    max-width: 100% !important;
    flex: 1 1 auto !important;
  }

  .location-container { overflow: hidden; }

  #precioresultcab {
    flex-wrap: wrap;
    gap: 6px;
  }

  .kmtd {
    margin-left: 0;
    font-size: 13px;
  }

  .direccion-content,
  #contenttabresult {
    white-space: normal !important;
  }

  .direccion-content {
    overflow: hidden !important;
    min-width: 0 !important;
  }

  .direccion-container {
    align-items: flex-start;
    gap: 8px;
  }

  /* fuel types en scroll horizontal */
  #fuelTypes {
    display: flex;
    overflow-x: auto;
    white-space: nowrap;
    padding: 5px;
    margin: 8px 0 12px 0;
    -webkit-overflow-scrolling: touch;
  }

  #fuelTypes span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    padding: 12px 12px;
    min-height: var(--tap-min-mobile);
    border: 1px solid #ddd;
    border-radius: var(--control-radius);
    background-color: #fff;
    cursor: pointer;
    font-size: 15px;
  }

  .impactante { margin-top: 15px; font-size: 30px; }
  #txcountresultados { font-size: 15px; }

  .price-contenttabla { font-size: 15px; }

  #restaurantesTable .direccion-content,
  #hotelesTable .direccion-content {
    min-width: 180px;
  }

  .poi-search-input,
  .poi-category-selector select {
    padding: 12px 12px;
    font-size: 15px;
    min-height: var(--tap-min-mobile);
    border-radius: var(--control-radius);
  }

  .poi-tab{
    min-height: var(--tap-min-mobile);
    padding: 12px 16px;
    font-size: 15px;
    border-radius: var(--control-radius);
  }

  .custom-button{
    min-height: var(--tap-min-mobile);
    padding: 12px 14px;
    font-size: 16px;
    border-radius: var(--control-radius);
  }

  #restaurantes-content .custom-button,
  #hoteles-content .custom-button,
  #pois-content .custom-button{
    margin-bottom: 6px;
  }

  .btn-floating {
    display: block !important;
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 6000;
    padding: 12px 16px;
    border-radius: var(--control-radius);
    font-size: 16px;
  }

  .toggle-label{
    font-size: 15px;
  }

  .top-panel-toggle{
    min-height: var(--tap-min-mobile);
    padding: 12px 14px;
    font-size: 16px;
  }
}

/* =========================
   DESKTOP (a partir de 992px)
========================= */
@media (min-width: 992px) {
  .btn-floating { display: none !important; }

  #col1 { padding: 15px; }
  #col2 { display: block; }
}
