/***** ========== ESTILOS (Mobile-first) ========== *****/

/* Layout base */
footer {
  display: none !important;
}

.empresas-mapa-container {
  display: flex;
  flex-direction: column;
  /* mobile first */
  width: 100%;
  height: auto;
  background: #fff;
  border-top: 1px solid #ddd;
  font-family: 'Aller', system-ui, sans-serif;
}

.empresas-sidebar {
  order: 1;
  flex: none;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-bottom: 1px solid #ddd;
  /* en desktop pasa a right */
  padding: 15px 20px;
  overflow-y: auto;
  z-index: 3;
  box-shadow: 2px 0 8px rgba(0, 0, 0, .05);
}

.empresas-sidebar h2,
.empresas-sidebar h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 15px;
  color: #97B129;
  letter-spacing: .03em;
  animation: fadeInUp .6s ease forwards;
}

/* Título + botón atrás */
.empresas-sidebar h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.empresas-sidebar .btn-back-sidebar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: #B6BE1A;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  transition: background .3s ease, transform .2s ease, box-shadow .2s ease;
}

.empresas-sidebar .btn-back-sidebar:hover {
  transform: scale(1.05);
}

.empresas-sidebar .btn-back-sidebar:focus {
  outline: 2px solid rgba(182, 190, 26, .6);
  outline-offset: 2px;
}

.empresas-sidebar .btn-back-sidebar img {
  width: 18px;
  height: 18px;
  display: block;
  filter: brightness(0) invert(1);
}

.empresas-sidebar .title-text {
  text-transform: uppercase;
}

.empresas-sidebar label {
  display: block;
  margin-bottom: 12px;
  font-size: .95rem;
  color: #555;
  user-select: none;
}

.empresas-sidebar input,
.empresas-sidebar select {
  width: 100%;
  padding: 8px 12px;
  font-size: 1rem;
  border: 1.8px solid #bbb;
  border-radius: 6px;
  background: #fff;
  box-shadow: inset 0 2px 5px rgb(0 0 0 / 5%);
  transition: border-color .3s ease, box-shadow .3s ease;
}

.empresas-sidebar input:focus,
.empresas-sidebar select:focus {
  outline: none;
}

.filtros-basicos {
  display: flex;
  flex-flow: column nowrap;
  gap: 20px;
}

.filtros-basicos-row {
  display: flex;
  flex-flow: row wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.filtros-basicos-row label input,
.filtros-basicos-row label select {
  margin-top: 10px;
}

/* Filtros avanzados (details/summary) */
.filtros-avanzados {
  margin-top: 20px;
  border-top: 1px solid #ddd;
  padding-top: 12px;
}

.filtros-avanzados summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 12px;
  list-style: none;
  position: relative;
  padding-left: 22px;
  color: #B6BE1A;
  user-select: none;
  transition: color .3s ease;
  animation: fadeInLeft .5s ease forwards;
}

.filtros-avanzados summary::marker {
  content: '';
}

.filtros-avanzados summary::before {
  content: "▶";
  position: absolute;
  left: 0;
  top: -.2rem;
  font-size: 1.1rem;
  color: #B6BE1A;
  transition: transform .3s ease;
}

.filtros-avanzados[open] summary::before {
  transform: rotate(90deg);
}

.filtros-avanzados label {
  margin-left: 14px;
  font-weight: 500;
  font-size: .9rem;
}

/* Toolbar de chips (filtros rápidos) */
.cat-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 10px 0 16px;
}

.cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1.8px solid #bbb;
  border-radius: 999px;
  background: #fff;
  font-size: .9rem;
  cursor: pointer;
  user-select: none;
  transition: border-color .2s ease, box-shadow .2s ease, transform .15s ease;
}

.cat-chip img {
  width: 16px;
  height: 16px;
  display: block;
}

.cat-chip.is-on {
  border-color: #97B129;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
}

.cat-chip:active {
  transform: scale(.98);
}

/* Acordeones por categoría */
.cat-acc {
  border: 1px solid #ddd;
  border-radius: 12px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
  background: #fff;
  animation: fadeInUp .3s ease both;
}

.cat-acc[open] {
  box-shadow: 0 6px 14px rgba(0, 0, 0, .07);
}

.cat-acc summary {
  list-style: none;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  user-select: none;
}

.cat-acc summary::-webkit-details-marker {
  display: none;
}

.cat-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cat-bullet {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cat-color, #bbb);
  flex: 0 0 12px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .04) inset;
}

.cat-name {
  font-weight: 700;
  color: #333;
  letter-spacing: .02em;
}

.cat-count {
  font-size: .85rem;
  color: #666;
}

.cat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cat-eye {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f6f6f6;
  border: 1px solid #e2e2e2;
  cursor: pointer;
  transition: background .2s ease, transform .1s ease, border-color .2s ease;
}

.cat-eye:hover {
  background: #efefef;
  border-color: #d5d5d5;
}

.cat-eye:active {
  transform: scale(.96);
}

.cat-eye img {
  width: 20px;
  height: 20px;
}

.cat-caret {
  width: 18px;
  height: 18px;
  opacity: .75;
  transform: rotate(0);
  transition: transform .2s ease;
}

.cat-acc[open] .cat-caret {
  transform: rotate(90deg);
}

.cat-accordion__panel {
  padding: 12px 14px;
  border-top: 1px solid #eee;
  background: #fff;
}

.cat-accordion__panel ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cat-empty {
  font-size: .9rem;
  color: #777;
  padding: 6px 2px;
}

/* Listado */
#lista-empresas {
  list-style: none;
  padding: 0;
  margin: 0;
}

#lista-empresas li {
  padding: 10px 14px;
  margin-bottom: 12px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  transition: box-shadow .3s ease, transform .25s ease;
  animation: fadeInUp .4s ease forwards;
}

/* Card */
.empresa-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid #eee;
  background: #fff;
  transition: background .2s;
  animation: fadeInUp .4s ease forwards;
}

.empresa-card:hover {
  transform: translateX(6px);
}

.img-wrapper {
  position: relative;
  display: block;
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 4px;
  background: #f0f0f0;
}

.img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  filter: blur(10px);
  transition: opacity .4s ease-in-out, filter .4s ease-in-out;
}

.img-wrapper img.loaded {
  opacity: 1;
  filter: blur(0);
}

.img-wrapper.has-icon {
  background: var(--icon-bg, #B6BE1A);
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-wrapper.has-icon .cat-icon-img {
  /* width: 44px; */
  height: 44px;
  object-fit: contain;
  filter: brightness(0) invert(1);
  opacity: 1;
  display: block;
}

.empresa-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.empresa-card-title {
  display: none;
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #333;
}

.empresa-card-title-item {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: #333;
}

.empresa-card-excerpt {
  margin-bottom: 8px;
}

.empresa-card-excerpt a {
  font-size: .85rem;
  color: #666;
}

.empresa-card-excerpt h2 {
  margin-top: 0;
}

.empresa-card-links {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  justify-content: flex-start;
}

.empresa-card-button,
.empresas-sidebar .button {
  display: block;
  width: fit-content;
  /* margin-left: auto; */
  text-align: center;
  padding: 6px 8px;
  font-size: .85rem !important;
  background: #B6BE1A;
  color: #fff !important;
  border-radius: 6px;
  text-decoration: none !important;
  transition: background .3s ease, transform .2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .4);
  border-color: transparent;
}

.empresas-sidebar .button.load {
  display: none;
}

.empresa-card-button:hover,
.empresas-sidebar .button:hover {
  transform: scale(1.05);
}

/* Mapa */
#map-container {
  position: relative;
  flex: 1;
  height: 100%;
  z-index: 1;
}

#map {
  width: 100%;
  height: 70vh;
}

/* mobile default */

/* Loader del mapa */
#map-loader {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.78);
  z-index: 10;
}

#map-loader .spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: -20px 0 0 -20px;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(182, 190, 26, 0.25);
  border-top-color: #B6BE1A;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Sidebar loader */
.sidebar-loader {
  display: none;
  padding: 30px 0;
  text-align: center;
}

.sidebar-loader .spinner {
  display: inline-block;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(182, 190, 26, 0.25);
  border-top-color: #B6BE1A;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* Skeleton para listado */
.skeleton-card {
  display: flex;
  gap: 10px;
  padding: 10px !important;
}

.skeleton-image,
.skeleton-line {
  background: linear-gradient(90deg, #eee 25%, #ddd 50%, #eee 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.2s infinite;
}

.skeleton-image {
  width: 100px;
  height: 100px;
  border-radius: 4px;
  flex-shrink: 0;
}

.skeleton-lines {
  flex: 1;
}

.skeleton-line {
  height: 12px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-line.short {
  width: 40%;
}

.skeleton-line.medium {
  width: 70%;
}

/* Scrollbar sidebar */
.empresas-sidebar::-webkit-scrollbar {
  width: 8px;
}

.empresas-sidebar::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 8px;
}

.empresas-sidebar::-webkit-scrollbar-thumb {
  background: #bbb;
  border-radius: 8px;
  transition: background-color .3s ease;
}

.empresas-sidebar::-webkit-scrollbar-thumb:hover {
  background: #888;
}

/* Leaflet UI */
.leaflet-tooltip.map-tooltip {
  background: var(--map-color);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .2);
  pointer-events: none;
  font: 16px/1.2 system-ui, sans-serif;
  text-transform: uppercase;
}

.leaflet-container .popup-poi strong {
  font-weight: 600;
}

.poi-chip .poi-chip-inner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--chip-color, #333);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}

.poi-chip img {
  width: 16px;
  height: 16px;
  display: block;
}

/* Control: filtros */
.leaflet-control.custom-filters {
  position: relative;
}

.leaflet-control.custom-filters .filters-panel {
  display: none;
  position: absolute;
  top: 32px;
  left: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 10px 12px;
  min-width: 220px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .15);
  z-index: 1000;
}

.leaflet-control.custom-filters.open .filters-panel {
  display: block;
}

.filters-panel .filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.filters-panel .filters-close {
  background: none;
  border: 0;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.filters-panel label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
}

/* Leyenda */
.leaflet-control.legend-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .1);
  font-size: 12px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 3px 0;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--c, #666);
  display: inline-block;
}

/* Transiciones para polígonos */
.smooth-transition {
  transition: opacity .2s, fill-opacity .2s;
}

/* Círculo del cluster (usa --c para el color) */
.marker-cluster .mcircle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--c, #666);
  border: 3px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.marker-cluster .mcircle span {
  color: #fff;
  font: 600 13px/1 system-ui, sans-serif;
}

/* Tamaños (opcional, ya los diferenciamos por clase marker-cluster-small/medium/large) */
.marker-cluster-small .mcircle {
  transform: scale(0.9);
}

.marker-cluster-medium .mcircle {
  transform: scale(1.0);
}

.marker-cluster-large .mcircle {
  transform: scale(1.1);
}

.marker-cluster div {
  margin-left: 0 !important;
  margin-top: 0 !important;
}

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
  background-color: transparent !important;
}


/***** ========== MEDIA QUERIES (Desktop ≥ 769px) ========== *****/

body:not(:has(#wpadminbar)) .empresas-mapa-container {
  height: calc(100vh - 140px);
}

/* CON admin bar: desktop/tablet (>=783px) → 32px extra */
@media (min-width: 783px) {
  body:has(#wpadminbar) .empresas-mapa-container {
    height: calc(100vh - (140px + 32px));
    /* 172px */
  }
}

/* CON admin bar: móvil (<=782px) → 46px extra */
@media (max-width: 782px) {
  body:has(#wpadminbar) .empresas-mapa-container {
    height: calc(100vh - (140px + 46px));
    /* 186px */
  }
}

@media (min-width:769px) {
  .empresas-mapa-container {
    flex-direction: row;
    height: calc(100vh - 140px);
    /* margin-top: 160px; */
  }

  .empresas-sidebar {
    order: initial;
    flex: 0 0 30%;
    border-bottom: none;
    border-right: 1px solid #ddd;
    padding: 20px 25px;
  }

  #map {
    height: 100%;
  }

  /* Fila de filtros básicos: 60/40 en desktop */
  .filtros-basicos-row label:first-of-type {
    flex: 1 0 calc(60% - 5px);
  }

  .filtros-basicos-row label:last-of-type {
    flex: 1 0 calc(40% - 5px);
  }
}

/***** ========== ANIMACIONES & EFECTOS ========== *****/

/* Mapa shimmer (usado por skeleton cards) */
@keyframes shimmerAnim {
  100% {
    background-position-x: -200%;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Skeleton */
@keyframes skeleton-loading {
  to {
    background-position: -200% 0;
  }
}

/* Entradas */
@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInLeft {
  0% {
    opacity: 0;
    transform: translateX(-12px);
  }

  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* NUEVOS ESTILOS POPUP */

.poi-chip-inner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #fff;
  border: 3px solid var(--chip-color, #1e6ad8);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .15);
}

.poi-chip-inner img {
  width: 16px;
  height: 16px;
  display: block;
}

/* Leaflet popup */
.leaflet-popup.popup-modern .leaflet-popup-content-wrapper {
  padding: 0;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .18);
  border: 1px solid rgba(30, 106, 216, .15);
}

.leaflet-popup.popup-modern .leaflet-popup-content {
  margin: 0;
}

.leaflet-popup.popup-modern .leaflet-popup-tip {
  background: #fff;
  border: 1px solid rgba(30, 106, 216, .15);
}

/* Tarjeta del popup */
.pm-card {
  overflow: hidden;
  border-radius: 14px;
  background: #fff;
}

.pm-cover {
  display: block;
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #eef5ff;
}

.pm-cover-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 110px;
  background: var(--icon-bg, #B6BE1A);
}

.pm-cover-icon img {
  width: 52px;
  height: 52px;
  filter: brightness(0) invert(1);
  display: block;
}

.pm-body {
  padding: 14px 14px 16px;
}

.pm-title {
  margin: 0 0 10px;
  font-size: 16px;
  line-height: 1.25;
  font-weight: 700;
  color: #143d7a;
}

.pm-btns {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.pm-btn {
  width: fit-content !important;
  display: inline-block;
  font-size: 13px;
  line-height: 1;
  padding: 10px 12px;
  border-radius: 10px;
  background: #B6BE1A;
  color: #fff !important;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(30, 106, 216, .25);
  transition: transform .15s ease, box-shadow .15s ease;
}

.pm-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(30, 106, 216, .3);
}

.leaflet-popup-content-wrapper {
  padding: 0px !important;
}

.leaflet-popup-content {
  margin: 0px !important;
}

@media (max-width: 900px) {
  .pm-cover { height: 90px; }
  .pm-cover-icon { height: 90px; }
  .pm-cover-icon img { width: 36px; height: 36px; }
  .pm-body {
    padding: 8px 10px 10px !important;
  }

  .pm-title {
    font-size: 13px !important;
    margin-bottom: 6px !important;
  }

  .pm-btn {
    font-size: 11px !important;
    padding: 4px 8px !important;
  }
}

.cat-acc.is-locked>summary {
  cursor: default;
}

.cat-acc.is-locked summary .cat-caret {
  display: none !important;
}
