/* =========================
   BASE
========================= */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  min-width: 320px;
  background: #eaf3fb;
  color: #333;
}

header {
  padding: 25px;
  text-align: center;
  background: #1f4e79;
  color: #eaf3fb;
}

button,
input,
select {
  font: inherit;
}

/* =========================
   PULSANTI E GRUPPI
========================= */

.menu {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 40px;
  margin-top: 100px;
}

.menu-btn,
.dettaglio-card-btn,
.popup-btn {
  border: 0;
  border-radius: 10px;
  background: #1f4e79;
  color: #eaf3fb;
  font-weight: bold;
  cursor: pointer;
  transition:
    background-color 0.25s,
    transform 0.25s,
    opacity 0.25s;
}

.menu-btn {
  width: 250px;
  height: 80px;
  font-size: 24px;
}

.menu-btn:hover,
.dettaglio-card-btn:hover,
.popup-btn:hover {
  background-color: #2d6aa3;
  transform: scale(1.04);
}

.menu-btn:active,
.dettaglio-card-btn:active,
.popup-btn:active {
  transform: scale(0.98);
}

.menu-btn:disabled {
  background: #9aa9b6;
  cursor: not-allowed;
  transform: none;
  opacity: 0.7;
}

.menu-btn:disabled:hover {
  background: #9aa9b6;
  transform: none;
}

.button-group {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 30px;
  width: 100%;
  margin-top: 40px;
}

.button-group .menu-btn {
  width: 200px;
  height: 65px;
  font-size: 22px;
}

.logout-btn {
  background: #d32f2f;
}

.logout-btn:hover {
  background: #b71c1c;
}

/* =========================
   HOME E LOGO
========================= */

.logo-container {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 60px;
}

.logo {
  width: 100%;
  max-width: 550px;
  height: auto;
  border-radius: 10px;
}

/* =========================
   CONTENITORI GENERALI
========================= */

.admin-container {
  width: 90%;
  max-width: 1200px;
  margin: 40px auto;
}

.admin-menu {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 40px;
}

.admin-content {
  min-height: 400px;
  padding: 30px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

.admin-content h2 {
  margin-bottom: 20px;
  color: #1f4e79;
}

.home-btn {
  display: flex;
  justify-content: center;
  margin-top: 30px;
}

/* =========================
   LOGIN E PASSWORD
========================= */

.login-box form {
  width: 100%;
}

.login-container {
  min-height: calc(100vh - 100px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px 16px;
}

.login-box {
  width: 90%;
  max-width: 600px;
  min-height: 400px;
  padding: 60px;
  border-radius: 20px;
  background: #eaf3fb;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 35px;
}

.login-box h2 {
  color: #1f4e79;
  font-size: 36px;
}

.password-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.password-input {
  width: 100%;
  min-width: 0;
  height: 65px;
  padding: 15px 58px 15px 20px;
  border: 2px solid #1f4e79;
  border-radius: 10px;
  font-size: 24px;
}

.eye,
.eye-button {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  cursor: pointer;
}

.eye {
  font-size: 30px;
}

.eye-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  outline: none;
  background: transparent;
  font-size: 1.2rem;

  display: flex;
  align-items: center;
  justify-content: center;
}

.eye-button:hover {
  background: rgba(31, 78, 121, 0.08);
}

.eye-button:focus-visible {
  outline: 2px solid currentColor;
}

.eye-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* =========================
   POPUP RESPONSIVE
========================= */

.popup {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;

  justify-content: center;
  align-items: center;

  padding: 16px;
  background: rgba(0, 0, 0, 0.5);
}

.popup-content {
  width: min(100%, 420px);
  max-height: calc(100vh - 32px);
  padding: 28px 22px;
  overflow-y: auto;

  border-radius: 12px;
  background: white;
  text-align: center;
}

.popup-content p {
  margin: 0 0 22px;
  color: #333;
  font-size: 24px;
  font-weight: 300;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.popup-content .popup-btn {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 55px;
  padding: 12px 18px;
  margin: 0;
  font-size: 22px;
}

/* =========================
   OPERATORE
========================= */

.luce-btn,
.gas-btn {
  background-size: cover;
  background-position: center;
  color: white;
}

.luce-btn {
  background-image:
    linear-gradient(rgba(255, 193, 7, 0.75), rgba(255, 193, 7, 0.75)),
    url("../img/lampadina.png");
}

.gas-btn {
  background-image:
    linear-gradient(rgba(220, 50, 30, 0.75), rgba(220, 50, 30, 0.75)),
    url("../img/fiamma.png");
}

.luce-btn:hover {
  background-image:
    linear-gradient(rgba(255, 193, 7, 0.85), rgba(255, 193, 7, 0.85)),
    url("../img/lampadina.png");
}

.gas-btn:hover {
  background-image:
    linear-gradient(rgba(220, 50, 30, 0.85), rgba(220, 50, 30, 0.85)),
    url("../img/fiamma.png");
}

.menu-btn:focus-visible,
.dettaglio-card-btn:focus-visible,
.popup-btn:focus-visible {
  outline: 3px solid #f4b400;
  outline-offset: 3px;
}

/* =========================
   FORM E SELECT
========================= */

.select-box {
  width: 100%;
  height: 60px;
  padding: 0 15px;
  border: 2px solid #1f4e79;
  border-radius: 10px;
  background: white;
  color: #333;
  font-size: 20px;
  cursor: pointer;
}

.select-box:focus-visible,
.form-grid input:focus-visible,
.password-input:focus-visible {
  outline: 3px solid rgba(45, 106, 163, 0.3);
  outline-offset: 2px;
  border-color: #2d6aa3;
}

.gestione-box {
  margin: 30px 0;
}

.gestione-box label {
  display: block;
  margin-bottom: 10px;
  color: #1f4e79;
  font-size: 22px;
  font-weight: bold;
}

#contenutoGestione {
  margin-top: 40px;
}

.form-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  align-items: center;
}

.form-grid label {
  color: #1f4e79;
  font-size: 20px;
  font-weight: bold;
}

.form-grid input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 10px 15px;
  border: 2px solid #1f4e79;
  border-radius: 8px;
  font-size: 18px;
}

.form-title {
  margin-bottom: 30px;
  color: #1f4e79;
  text-align: center;
}

/* =========================
   RICERCA AMMINISTRATORE
========================= */

.ricerca-actions {
  width: 100%;
  margin-top: 40px;

  display: flex;
  flex-direction: column;
  gap: 25px;
}

.ricerca-actions .button-group {
  margin-top: 0;
}

.ricerca-actions-superiori {
  padding-bottom: 25px;
  border-bottom: 2px solid rgba(31, 78, 121, 0.2);
}

/* =========================
   PROMOZIONI E PREZZI MEDI
========================= */

.promozione-pannelli,
.prezzi-medi-pannelli {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
  margin: 30px 0 50px;
}

.promozione-pannello,
.prezzo-medio-pannello {
  min-height: 150px;
  padding: 25px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 15px;

  border: 2px solid #1f4e79;
  border-radius: 12px;
  background: #eaf3fb;
  text-align: center;
}

.prezzo-medio-pannello {
  min-height: 165px;
  gap: 12px;
}

.promozione-pannello-titolo,
.prezzo-medio-titolo {
  color: #333;
  font-size: 20px;
}

.promozione-pannello strong,
.prezzo-medio-pannello strong {
  color: #1f4e79;
  font-size: 30px;
}

.prezzo-medio-pannello strong {
  font-size: 31px;
}

.prezzo-medio-unita {
  color: #555;
  font-size: 17px;
  font-weight: bold;
}

.nuova-promozione-box,
.prezzi-medi-form-box {
  margin-top: 30px;
}

.nuova-promozione-box h2,
.prezzi-medi-form-box h2 {
  margin-bottom: 30px;
}

.promozioni-actions,
.prezzi-medi-actions {
  margin-top: 40px;
}

/* =========================
   PREVENTIVO
========================= */

#titoloPreventivo {
  text-transform: uppercase;
}

.preventivo-content {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.preventivo-content h2 {
  margin-bottom: 35px;
  text-align: center;
}

#formDatiPreventivo {
  width: 100%;
}

.input-unita {
  position: relative;
  width: 100%;
}

.input-unita input {
  width: 100%;
  padding-right: 85px;
}

.input-unita span {
  position: absolute;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);

  color: #1f4e79;
  font-size: 18px;
  font-weight: bold;
  pointer-events: none;
}

.preventivo-actions {
  margin-top: 40px;
}

/* =========================
   RISULTATI
========================= */

.risultati-container,
.dettaglio-container {
  max-width: 1000px;
}

.riepilogo-preventivo {
  margin-bottom: 45px;
}

.riepilogo-preventivo h2,
.risultati-offerte h2 {
  margin-bottom: 30px;
  color: #1f4e79;
  text-align: center;
}

.riepilogo-grid,
.risultato-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 25px;
}

.riepilogo-elemento,
.risultato-pannello {
  min-height: 125px;
  padding: 20px;

  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;

  border: 2px solid #1f4e79;
  border-radius: 12px;
  background: #eaf3fb;
  text-align: center;
}

.riepilogo-etichetta,
.risultato-pannello span {
  color: #333;
  font-size: 18px;
}

.riepilogo-elemento strong,
.risultato-pannello strong {
  color: #1f4e79;
  font-size: 25px;
}

.risultato-pannello {
  min-height: 140px;
  gap: 15px;
}

.risultato-pannello strong {
  font-size: 28px;
}

.risultati-offerte {
  margin-top: 30px;
}

.lista-risultati {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.risultato-card {
  padding: 30px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.12);
}

.risultato-card-intestazione {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 28px;
}

.posizione-card {
  width: 46px;
  height: 46px;
  flex-shrink: 0;

  display: flex;
  justify-content: center;
  align-items: center;

  border-radius: 50%;
  background: #1f4e79;
  color: white;
  font-size: 21px;
  font-weight: bold;
}

.nome-offerta-card {
  color: #1f4e79;
  font-size: 27px;
}

.risultato-card-dati {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 25px;
  margin-bottom: 28px;
}

.risultato-card-dato {
  padding: 20px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;

  border-radius: 10px;
  background: #eaf3fb;
  text-align: center;
}

.risultato-card-dato span {
  color: #333;
  font-size: 18px;
}

.risultato-card-dato strong {
  color: #1f4e79;
  font-size: 26px;
}

.risparmio-negativo {
  color: #b3261e !important;
}

.risparmio-positivo {
  color: #18763c !important;
}

.risultato-card-azioni {
  display: flex;
  justify-content: center;
}

.dettaglio-card-btn {
  width: 180px;
  height: 55px;
  font-size: 20px;
}

.nessun-risultato {
  display: none;
  padding: 30px;
  border-radius: 12px;
  background: white;
  color: #333;
  text-align: center;
  font-size: 21px;
}

.risultati-actions {
  margin-top: 45px;
}

/* =========================
   DETTAGLIO
========================= */

.dettaglio-offerta-box {
  padding: 40px;
}

.dettaglio-intestazione {
  display: flex;
  align-items: center;
  gap: 20px;
  padding-bottom: 30px;
  border-bottom: 2px solid #e1e8ef;
}

.dettaglio-sottotitolo {
  display: block;
  margin-bottom: 5px;
  color: #555;
  font-size: 17px;
}

.dettaglio-intestazione h2 {
  margin: 0;
  color: #1f4e79;
  font-size: 32px;
}

.dettaglio-sezione {
  margin-top: 35px;
  padding-top: 10px;
}

.dettaglio-sezione h3 {
  margin-bottom: 22px;
  color: #1f4e79;
  font-size: 24px;
}

.dettaglio-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.dettaglio-riga {
  min-height: 58px;
  padding: 15px 20px;

  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 25px;

  border-radius: 9px;
  background: #eaf3fb;
}

.dettaglio-riga span {
  color: #333;
  font-size: 18px;
}

.dettaglio-riga strong {
  color: #1f4e79;
  text-align: right;
  font-size: 19px;
}

.dettaglio-actions {
  margin-top: 40px;
}

/* =========================
   COMPLETEZZA OFFERTA
========================= */

.campo-da-completare {
  border: 2px solid #c62828 !important;
  background: #fff5f5;
}

.campo-da-completare:focus {
  border-color: #b71c1c !important;
  outline: 2px solid rgba(198, 40, 40, 0.18);
}

.messaggio-campo-mancante {
  display: block;
  margin-top: 6px;
  color: #b71c1c;
  font-size: 0.85rem;
  line-height: 1.3;
}

/* =========================
   CAMBIO PASSWORD
========================= */

.cambio-password-container {
  width: min(92%, 560px);
  margin: 40px auto;
}

.cambio-password-box {
  padding: 32px;
}

.cambio-password-box form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.cambio-password-box label {
  margin-bottom: -8px;
  font-weight: 600;
}

.cambio-password-box .password-container {
  margin-bottom: 6px;
}

.cambio-password-box .password-input {
  min-height: 48px;
  padding: 12px 48px 12px 14px;
  font-size: 1rem;
}

.cambio-password-box .button-group {
  gap: 14px;
  margin-top: 14px;
}

.cambio-password-box .menu-btn {
  min-width: 180px;
}

/* =========================
   MANUTENZIONE
========================= */

.manutenzione-box {
  width: min(92%, 560px);
  padding: 36px;
  text-align: center;
}

.manutenzione-icona {
  margin-bottom: 14px;
  font-size: 3.5rem;
}

.manutenzione-box h2 {
  margin-bottom: 18px;
}

.manutenzione-box p {
  margin: 10px 0;
  line-height: 1.6;
}

.manutenzione-stato {
  margin: 24px 0;
  padding: 14px;
  border-radius: 10px;
  background: rgba(255, 193, 7, 0.15);
  font-weight: 600;
}

/* =========================
   RESPONSIVE
========================= */

@media (max-width: 768px) {
  .select-box {
    height: 55px;
    font-size: 18px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid label {
    margin-bottom: -10px;
  }

  .preventivo-content {
    padding: 25px 20px;
  }

  #titoloPreventivo {
    font-size: 24px;
  }

  .preventivo-content h2 {
    margin-bottom: 25px;
  }

  .input-unita span {
    right: 15px;
    font-size: 16px;
  }

  .riepilogo-grid,
  .risultato-grid,
  .risultato-card-dati {
    grid-template-columns: 1fr;
  }

  .dettaglio-offerta-box {
    padding: 30px 22px;
  }
}

@media (max-width: 600px) {
  header h1 {
    font-size: 24px;
  }

  .menu {
    gap: 20px;
    margin-top: 50px;
  }

  .menu-btn {
    width: 90%;
    max-width: 300px;
    height: 60px;
    font-size: 20px;
  }

  .login-box {
    min-height: auto;
    padding: 30px 20px;
  }

  .login-box h2 {
    font-size: 28px;
  }

  .password-input {
    height: 55px;
    font-size: 18px;
  }

  .eye {
    font-size: 25px;
  }

  .button-group {
    gap: 16px;
  }

  .button-group .menu-btn {
    width: 100%;
    max-width: 300px;
    height: 55px;
    font-size: 18px;
  }

  .popup-content p {
    font-size: 20px;
  }

  .ricerca-actions {
    gap: 20px;
  }

  .ricerca-actions-superiori {
    padding-bottom: 20px;
  }

  .ricerca-actions .button-group,
  .preventivo-actions,
  .cambio-password-box .button-group {
    flex-direction: column;
    align-items: center;
  }

  .ricerca-actions .menu-btn,
  .preventivo-actions .menu-btn,
  .cambio-password-box .menu-btn {
    width: 100%;
    max-width: 300px;
    min-width: 0;
  }

  .promozione-pannelli,
  .prezzi-medi-pannelli {
    grid-template-columns: 1fr;
  }

  #titoloPreventivo {
    font-size: 20px;
  }

  .preventivo-content {
    padding: 25px 15px;
  }

  .input-unita input {
    padding-right: 70px;
  }

  .risultato-card {
    padding: 22px 18px;
  }

  .risultato-card-intestazione,
  .dettaglio-intestazione {
    align-items: flex-start;
  }

  .posizione-card {
    width: 42px;
    height: 42px;
    font-size: 19px;
  }

  .nome-offerta-card {
    font-size: 23px;
  }

  .risultato-card-dato strong {
    font-size: 23px;
  }

  .dettaglio-intestazione h2 {
    font-size: 26px;
  }

  .dettaglio-riga {
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
  }

  .dettaglio-riga strong {
    text-align: left;
  }

  .risultato-pannello strong {
    font-size: 25px;
  }

  .cambio-password-container {
    width: 92%;
    margin: 24px auto;
  }

  .cambio-password-box {
    padding: 22px 18px;
  }
}

@media (max-width: 480px) {
  .popup {
    padding: 12px;
  }

  .popup-content {
    width: 100%;
    padding: 24px 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }

  .menu-btn:hover,
  .dettaglio-card-btn:hover,
  .popup-btn:hover,
  .menu-btn:active,
  .dettaglio-card-btn:active,
  .popup-btn:active {
    transform: none;
  }
}

/*
  Durante il ritorno dalla pagina Dettaglio,
  nascondiamo temporaneamente il contenuto.

  Il layout viene comunque calcolato,
  ma l'utente non vede il passaggio
  iniziale dall'inizio della pagina.
*/

html.ripristino-risultati-in-corso body {
  visibility: hidden;
}
