/* =====================================================
   Locations Manager – Public Styles
   Primary color: #E15C5C
   ===================================================== */

:root {
  --lm-primary:    #E15C5C;
  --lm-primary-dk: #c94040;
  --lm-primary-lt: #fef2f2;
  --lm-text:       #1f2937;
  --lm-muted:      #6b7280;
  --lm-border:     #e5e7eb;
  --lm-radius:     14px;
  --lm-shadow:     0 4px 24px rgba(0,0,0,.10);
}

/* ---- Search ---- */
.lm-wrapper { font-family: inherit; }

.lm-search-bar {
  max-width: 560px;
  margin: 0 auto 2.5rem;
}
.lm-search-inner {
  position: relative;
  display: flex;
  align-items: center;
}
.lm-search-icon {
  position: absolute;
  left: 16px;
  width: 20px;
  color: var(--lm-muted);
  pointer-events: none;
}
#lm-search-input {
  width: 100%;
  padding: 14px 20px 14px 48px;
  border: 2px solid var(--lm-border);
  border-radius: 50px;
  font-size: 1rem;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  background: #fff;
}
#lm-search-input:focus {
  border-color: var(--lm-primary);
  box-shadow: 0 0 0 4px rgba(225,92,92,.12);
}

/* ---- Grid ---- */
.lm-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.75rem;
}

/* Carte nascoste (show more/less) */
.lm-grid .lm-card-item.lm-hidden {
  display: none;
}

/* Pulsante Show More / Show Less */
.lm-show-more-wrap {
  text-align: center;
  margin-top: 2rem;
}
.lm-btn-show-more {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: var(--lm-primary);
  border: 2px solid var(--lm-primary);
  border-radius: 50px;
  padding: 11px 32px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, color .2s, transform .15s;
  letter-spacing: .02em;
}
.lm-btn-show-more:hover {
  background: var(--lm-primary);
  color: #fff;
  transform: scale(1.03);
}
.lm-btn-show-more svg {
  transition: transform .3s;
}
.lm-btn-show-more.is-expanded svg {
  transform: rotate(180deg);
}

/* ---- Card ---- */
.lm-card-item {
  background: #fff;
  border-radius: var(--lm-radius);
  box-shadow: var(--lm-shadow);
  overflow: hidden;
  transition: transform .25s, box-shadow .25s;
  cursor: pointer;
}
.lm-card-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(225,92,92,.18);
}
.lm-card-image {
  position: relative;
  height: 200px;
  background: #f3f4f6;
  overflow: hidden;
}
.lm-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s;
}
.lm-card-item:hover .lm-card-image img { transform: scale(1.05); }
.lm-card-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 3rem;
  color: #d1d5db;
}
.lm-card-assoc {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(255,255,255,.92);
  border-radius: 8px;
  padding: 4px 8px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--lm-text);
  backdrop-filter: blur(4px);
}
.lm-card-assoc img { height: 22px; object-fit: contain; }
.lm-card-content { padding: 1.2rem 1.4rem 1.4rem; }
.lm-card-title {
  margin: 0 0 .5rem;
  font-size: 1.15rem;
  color: var(--lm-text);
}
.lm-card-desc {
  margin: 0 0 1rem;
  font-size: .9rem;
  color: var(--lm-muted);
  line-height: 1.5;
}
.lm-btn-explore {
  background: var(--lm-primary);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: 9px 20px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .15s;
  width: 50%;
}
.lm-btn-explore:hover {
  background: var(--lm-primary-dk);
  transform: scale(1.02);
}

/* ---- No results ---- */
.lm-no-results {
  text-align: center;
  color: var(--lm-muted);
  grid-column: 1/-1;
  padding: 3rem;
  font-size: 1.05rem;
}

/* ---- Modal ---- */
.lm-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
}
.lm-modal.is-open { display: flex; align-items: center; justify-content: center; }
.lm-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(3px);
  z-index: 1; /* SOTTO il container */
}
.lm-modal-container {
  position: relative;
  z-index: 2; /* SOPRA l'overlay */
  width: 95vw;
  max-width: 1050px;
  max-height: 90vh;
  background: #fff;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
}
.lm-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 999;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .2s;
}
.lm-modal-close:hover { background: #fff; }
.lm-modal-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Left side */
.lm-modal-left {
  flex: 0 0 50%;
  overflow-y: auto;
  padding: 0;
}
.lm-modal-left::-webkit-scrollbar { width: 5px; }
.lm-modal-left::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 4px; }

/* Right side – map */
.lm-modal-right { flex: 0 0 50%; }
#lm-modal-map { width: 100%; height: 100%; min-height: 400px; }

/* Modal inner content */
.lm-modal-hero {
  height: 200px;
  background-size: cover;
  background-position: center;
}
.lm-modal-title {
  padding: 1.2rem 1.5rem .4rem;
  margin: 0;
  font-size: 1.5rem;
  color: var(--lm-text);
}
.lm-modal-assoc-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 1.5rem .8rem;
  background: var(--lm-primary-lt);
  border: 1px solid rgba(225,92,92,.2);
  padding: 4px 12px;
  border-radius: 50px;
  font-size: .82rem;
  color: var(--lm-primary-dk);
}
.lm-modal-assoc-badge img { height: 18px; object-fit: contain; }
.lm-modal-assoc-badge a { color: inherit; text-decoration: none; font-weight: 600; }

.lm-modal-section {
  padding: .8rem 1.5rem;
  border-top: 1px solid var(--lm-border);
}
.lm-modal-section:first-child { border-top: none; }
.lm-modal-section h3 {
  margin: 0 0 .75rem;
  font-size: .95rem;
  color: var(--lm-primary);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.lm-modal-desc { font-size: .95rem; color: var(--lm-muted); line-height: 1.6; }

.lm-group { margin-bottom: .8rem; }
.lm-group-label {
  display: inline-block;
  background: var(--lm-primary);
  color: #fff;
  border-radius: 50px;
  padding: 2px 12px;
  font-size: .78rem;
  font-weight: 700;
  margin-bottom: .5rem;
  letter-spacing: .03em;
}
.lm-item-card {
  background: #f9fafb;
  border: 1px solid var(--lm-border);
  border-radius: 10px;
  margin-bottom: .5rem;
  font-size: .88rem;
  overflow: hidden;
  transition: border-color .2s, box-shadow .2s;
}
.lm-item-card.has-coords { border-color: var(--lm-border); }
.lm-item-card--active {
  border-color: var(--lm-primary) !important;
  box-shadow: 0 0 0 2px rgba(225,92,92,.2);
}

/* Zona superiore: cliccabile per centrare la mappa */
.lm-item-card-body {
  padding: .65rem .9rem .5rem;
  cursor: default;
}
.lm-item-card.has-coords .lm-item-card-body {
  cursor: pointer;
}
.lm-item-card.has-coords .lm-item-card-body:hover {
  background: var(--lm-primary-lt);
}
.lm-item-card strong { color: var(--lm-text); display: block; margin-bottom: .15rem; }
.lm-item-addr { margin: .1rem 0 .3rem; color: var(--lm-muted); font-size: .82rem; }
.lm-map-hint {
  display: inline-block;
  font-size: .75rem;
  color: var(--lm-primary);
  opacity: .75;
  margin-top: .1rem;
}
.lm-item-card.has-coords .lm-item-card-body:hover .lm-map-hint { opacity: 1; }

/* Zona inferiore: link – nessun handler JS, sempre cliccabili */
.lm-item-links {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  padding: .45rem .9rem .65rem;
  border-top: 1px solid var(--lm-border);
  background: #fff;
  position: relative;
  z-index: 5; /* sempre sopra tutto */
  pointer-events: all;
}
.lm-link-maps, .lm-link-phone {
  font-size: .8rem;
  text-decoration: none;
  padding: 3px 12px;
  border-radius: 50px;
  font-weight: 600;
  border: 1.5px solid;
  cursor: pointer;
  transition: background .15s, color .15s;
  position: relative;
  z-index: 5;
  pointer-events: all;
  -webkit-user-select: none;
}
.lm-link-maps { color: var(--lm-primary); border-color: var(--lm-primary); }
.lm-link-maps:hover { background: var(--lm-primary); color: #fff; }
.lm-link-phone { color: #059669; border-color: #059669; }
.lm-link-phone:hover { background: #059669; color: #fff; }

/* Leaflet popup */
.lm-popup-accomm .leaflet-popup-content-wrapper { border-top: 3px solid var(--lm-primary); }
.lm-popup-pov .leaflet-popup-content-wrapper { border-top: 3px solid #3b82f6; }

/* ---- Associations strip ---- */
.lm-associations {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
}
.lm-assoc-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  text-align: center;
}
.lm-assoc-item img {
  height: 48px;
  object-fit: contain;
  filter: grayscale(.3);
  transition: filter .2s, transform .2s;
}
.lm-assoc-item img:hover { filter: none; transform: scale(1.06); }
.lm-assoc-item a, .lm-assoc-item span {
  font-size: .82rem;
  color: var(--lm-muted);
  text-decoration: none;
  font-weight: 500;
}
.lm-assoc-item a:hover { color: var(--lm-primary); }

/* ---- Responsive ---- */
/* =====================================================
   MOBILE  (≤ 768px)
   Layout a tab: [Info] [Mappa] fissi in basso
   ===================================================== */
@media (max-width: 900px) {
  .lm-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {

  /* Griglia */
  .lm-grid { grid-template-columns: 1fr; }

  /* Modale occupa tutto lo schermo */
  .lm-modal-container {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  /* Body diventa stack verticale con overflow nascosto */
  .lm-modal-body {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    position: relative;
  }

  /* Pannello info e mappa: uno alla volta, full-height */
  .lm-modal-left,
  .lm-modal-right {
    position: absolute;
    inset: 0;
    width: 100%;
    flex: none;
    transition: transform .3s ease, opacity .3s ease;
  }

  .lm-modal-left {
    overflow-y: auto;
    background: #fff;
    transform: translateX(0);
    opacity: 1;
    z-index: 2;
  }

  .lm-modal-right {
    transform: translateX(100%);
    opacity: 0;
    z-index: 1;
  }

  /* Quando la mappa è attiva */
  .lm-modal-body.show-map .lm-modal-left {
    transform: translateX(-100%);
    opacity: 0;
  }
  .lm-modal-body.show-map .lm-modal-right {
    transform: translateX(0);
    opacity: 1;
    z-index: 2;
  }

  /* Mappa full height */
  #lm-modal-map {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  /* Tab bar fissa in basso */
  .lm-tab-bar {
    display: flex;
    border-top: 1px solid var(--lm-border);
    background: #fff;
    flex-shrink: 0;
    z-index: 10;
  }

  .lm-tab-btn {
    flex: 1;
    padding: 14px 8px;
    border: none;
    background: none;
    font-size: .95rem;
    font-weight: 600;
    color: var(--lm-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-top: 3px solid transparent;
    transition: color .2s, border-color .2s;
  }

  .lm-tab-btn.active {
    border-top-color: var(--lm-primary);
  }

  /* Hero più compatta */
  .lm-modal-hero { height: 140px; }

  /* Pulsante chiudi più grande per mobile */
  .lm-modal-close {
    top: 10px;
    right: 10px;
    width: 40px;
    height: 40px;
    font-size: 1.1rem;
  }
}

/* Desktop: tab bar nascosta */
@media (min-width: 769px) {
  .lm-tab-bar { display: none; }
}

/* Card attiva (selezionata sulla mappa) */
.lm-item-card--active {
  border-color: var(--lm-primary) !important;
  background: var(--lm-primary-lt) !important;
  box-shadow: 0 0 0 2px rgba(225,92,92,.25);
}

/* ---- Card counts badges ---- */
.lm-card-counts {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-bottom: .9rem;
}
.lm-count-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  padding: 3px 10px;
  border-radius: 50px;
  font-weight: 500;
}
.lm-count-badge strong { font-weight: 700; }
.lm-count-accomm {
  background: var(--lm-primary-lt);
  color: var(--lm-primary-dk);
  border: 1px solid rgba(225,92,92,.2);
}
.lm-count-pov {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}
.lm-count-empty {
  font-size: .78rem;
  color: var(--lm-muted);
  font-style: italic;
}
