/* ═══════════════════════════════════════════════════════════════
   ApuliaOne — esplora.css (v4 — "map first")
   Mobile: mappa protagonista + bottom bar stato +
           card quasi fullscreen con X sovrimpressa
   Desktop: lista | mappa + card flottante da destra/basso
═══════════════════════════════════════════════════════════════ */

@import url('https://unpkg.com/leaflet@1.9.4/dist/leaflet.css');


/* ─────────────────────────────────────────────
   FILTER BAR — sticky sotto header
   ───────────────────────────────────────────── */
.filter-wrap {
  background: var(--white);
  border-bottom: 1px solid var(--sand);
  padding: 10px 16px;
  position: sticky;
  top: 60px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(11,46,107,0.05);
}
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
.filter-bar::-webkit-scrollbar { display: none; }


/* ─────────────────────────────────────────────
   LAYOUT — la mappa domina
   Mobile: mappa a schermo (meno header/filtri/statusbar)
   ───────────────────────────────────────────── */
.esplora-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  position: relative;
}

.map-wrap {
  position: relative;
  /* 100vh - header 60 - filtri 52 - status bar 54 - bottom nav 70 */
  height: calc(100vh - 60px - 52px - 54px - 70px);
  min-height: 300px;
  flex-shrink: 0;
}
#map { width: 100%; height: 100%; z-index: 1; }

/* Legenda */
.map-legend {
  position: absolute;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  background: rgba(255,255,255,0.95);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(4px);
}
.legend-title {
  font-family: 'Montserrat', sans-serif;
  font-size: 9px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: #bbb; margin-bottom: 6px;
}
.legend-row {
  display: flex; align-items: center; gap: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 11px; font-weight: 600;
  color: var(--navy); margin-bottom: 4px;
}
.legend-row:last-child { margin-bottom: 0; }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.12); flex-shrink: 0;
}
.legend-dot.d-sandy { background: #22c55e; }
.legend-dot.d-rocky { background: #f97316; }
.legend-dot.d-mixed { background: #eab308; }

/* Banner fallback server */
.fallback-banner {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  background: rgba(234,179,8,0.95);
  color: var(--navy);
  font-family: 'Montserrat', sans-serif;
  font-size: 11px; font-weight: 700;
  padding: 6px 14px; border-radius: 20px;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
}


/* ─────────────────────────────────────────────
   STATUS BAR — barra fissa sotto la mappa
   "Nessuna spiaggia selezionata" / nome selezionato
   ───────────────────────────────────────────── */
.status-bar {
  background: var(--navy);
  color: rgba(255,255,255,0.65);
  font-family: 'Montserrat', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 16px;
  text-align: center;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-shrink: 0;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
}


/* ─────────────────────────────────────────────
   CARD LUOGO — quasi fullscreen su mobile
   X sovrimpressa in alto a destra
   ───────────────────────────────────────────── */
.detail-panel {
  position: fixed;
  left: 0; right: 0;
  bottom: -110%;
  top: auto;
  height: calc(100vh - 24px);       /* quasi fullscreen */
  background: var(--white);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: 0 -6px 40px rgba(11,46,107,0.25);
  z-index: 300;                      /* sopra tutto */
  overflow-y: auto;
  transition: bottom 0.35s cubic-bezier(.22,.61,.36,1);
}
.detail-panel.open { bottom: 0; }

/* X di chiusura SOVRIMPRESSA — sempre visibile */
.dp-close-float {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px 12px 0 0;
  z-index: 20;
  background: rgba(255,255,255,0.95);
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  cursor: pointer;
  font-size: 18px;
  color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  backdrop-filter: blur(4px);
  transition: transform 0.15s, background 0.2s;
}
.dp-close-float:hover { transform: scale(1.08); background: var(--white); }

/* Hero card */
.dp-hero {
  height: 200px;
  display: flex;
  align-items: flex-end;
  padding: 16px;
  position: relative;
  margin-top: -52px;   /* la X flotta sopra l'hero */
}
.dp-hero-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(11,46,107,0.6), transparent);
}
.dp-hero-title {
  font-family: 'Montserrat', sans-serif;
  font-weight: 800; font-size: 22px;
  color: var(--white);
  text-shadow: 0 2px 8px rgba(0,0,0,0.4);
  position: relative; z-index: 1;
}
.dp-hero-sub {
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  margin-top: 3px;
  position: relative; z-index: 1;
}

.dp-body { padding: 16px; }

/* Statistiche griglia */
.dp-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 16px;
}
.dp-stat {
  background: var(--beige);
  border-radius: var(--radius-md);
  padding: 11px;
  display: flex; align-items: center; gap: 9px;
}
.ds-icon { font-size: 20px; }
.ds-lbl  { font-size: 10px; color: #aaa; }
.ds-val  {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700; font-size: 13px;
  color: var(--navy);
}

.dp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.dp-sec-lbl {
  font-family: 'Montserrat', sans-serif;
  font-size: 11px; font-weight: 700;
  letter-spacing: 2px; text-transform: uppercase;
  color: #ccc; margin-bottom: 10px;
}

.dp-alert {
  background: #fef3c7;
  border: 1.5px solid #f59e0b;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  font-size: 12px; line-height: 1.6;
  color: #78350f;
  margin-bottom: 14px;
}

.dp-score    { margin-bottom: 16px; }
.dp-desc     { font-size: 13px; line-height: 1.75; color: #555; margin-bottom: 18px; }
.dp-btn-maps { margin-bottom: 8px; }


/* ─────────────────────────────────────────────
   STRIP PREVISIONI 7 GIORNI
   Quadratini scrollabili: giorno, meteo, temp, score
   ───────────────────────────────────────────── */
.forecast-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  margin-bottom: 18px;
}
.forecast-strip::-webkit-scrollbar { display: none; }

.forecast-day {
  flex-shrink: 0;
  width: 84px;
  background: var(--beige);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  text-align: center;
  border: 1.5px solid transparent;
}
.forecast-day.today { border-color: var(--gold); }

.fd-label {
  font-family: 'Montserrat', sans-serif;
  font-size: 10px; font-weight: 700;
  letter-spacing: 0.5px; text-transform: uppercase;
  color: var(--navy);
  margin-bottom: 4px;
}
.fd-icon { font-size: 22px; margin-bottom: 4px; }
.fd-temp {
  font-family: 'Montserrat', sans-serif;
  font-size: 13px; font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
}
/* Score con colore semaforo */
.fd-score {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px; font-weight: 800;
  border-radius: 8px;
  padding: 3px 0;
  color: var(--white);
}
.fd-score.verde  { background: #22c55e; }
.fd-score.giallo { background: #eab308; }
.fd-score.rosso  { background: #ef4444; }

/* Loading strip */
.forecast-loading {
  font-size: 12px;
  color: #aaa;
  padding: 16px;
  text-align: center;
  width: 100%;
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.4; }
}

/* Stati lista (desktop) */
.list-loading {
  text-align: center;
  padding: 24px;
  color: #999;
  font-size: 13px;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  animation: pulse 1.5s ease-in-out infinite;
}
.list-empty { text-align: center; padding: 24px; color: #bbb; }
.list-empty-icon { font-size: 36px; margin-bottom: 10px; }
.list-empty p { font-size: 13px; line-height: 1.6; }


/* ─────────────────────────────────────────────
   LISTA (solo desktop) — riga spiaggia
   ───────────────────────────────────────────── */
.results-list { display: none; }   /* nascosta su mobile */

.srow {
  display: flex; align-items: center; gap: 12px;
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: border-color 0.2s;
}
.srow:hover    { border-color: var(--teal); }
.srow.selected { border-color: var(--gold); background: rgba(214,165,58,0.04); }
.row-dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex-shrink: 0; border: 2px solid rgba(0,0,0,0.10);
}
.srow-content { flex: 1; min-width: 0; }
.row-name {
  font-family: 'Montserrat', sans-serif;
  font-weight: 700; font-size: 13px;
  color: var(--navy);
}
.row-meta  { font-size: 11px; color: #aaa; margin-top: 2px; }
.row-score {
  margin-left: auto;
  font-family: 'Montserrat', sans-serif;
  font-weight: 700; font-size: 13px;
  color: var(--teal); flex-shrink: 0;
}


/* ─────────────────────────────────────────────
   DESKTOP (≥ 860px)
   Lista sinistra | mappa destra
   Card flottante a destra, sale dal basso
   ───────────────────────────────────────────── */
@media (min-width: 860px) {
  .esplora-body {
    flex-direction: row;
    height: calc(100vh - 60px - 52px);
    overflow: hidden;
  }

  .results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 340px;
    flex-shrink: 0;
    order: 1;
    height: 100%;
    overflow-y: auto;
    border-right: 1px solid var(--sand);
    padding: 12px;
    background: var(--beige);
  }

  .map-wrap {
    flex: 1;
    height: 100%;
    order: 2;
    min-height: unset;
  }

  .status-bar { display: none; }   /* non serve su desktop */

  /* Card flottante: a destra, sale dal basso */
  .detail-panel {
    left: auto;
    right: 24px;
    bottom: -110%;
    width: 400px;
    height: calc(100vh - 60px - 52px - 48px);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 50px rgba(11,46,107,0.3);
  }
  .detail-panel.open { bottom: 24px; }
}


/* ─────────────────────────────────────────────
   MOBILE (≤ 599px)
   ───────────────────────────────────────────── */
@media (max-width: 599px) {
  .page-body { padding-bottom: 0; }
  .map-wrap {
    height: calc(100vh - 56px - 52px - 54px - 70px);
    min-height: 280px;
  }
}
