/* ============================================================
   map-v2.css — Stile split-screen mappa (Booking.com style)
   ============================================================ */

/* --- Layout split-screen ----------------------------------- */
.map-wrapper {
  display: flex;
  height: calc(100vh - 56px);   /* altezza viewport meno navbar */
  overflow: hidden;
}

.map-list {
  width: 420px;
  min-width: 340px;
  overflow-y: auto;
  background: #f9fafb;
  border-right: 1px solid #e4e8eb;
  scrollbar-width: thin;
  padding-bottom: 8px;
}

.map-list::-webkit-scrollbar { width: 6px; }
.map-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.map-canvas {
  flex: 1;
  position: relative;
}

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

/* --- Header lista ------------------------------------------ */
.map-list-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, #f8faf8 0%, #fff 100%);
  padding: 18px 20px 14px;
  border-bottom: 1px solid #e4e8eb;
}

.map-list-header h1 {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 3px;
  color: #1a3c34;
  line-height: 1.3;
}

.map-list-header .map-count {
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

.map-back-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #1b5e20;
  text-decoration: none;
  margin-top: 8px;
  font-weight: 600;
  transition: color .15s;
}

.map-back-link:hover { color: #145218; text-decoration: underline; }

/* --- Card struttura ---------------------------------------- */
.map-card {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  margin: 6px 12px;
  border-radius: 12px;
  border: 1px solid #e8ecef;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, transform .15s;
  text-decoration: none;
  color: inherit;
  background: #fff;
}

.map-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
  border-color: #c8d6dc;
  transform: translateY(-1px);
}

.map-card.active {
  border-color: #0071c2;
  box-shadow: 0 0 0 2px rgba(0,113,194,.15), 0 4px 12px rgba(0,0,0,.08);
}

.map-card-img {
  width: 120px;
  height: 96px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  background: #f0f2f4;
}

.map-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}

.map-card-type {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #8b95a0;
  font-weight: 600;
}

.map-card-name {
  font-size: 15px;
  font-weight: 700;
  color: #1a3c34;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.map-card-loc {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 4px;
}

.map-card-price {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  margin-top: auto;
}

.map-card-price .label {
  font-size: 11px;
  color: #8b95a0;
}

.map-card-price .amount {
  font-size: 17px;
  font-weight: 800;
  color: #1b5e20;
}

.map-card-price .currency {
  font-size: 13px;
  font-weight: 600;
  color: #1b5e20;
}

/* --- Marker prezzo sulla mappa (stile Airbnb) -------------- */
.price-marker {
  background: #fff;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 22px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
  text-align: center;
  line-height: 1;
  border: 1.5px solid rgba(0,0,0,.08);
  transition: all .18s ease;
  cursor: pointer;
}

.price-marker:hover {
  background: #1a1a1a;
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
  z-index: 1000 !important;
}

.price-marker.active {
  background: #1b5e20;
  color: #fff;
  border-color: #1b5e20;
  transform: scale(1.08);
  box-shadow: 0 4px 14px rgba(27,94,32,.35);
  z-index: 1000 !important;
}

/* --- Cluster marker ---------------------------------------- */
.cluster-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 800;
  box-shadow: 0 2px 10px rgba(0,0,0,.2);
  border: 3px solid #fff;
  text-align: center;
  line-height: 1;
  transition: transform .15s, box-shadow .15s;
}

.cluster-small {
  width: 40px;
  height: 40px;
  font-size: 13px;
  background: linear-gradient(135deg, #43a047, #2e7d32);
}

.cluster-medium {
  width: 50px;
  height: 50px;
  font-size: 14px;
  background: linear-gradient(135deg, #2e7d32, #1b5e20);
}

.cluster-large {
  width: 60px;
  height: 60px;
  font-size: 16px;
  background: linear-gradient(135deg, #1b5e20, #0d4a14);
}

.cluster-marker:hover {
  transform: scale(1.12);
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}

/* --- Popup Leaflet (card nel popup) ------------------------ */
.ai-popup .leaflet-popup-content-wrapper {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,.18);
  padding: 0;
  overflow: hidden;
}

.ai-popup .leaflet-popup-content {
  margin: 0;
  width: 280px !important;
}

.ai-popup .leaflet-popup-tip {
  background: #fff;
  box-shadow: 0 3px 10px rgba(0,0,0,.12);
}

.ai-popup .leaflet-popup-close-button {
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  background: rgba(255,255,255,.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #333;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  z-index: 10;
}

.popup-card { text-decoration: none; color: inherit; display: block; }

.popup-card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
  background: #f0f2f4;
}

.popup-card-body { padding: 14px 14px 12px; }

.popup-card-type {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #6b7280;
  font-weight: 600;
  margin-bottom: 4px;
}

.popup-card-name {
  font-size: 15px;
  font-weight: 800;
  color: #1a3c34;
  margin-bottom: 3px;
  line-height: 1.3;
}

.popup-card-loc {
  font-size: 12px;
  color: #8b95a0;
  margin-bottom: 10px;
}

.popup-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid #f0f2f4;
}

.popup-card-price {
  font-size: 17px;
  font-weight: 800;
  color: #1b5e20;
}

.popup-card-price small {
  font-size: 11px;
  font-weight: 400;
  color: #8b95a0;
  display: block;
}

.popup-card-cta {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 10px;
  background: #1b5e20;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 13px;
  transition: background .18s, transform .12s;
}

.popup-card-cta:hover { background: #145218; color: #fff; transform: translateY(-1px); }

/* --- Animazione card lista (fade-in + slide-up sfalsato) --- */
@keyframes cardSlideIn {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.map-card-animate {
  opacity: 0;
  animation: cardSlideIn .35s ease-out forwards;
}

/* --- Animazione marker prezzo (drop-in) -------------------- */
@keyframes markerDrop {
  0%   { opacity: 0; transform: translateY(-18px) scale(.7); }
  60%  { opacity: 1; transform: translateY(3px) scale(1.05); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.price-marker-animate {
  opacity: 0;
  animation: markerDrop .4s ease-out forwards;
}

/* --- Pin rosso località cercata ---------------------------- */
.location-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
  animation: pinBounce .6s ease-out;
}

@keyframes pinBounce {
  0%   { opacity: 0; transform: translateY(-30px); }
  50%  { opacity: 1; transform: translateY(4px); }
  70%  { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

.location-pin-label {
  display: block;
  margin-top: 2px;
  background: #e53935;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  letter-spacing: .3px;
}

/* --- Pin utente "Sei qui" (pallino blu pulsante) ----------- */
.user-pin {
  position: relative;
  width: 20px;
  height: 20px;
}

.user-pin-dot {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 12px;
  height: 12px;
  background: #1a73e8;
  border: 2.5px solid #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  z-index: 2;
}

.user-pin-ring {
  position: absolute;
  top: -6px;
  left: -6px;
  width: 32px;
  height: 32px;
  background: rgba(26,115,232,.18);
  border-radius: 50%;
  z-index: 1;
  animation: userPulse 2s ease-out infinite;
}

@keyframes userPulse {
  0%   { transform: scale(.6); opacity: .8; }
  100% { transform: scale(1.8); opacity: 0; }
}

/* --- Strip orizzontale mobile ------------------------------ */
.map-strip-mobile {
  display: none;
}

/* --- Bottone mobile "torna alla lista" --------------------- */
.map-toggle-mobile {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  background: #fff;
  color: #1f2937;
  border: 1px solid #d1d5db;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
  cursor: pointer;
  text-decoration: none;
}

.map-toggle-mobile:hover { background: #f3f4f6; color: #1f2937; text-decoration: none; }

/* --- Toggle "Cerca quando muovo la mappa" ----------------- */
.map-search-toggle {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: #fff;
  padding: 10px 18px;
  border-radius: 28px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  border: 1px solid rgba(0,0,0,.06);
}

.map-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  cursor: pointer;
}

/* Nasconde il checkbox nativo */
.map-toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.map-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

/* Track (sfondo del toggle) */
.map-toggle-track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 22px;
  transition: background .2s ease;
}

/* Pallino */
.map-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .2s ease;
}

/* Stato attivo */
.map-toggle-switch input:checked + .map-toggle-track {
  background: #2e7d32;
}

.map-toggle-switch input:checked + .map-toggle-track::after {
  transform: translateX(18px);
}

.map-loading-spinner {
  display: inline-flex;
  align-items: center;
}

/* --- Footer nella mappa (nascosto su mobile) --------------- */
.map-footer-wrap {
  display: none;
}

/* --- Responsive -------------------------------------------- */
@media (max-width: 768px) {
  .map-wrapper {
    display: block;
    height: calc(100vh - 56px - 104px);
  }

  .map-list { display: none; }

  .map-canvas {
    width: 100%;
    height: 100%;
  }

  .map-toggle-mobile { display: block; bottom: 118px; }

  .map-footer-wrap { display: none; }

  /* Strip orizzontale mobile — più alta e con ombre */
  .map-strip-mobile {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    background: #fff;
    border-top: 1px solid #e4e8eb;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    gap: 8px;
    padding: 10px 10px;
    height: 104px;
    box-shadow: 0 -4px 16px rgba(0,0,0,.12);
    scrollbar-width: none;
  }

  .map-strip-mobile::-webkit-scrollbar { display: none; }

  .map-strip-card {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    scroll-snap-align: start;
    width: 220px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1.5px solid #e8ecef;
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, box-shadow .15s, transform .12s;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
  }

  .map-strip-card.active,
  .map-strip-card:active {
    border-color: #1b5e20;
    box-shadow: 0 0 0 2px rgba(27,94,32,.2), 0 2px 8px rgba(0,0,0,.1);
    transform: translateY(-1px);
  }

  .map-strip-card img {
    width: 68px;
    height: 56px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f0f2f4;
  }

  .map-strip-info {
    min-width: 0;
    flex: 1;
  }

  .map-strip-name {
    font-size: 12.5px;
    font-weight: 700;
    color: #1a3c34;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
  }

  .map-strip-price {
    font-size: 14px;
    font-weight: 800;
    color: #1b5e20;
    margin-top: 3px;
  }
}

/* Desktop: footer visibile sotto la mappa */
@media (min-width: 769px) {
  .map-footer-wrap {
    display: block;
  }
}

/* ============================================================
   v3 — Card arricchita stile Gites/Booking + UX mappa
   ============================================================ */

/* Wrap immagine card per ospitare badge sconto */
.map-card-img-wrap {
  position: relative;
  flex-shrink: 0;
}

/* Badge "%" rosso sulla foto se ci sono offerte attive */
.map-card-discount {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e53935;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(229,57,53,.35);
  letter-spacing: -.5px;
}

/* Riga meta capacità · camere */
.map-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 12px;
  color: #6b7280;
  margin: 2px 0 6px;
}

.map-card-meta span {
  position: relative;
}
.map-card-meta span + span::before {
  content: '·';
  position: absolute;
  left: -8px;
  color: #c8d6dc;
}

/* Footer card: voto + prezzo allineati */
.map-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
}

/* Pillola voto stile Booking */
.map-card-rating {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.map-card-rating-score {
  background: #003580;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 4px 4px 4px 0;
  min-width: 28px;
  text-align: center;
  line-height: 1.1;
}

.map-card-rating-count {
  font-size: 11px;
  color: #6b7280;
}

/* Pulsante "Nascondi mappa" in alto-sx mappa */
.map-hide-btn {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #fff;
  color: #1f2937;
  border: 1px solid rgba(0,0,0,.08);
  padding: 8px 14px;
  border-radius: 24px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
  transition: background .15s, transform .12s;
}

.map-hide-btn:hover {
  background: #f3f4f6;
  color: #1f2937;
  text-decoration: none;
  transform: translateY(-1px);
}

/* Toast "zooma per vedere più offerte" */
.map-zoom-hint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  background: rgba(20, 25, 30, .92);
  color: #fff;
  padding: 10px 18px 10px 16px;
  border-radius: 22px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.3);
  white-space: nowrap;
  animation: zoomHintFade .25s ease-out;
}

@keyframes zoomHintFade {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* "Su richiesta" — fallback prezzo non disponibile */
.map-card-price-empty {
  font-size: 12px;
  font-weight: 600;
  color: #8b95a0;
  font-style: italic;
}

.popup-card-price-empty {
  font-size: 13px;
  font-weight: 600;
  color: #8b95a0;
  font-style: italic;
}

.price-marker:has(:empty),
.price-marker[data-empty="1"] {
  font-size: 11px;
  font-style: italic;
  color: #6b7280;
}

/* Mobile: badge e meta più compatti, nasconde pulsante "nascondi" */
@media (max-width: 768px) {
  .map-hide-btn { display: none; }
  .map-zoom-hint {
    bottom: 116px;
    font-size: 12px;
    padding: 8px 14px;
  }
}
