html {
  font-size: 100%;
}

[hidden] {
  display: none !important;
}

body {
  background-image: url("../images/page_background.jpg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: white;
  font-family: Arial, sans-serif;
  margin: 0;
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

body.modal-aperto {
  overflow: hidden;
}

main {
  background-color: rgba(0, 0, 0, 0.6);
  flex: 1;
  width: 100%;
  margin: 0 auto;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 10;
}

header {
  align-items: center;
  background-color: rgb(50, 120, 120);
  display: flex;
  gap: 15px;
  justify-content: center;
  padding: 6px 15px;
}

/* Altezza fissa: stemmi di proporzioni diverse occupano sempre lo stesso spazio nella barra */
header img {
  flex-shrink: 0;
  height: 42px;
  width: auto;
}

.city-name {
  font-size: 28px;
  font-weight: bold;
  line-height: 1.15;
}

nav {
  background-color: rgb(255, 255, 255);
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 10px 0 5px 0;
}

nav a.attivo {
  font-weight: bold;
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-top: 30px;
  width: 100%;
}

a {
  color: rgb(0, 0, 0);
}

caption {
  font-size: 20px;
  margin-bottom: 15px;
  font-weight: bold;
}

.weather-table,
.stats-table {
  background-color: rgba(218, 230, 234, 0.75);
  border-collapse: collapse;
  border-radius: 5px;
  margin: auto;
  margin-bottom: 30px;
  overflow: hidden;
  table-layout: fixed;
  text-align: left;
  width: 75%;
}

.stats-table {
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}

.stats-table thead th:first-child {
  border-top-left-radius: 5px;
}

.stats-table thead th:last-child {
  border-top-right-radius: 5px;
}

th {
  background-color: rgb(50, 120, 120) !important;
  text-align: center;
}

td {
  color: rgb(0, 0, 0);
  padding: 10px;
  vertical-align: middle;
  text-align: center;
}

label {
  align-items: center;
  font-size: 18px;
}

.date-label {
  display: block;
}

input[type="datetime-local"] {
  padding: 12px 16px;
  font-size: 18px;
  border: 3px solid #59c1d4a4;
  border-radius: 5px;
  background: #f9fafc;
  color: #000000;
  transition: all 0.3s ease;
}

input[type="datetime-local"]:hover {
  border-color: #59c2d4;
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  background-image: url("../images/calendario.png");
  cursor: pointer;
  filter: invert(0.2);
}

input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  filter: invert(0);
}

.date-container {
  display: grid;
  column-gap: 10px;
  grid-template-columns: 1fr 1fr;
}

.date-container input {
  margin-top: 10px;
  padding: 5px;
}

#date-btns {
  display: flex;
  justify-content: left;
  column-gap: 20px;
}

#date-btns button {
  background: #59c2d4;
  border-radius: 5px;
  color: white;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  height: 35px;
  margin-top: 15px;
  min-width: 100px;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    box-shadow 120ms ease;
}

.label,
.stats_label {
  font-weight: bold;
}

.etichetta {
  align-items: center;
  display: flex;
  gap: 10px;
}

.etichetta img {
  width: 28px;
  height: 28px;
}

.status {
  font-size: 18px;
  white-space: nowrap;
}

.stats-btn-wrap {
  display: flex;
  justify-content: center;
  margin: 20px;
}

.stats-btn + .stats-btn {
  margin-left: 15px;
}

.g_btn,
.stats-btn {
  background: rgb(50, 120, 120);
  color: rgb(255, 255, 255);
  height: 35px;
  min-width: auto;
  min-height: auto;
  border-radius: 5px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 120ms ease,
    filter 120ms ease,
    box-shadow 120ms ease;
}

.g_btn:hover,
.stats-btn:hover,
#date-btns button:hover,
.preset-btn:hover {
  filter: brightness(1.1);
}

.g_btn:active,
.stats-btn:active,
#date-btns button:active,
.preset-btn:active {
  transform: scale(0.96);
}

.stats-btn.attivo,
.preset-btn.attivo {
  background: rgb(30, 80, 80);
  color: rgb(255, 255, 255);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
}

.g_btn img,
#date-btns button img {
  display: none;
  width: 100%;
  height: 100%;
}

.hid-txt {
  display: none;
}

/* Messaggi */
.avviso {
  background: rgba(190, 30, 30, 0.9);
  border-radius: 5px;
  margin: 20px auto 0 auto;
  padding: 10px;
  text-align: center;
  width: 75%;
}

.caricamento,
.ultimo-agg {
  font-size: 15px;
  text-align: center;
}

.ultimo-agg {
  margin: -10px 0 20px 0;
  opacity: 0.85;
}

#stats-wrap {
  margin-top: 10px;
}

/* Modale grafico fullscreen */
#chart-modal {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: flex-start;
  z-index: 999;
  overflow-y: auto;
}

#chart-container {
  background: rgba(255, 255, 255, 0.95);
  padding: 30px 20px 20px 20px;
  border-radius: 10px;
  color: black;
  width: 90%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 40px auto;
}

#chart-title {
  font-size: 22px;
  margin: 0 0 10px 0;
  text-align: center;
}

/* Chart.js con maintainAspectRatio: false richiede un contenitore dedicato con altezza definita */
.chart-box {
  position: relative;
  width: 95%;
  height: 400px;
  margin-bottom: 25px;
}

#chart-box2 {
  height: 350px;
}

/* Avviso sopra il grafico: testo centrato e bordo uniforme (una striscia solo a sinistra sarebbe sbilanciata) */
.chart-msg {
  background: #fff6d6;
  border: 2px solid #e0b100;
  border-radius: 8px;
  margin: 0 0 15px 0;
  padding: 8px 14px;
  text-align: center;
}

.chart-hint {
  color: #555;
  font-size: 14px;
  margin: -10px 0 15px 0;
  text-align: center;
}

/* Pulsanti del periodo rapido: 4 in fila, su schermi stretti 2 righe da 2 (invece di 3+1) */
.preset-btns {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, auto);
  justify-content: center;
  margin-bottom: 15px;
}

@media (max-width: 520px) {
  .preset-btns {
    grid-template-columns: repeat(2, 130px);
  }
}

.preset-btn {
  background: rgb(255, 255, 255);
  border: 2px solid rgb(50, 120, 120);
  border-radius: 5px;
  color: rgb(50, 120, 120);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  padding: 4px 12px;
}

footer {
  align-items: center;
  background-color: rgba(255, 255, 255, 0.8);
  color: rgb(0, 0, 0);
  display: flex;
  flex-direction: column;
  padding-bottom: 5px;
}

footer h3 {
  margin: 10px 0 0 0;
  text-align: center;
}

footer img {
  margin-top: 15px;
  width: 200px;
}

/* Index */
@media (max-width: 768px) {
  .status {
    display: none;
  }

  .date-container {
    grid-template-columns: 1fr;
    row-gap: 10px;
  }

  .date-container :nth-child(3) {
    grid-row: 2;
  }

  .date-container input {
    margin: 0;
  }

  .chart-box {
    width: 100%;
    height: 320px;
  }

  #chart-box2 {
    height: 280px;
  }

  #chart-container {
    width: 95%;
    padding: 20px 10px;
    margin: 15px auto;
  }
}

/* Index */
@media (max-width: 480px) {
  .weather-table {
    width: 80%;
  }

  .label .etichetta {
    justify-content: center; /* centra l'icona quando il testo è nascosto */
  }

  .label_txt {
    display: none;
  }

  .g_btn {
    background-color: rgb(255, 255, 255);
    min-width: 40px;
    min-height: 40px;
  }

  #date-btns button {
    background-color: rgb(255, 255, 255);
    min-width: 50px;
    min-height: 50px;
  }

  .g_btn_txt,
  #date-btns span {
    display: none;
  }

  .g_btn img,
  #date-btns button img {
    display: inline-block;
  }

  header {
    gap: 10px;
  }

  header img {
    height: 46px;
  }

  /* I nomi lunghi vanno su due righe: centrate e un po' più piccole */
  .city-name {
    font-size: 20px;
    text-align: center;
  }
}

/* Stats */
@media (max-width: 768px) {
  .stats_label .etichetta {
    justify-content: center; /* centra l'icona quando il testo è nascosto */
  }

  .stats_label_txt {
    display: none;
  }
}

/* Stats */
@media (max-width: 480px) {
  .stats-table {
    table-layout: auto;
  }

  .stats-btn {
    height: auto;
  }

  .show-txt {
    display: none;
  }

  .hid-txt {
    display: inline-block;
  }
}

/* Impostazioni (pannello amministrazione) */
.admin-bar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin: 20px auto 0 auto;
  width: 90%;
}

.admin-bar h1 {
  font-size: 26px;
  margin: 0;
}

.admin-esci {
  background: rgb(255, 255, 255);
  border: 2px solid rgb(50, 120, 120);
  border-radius: 5px;
  color: rgb(50, 120, 120);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  padding: 5px 14px;
}

.board-grid {
  display: grid;
  gap: 15px;
  grid-template-columns: repeat(2, 1fr);
  margin: 20px auto 30px auto;
  width: 90%;
}

.board-card {
  background-color: rgba(255, 255, 255, 0.9);
  border-radius: 10px;
  color: rgb(0, 0, 0);
  overflow: hidden;
  padding-bottom: 10px;
}

.board-card h2 {
  background: rgb(50, 120, 120);
  color: rgb(255, 255, 255);
  margin: 0 0 15px 0;
  padding: 8px 15px;
}

.board-card.nascosta h2 {
  background: rgb(120, 120, 120);
}

.board-card.nascosta h2::after {
  content: " (nascosta)";
  font-size: 16px;
  font-weight: normal;
}

.board-locazione {
  align-items: center;
  display: flex;
  gap: 10px;
  padding: 0 15px 10px 15px;
}

.board-locazione label {
  font-size: 20px;
  font-weight: bold;
}

.board-locazione input {
  border: 1px solid #b3b3b3;
  border-radius: 5px;
  flex: 1;
  font-size: 16px;
  min-width: 0;
  padding: 6px 8px;
}

.board-modifica {
  background: rgb(50, 120, 120);
  border: none;
  border-radius: 5px;
  color: rgb(255, 255, 255);
  cursor: pointer;
  font-size: 16px;
  font-weight: 600;
  padding: 7px 12px;
}

.board-modifica:disabled {
  opacity: 0.6;
}

.board-check {
  align-items: center;
  cursor: pointer;
  display: flex;
  font-size: 20px;
  font-weight: bold;
  gap: 10px;
  padding: 7px 15px;
}

.board-check:hover {
  background: rgba(50, 120, 120, 0.08);
}

.board-check input {
  accent-color: rgb(50, 120, 120);
  cursor: pointer;
  flex-shrink: 0;
  height: 26px;
  margin: 0;
  width: 26px;
}

.board-check img {
  height: 28px;
  width: 28px;
}

.board-home {
  font-size: 21px;
}

.divisore {
  align-items: center;
  color: #555;
  display: flex;
  font-size: 15px;
  gap: 8px;
  margin: 10px 0 5px 0;
}

.divisore::before,
.divisore::after {
  background: #a0a0a0;
  content: "";
  height: 1px;
}

.divisore::before {
  width: 30px;
}

.divisore::after {
  flex: 1;
}

.board-esito {
  color: rgb(20, 130, 50);
  font-weight: bold;
  margin: 5px 15px 0 15px;
  min-height: 1.2em;
}

.board-esito.errore {
  color: rgb(200, 0, 0);
}

@media (max-width: 768px) {
  .board-grid {
    grid-template-columns: 1fr;
    width: 95%;
  }

  .board-locazione {
    flex-wrap: wrap;
  }

  .board-locazione label {
    width: 100%;
  }

  .board-check,
  .board-home {
    font-size: 18px;
  }
}

/* Impostazioni - schermata di accesso */
.login-wrap {
  display: flex;
  justify-content: center;
  padding: 50px 15px;
}

.login-card {
  background: rgb(255, 255, 255);
  border-radius: 14px;
  border-top: 6px solid rgb(50, 120, 120);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  color: rgb(30, 40, 40);
  display: flex;
  flex-direction: column;
  max-width: 400px;
  padding: 30px 32px 24px 32px;
  width: 100%;
}

.login-icona {
  align-items: center;
  align-self: center;
  background: rgba(50, 120, 120, 0.12);
  border-radius: 50%;
  color: rgb(50, 120, 120);
  display: flex;
  height: 68px;
  justify-content: center;
  margin-bottom: 12px;
  width: 68px;
}

.login-card h1 {
  font-size: 26px;
  margin: 0;
  text-align: center;
}

.login-sottotitolo {
  color: #666;
  font-size: 15px;
  margin: 6px 0 26px 0;
  text-align: center;
}

.login-card label {
  font-size: 15px;
  font-weight: bold;
  margin-bottom: 6px;
}

.login-campo {
  position: relative;
}

.login-campo input {
  border: 2px solid #cfd8d8;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 17px;
  padding: 12px 48px 12px 14px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  width: 100%;
}

.login-campo input:focus {
  border-color: rgb(50, 120, 120);
  box-shadow: 0 0 0 4px rgba(50, 120, 120, 0.18);
  outline: none;
}

.login-occhio {
  align-items: center;
  background: none;
  border: none;
  border-radius: 6px;
  color: #8a9999;
  cursor: pointer;
  display: flex;
  height: 36px;
  justify-content: center;
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
}

.login-occhio:hover,
.login-occhio.attivo {
  color: rgb(50, 120, 120);
}

.login-errore {
  background: #fdecec;
  border-left: 4px solid rgb(200, 40, 40);
  border-radius: 6px;
  color: rgb(160, 20, 20);
  font-size: 15px;
  margin: 14px 0 0 0;
  padding: 10px 12px;
}

.login-btn {
  background: rgb(50, 120, 120);
  border: none;
  border-radius: 8px;
  color: rgb(255, 255, 255);
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  margin-top: 20px;
  padding: 12px;
  transition: background 150ms ease, transform 100ms ease;
}

.login-btn:hover {
  background: rgb(38, 100, 100);
}

.login-btn:active {
  transform: scale(0.98);
}

.login-btn:disabled {
  cursor: wait;
  opacity: 0.7;
}

.login-indietro {
  align-self: center;
  color: rgb(50, 120, 120);
  font-size: 15px;
  margin-top: 18px;
  text-decoration: none;
}

.login-indietro:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  .login-wrap {
    padding: 30px 12px;
  }

  .login-card {
    padding: 24px 20px 20px 20px;
  }
}

/* Icona dell'occhio: aperto con il codice nascosto, barrato con il codice visibile */
.login-occhio .occhio-barrato,
.login-occhio.attivo .occhio-aperto {
  display: none;
}

.login-occhio.attivo .occhio-barrato {
  display: block;
}

/* Credito dello stemma (licenza) nel footer */
.credito {
  color: #555;
  font-size: 11px;
  margin-top: 4px;
  text-decoration: none;
}

.credito:hover {
  text-decoration: underline;
}

/* Qualità dell'aria (riga in fondo alla tabella della stazione) */
.etichetta img.faccina {
  height: 34px;
  width: 34px;
}

.faccina.spenta {
  filter: grayscale(1);
  opacity: 0.45;
}

.aria-livello {
  border-radius: 14px;
  color: rgb(255, 255, 255);
  display: inline-block;
  font-weight: bold;
  padding: 4px 14px;
}

.aria-1 {
  background: rgb(46, 157, 79);
}

.aria-2 {
  background: rgb(124, 170, 36);
}

.aria-3 {
  background: rgb(222, 127, 20);
}

.aria-4 {
  background: rgb(198, 40, 40);
}

.aria-nd {
  background: rgb(130, 130, 130);
}

.aria-info {
  color: rgb(70, 70, 70);
  font-size: 15px;
}
