:root{
  --footer-h: 52px; /* altezza footer, regolabile */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}


/* RESET BASE */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* SFONDO GENERALE PAGINA + BLOCCO SCROLL */
html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f0dabb;
  color: #222;
  overflow: hidden;           /* pagina NON scorre */
}

/* CONTENITORE PRINCIPALE A SCHERMO INTERO */
.page {
  position: relative;
  height: 100vh;
  min-height: 100vh;
  width: 100%;
}

@supports (height: 100dvh) {
  .page {
    height: 100dvh;
    min-height: 100dvh;
  }
}

/* =========================
   HEADER FISSO IN ALTO A DESTRA
   ========================== */
.header {
  position: absolute;
  top: calc(var(--safe-top) + 8px);
  right: 8px;
  left: 8px;
  z-index: 1000;

  display: flex;
  justify-content: flex-end;
  align-items: center;
  pointer-events: none; /* non blocca la mappa */
}

.header-title {
  max-height: 50px;
  height: auto;
  width: auto;
  pointer-events: auto; /* il titolo è comunque cliccabile se serve */
}

/* =========================
   FOOTER FISSO IN BASSO (ICONE SEMPRE VISIBILI)
   ========================== */

.footer {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: 0;

  height: var(--footer-h);

  /* iPhone: lascia SOLO lo spazio necessario alla home bar */
  padding-bottom: var(--safe-bottom);
  background-color: #f0dabb;

  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 14px;
}


/* Gruppo loghi a sinistra */
.footer-logos {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}

/* Loghi (sinistra) */
.footer-logo {
  height: 42px;
  width: auto;
}

.footer-logo-first-two {
  height: 46px;
}

.footer-logo-deleo {
  margin-right: 10px;
}

/* Banner footer allineato al gruppo centrale */
.footer-banner {
  margin-left: 0;
  margin-right: 0;
  margin-bottom: 4px;  /* piccolo spazio dal bordo inferiore */
  height: 44px;        /* leggermente piu grande dei loghi standard */
  width: auto;         /* mantiene proporzioni */
}



/* =========================
   LAYOUT PRINCIPALE (MAPPA + SIDEBAR)
   OCCUPA LO SPAZIO TRA HEADER E FOOTER
   ========================== */

.main-layout {
  position: absolute;
  /* riempi lo schermo ma lascia spazio per header e footer */
  top: calc(var(--safe-top) + 50px);     /* spazio sotto il titolo (ridotto) */
  bottom: calc(var(--footer-h) + var(--safe-bottom)); /* spazio sopra i loghi */
  left: 8px;
  right: 8px;

  display: flex;
  gap: 12px;
}

/* CONTENITORE MAPPA */
.map-wrapper {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
}

/* MAPPA LEAFLET */
#map {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* SIDEBAR SCORREVOLE (UNICA COLONNA DI TASTI) */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;

  overflow-y: auto;   /* SOLO QUI SI SCORRE */
  padding-right: 4px;
}

/* Ogni pulsante è una immagine a tutta larghezza nella colonna */
.sidebar-button {
  width: 100%;
  height: auto;
  cursor: pointer;
  display: block;
}

/* (opzionale) scrollbar sottile per i tasti */
.sidebar::-webkit-scrollbar {
  width: 6px;
}
.sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
}
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 3px;
}

/* =========================
   ORIENTAMENTO: PORTRAIT
   - mappa in alto
   - tasti in basso
   ========================== */
@media (orientation: portrait) {

  .header-title {
    max-height: 40px;
  }

  .footer-logo {
    height: 38px;
  }

  .footer-logo-first-two {
    height: 42px;
  }


  .footer-banner {
    height: 38px;
  }

  .main-layout {
    flex-direction: column; /* mappa sopra, tasti sotto */
  }

  .map-wrapper {
    flex: 1.3;    /* un po' più spazio alla mappa */
  }

  .sidebar {
    flex: 1;      /* occupa lo spazio restante, scorre se non entra */
    align-items: flex-start;      /* centra il contenuto nella colonna */
  }

  .sidebar-button {
      width: 70%;              /* non più 100% */
      max-width: 70%;           /* 🔹 riduci la larghezza (proporzioni ok) */
      height: auto;             /* mantiene proporzioni dell’immagine */
      margin: 4px 0;         /* 🔹 centra orizzontalmente */
      display: block;
  }

}

/* =========================
   ORIENTAMENTO: LANDSCAPE
   - mappa a sinistra
   - tasti a destra
   ========================== */
@media (orientation: landscape) {

  .header-title {
    max-height: 45px;
  }

  .footer-logo {
    height: 40px;
  }

  .footer-logo-first-two {
    height: 44px;
  }

  .footer-banner {
    height: 42px;
  }

  .main-layout {
    flex-direction: row; /* mappa a sinistra, tasti a destra */
  }

  .sidebar {
    width: 230px;     /* colonna verticale a destra */
    max-width: 35%;
  }

  .sidebar-button {
    width: 100%;
    height: auto;
    margin: 0;
  }

}

@media (max-width: 480px) {
  :root {
    --footer-h: 40px;
  }

  .footer {
    left: 4px;
    right: 4px;
    gap: 6px;
  }

  .footer-logos {
    gap: 6px;
    margin-bottom: 2px;
  }

  .footer-logo {
    height: 28px;
  }

  .footer-logo-first-two {
    height: 31px;
  }

  .footer-logo-deleo {
    margin-right: 0;
  }

  .footer-banner {
    height: 30px;
    margin-bottom: 2px;
  }
}

/* POPUP LEAFLET (come prima) */
.leaflet-popup-content {
  font-size: 14px;
  line-height: 1.4;
}

.leaflet-popup-content strong {
  font-size: 15px;
}
