/* --- UNIFORMITÀ CROSS‑BROWSER --- */
@charset "UTF-8";

/* Forza tema scuro coerente tra browser */
:root {
  color-scheme: dark;
}

/* VARIABILI */
:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #fff;
  --border: #38bdf8;
}

/* ============================================================
   RIFINITURE FINALI (Inserite dopo tutto il resto)
   ============================================================ */

.top-bar {
    padding: 10px 20px;
    background: rgba(30, 41, 59, 0.5); 
    border-radius: 0 0 15px 15px;
    width: 100%;
    max-width: 1300px;
    box-sizing: border-box;
    display: flex; /* Mantiene allineati titolo e orologio */
    align-items: center;
    justify-content: space-between;
}

.side-menu h3 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(56, 189, 248, 0.2);
}

#tempo-dati {
    cursor: pointer;
    outline: none;
    transition: border-color 0.3s;
    background: #1e293b; /* Colore coordinato alle tue card */
    color: white;
    border: 1px solid #334155;
    padding: 5px;
    border-radius: 4px;
}

#tempo-dati:hover {
    border-color: var(--border); /* Diventa azzurro quando ci passi sopra */
}

/* Protezione Griglia 3x3: impedisce ai grafici di deformare le card */
canvas {
    max-width: 100% !important;
    max-height: 100% !important;
}

/* BASE */
html {
  font-size: 15px;
}
body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
* {
  font-family: "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
}

/* ============================================================
   LED WiFi – Stili base, tooltip e stati visivi (OK / Warn)
   ============================================================ */

/* --- ANIMAZIONE PULSANTE AD ALTA FREQUENZA (0.5s) --- */
/* --- ANIMAZIONE PULSANTE CALIBRATA (1.5 secondi) --- */
/* --- ANIMAZIONE PULSANTE VERDE INTENSO (1.5s) --- */
@keyframes wifi-pulse-intense {
  0% { 
    transform: scale(1); 
    opacity: 1; 
    /* Verde base molto saturo */
    background: #00ff80;
    box-shadow: 0 0 10px #00ff80, 0 0 20px rgba(0, 255, 128, 0.2); 
  }
  50% { 
    transform: scale(1.3); 
    opacity: 0.8; 
    /* Verde neon ultra-brillante al picco */
    background: #05ffa1;
    box-shadow: 0 0 25px #05ffa1, 0 0 50px #05ffa1, 0 0 70px rgba(5, 255, 161, 0.3); 
  }
  100% { 
    transform: scale(1); 
    opacity: 1; 
    background: #00ff80;
    box-shadow: 0 0 10px #00ff80; 
  }
}

.wifi-led {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #444;
  display: inline-block;
  margin-left: 6px;
  transition: background 0.3s;
}

/* Stato OK (Verde) - Massima Intensità */
.wifi-ok {
  /* Usiamo un verde elettrico come base */
  background: #00ff80; 
  color: #00ff80;
  animation: wifi-pulse-intense 1.5s infinite ease-in-out;
}

/* Stato Lento (Giallo) - Mantiene la pulsazione ritmata */
.wifi-warn {
  background: #f59e0b;
  color: #f59e0b;
  animation: wifi-pulse-intense 1.5s infinite ease-in-out;
}

/* Stato Offline (Rosso) - FISSO E PREPOTENTE */
.wifi-off {
  background: #ff0000;
  color: #ff0000;
  animation: none;
  /* Doppio alone per il rosso fisso */
  box-shadow: 0 0 15px #ff0000, 0 0 30px rgba(255, 0, 0, 0.4);
  opacity: 1;
}

/* Orologio digitale */
#digital-clock {
  text-align: right;
  font-family: "Courier New", monospace;
}

#digital-time {
  font-size: 1.8rem;
  color: #38bdf8;
  letter-spacing: 2px;
  text-shadow: 0 0 8px #38bdf8;
}

#digital-date {
  font-size: 0.9rem;
  color: #94a3b8;
  margin-top: -4px;
}

/* GRIGLIA 3x3 (DESKTOP) */
.container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px; /* leggermente più respiro */
  width: 100%;
  max-width: 1300px; /* 🔥 BLOCCCHI PIÙ GRANDI */
  padding: 25px;
}

/* CARD SENSORI */
.card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  height: 270px; /* 🔥 SOLO QUESTA CAMBIA */
  overflow: hidden;
  padding: 4px;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(56, 189, 248, 0.4);
}

.data-header {
  height: 70px;
  padding-left: 6px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.label {
  font-size: 0.65em;
  color: #94a3b8;
  text-transform: uppercase;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 1px;
}

.val {
  font-size: 0.95rem;
  line-height: 1.05;
  font-weight: 500;
}
.val.gps {
  font-size: 0.85rem;
  line-height: 1.05;
}

/* ============================================================
   SISTEMA DI ZOOM
   ============================================================ */

.card.expanded {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1.05);
  width: 90vw;
  max-width: 800px;
  height: 80vh;
  z-index: 3000;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.9);
  cursor: zoom-out;
  background: var(--card);
}

.zoom-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2500;
}

.zoom-overlay.active {
  display: block;
}

/* COLORI SENSORI */
.val.temp {
  color: #ef4444;
}
.val.hum {
  color: #10b981;
}
.val.press {
  color: #f59e0b;
}
.val.iaq {
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}
.val.co2 {
  color: #ef4444;
}
.val.pm25 {
  color: #94a3b8;
}
.val.uv {
  color: #f472b6;
}
.val.wind {
  color: #38bdf8;
}
.val.gps {
  color: #10b981;
}

/* AREA GRAFICI */
.chart-area {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
  margin: 0 3px 3px 3px;
  border-radius: 8px;
}
.mini-chart {
  position: absolute;
  top: -6px;
  left: -5%;
  width: 110%;
  height: 200px; /* 🔥 SOLO PIÙ ALTO */
  border: none;
}

/* EFFETTO HIGHLIGHT AGGIORNAMENTO DATO */
.val.flash {
  animation: flash-bg 0.8s ease-out;
  padding: 0 4px; /* Dà un po' di spazio al colore di sfondo */
  display: inline-block;
}

@keyframes flash-bg {
  0% { 
    background-color: rgba(56, 189, 248, 0.4); /* Azzurro brillante (come il tuo border) */
    color: #fff;                               /* Testo bianco acceso */
    border-radius: 4px; 
  }
  100% { 
    background-color: transparent; 
    /* Il colore del testo tornerà quello della sua classe (es. .temp, .hum) */
  }
}

/* MAPPA */
.map-frame {
  width: 100%;
  height: 100%;
  border: none;
}

/* --- MENU HAMBURGER --- */
.hamburger-btn {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1100;
  background: var(--card);
  border: 2px solid var(--border);
  color: var(--border);
  font-size: 1.5rem;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: 0.3s;
}

.hamburger-btn:hover {
  background: var(--border);
  color: white;
}

.side-menu {
  position: fixed;
  top: 0;
  left: -280px;
  width: 260px;
  height: 100%;
  background: var(--card);
  transition: 0.4s ease;
  z-index: 1050;
  padding-top: 80px;
  border-right: 2px solid var(--border);
  box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}

.side-menu.active {
  left: 0;
}

.side-menu ul {
  list-style: none;
  padding: 0;
}

.side-menu li {
  padding: 15px 25px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: 0.2s;
}

.side-menu li:hover {
  background: rgba(56, 189, 248, 0.1);
  padding-left: 35px;
  color: var(--border);
}

.side-menu::-webkit-scrollbar {
  width: 6px;
}
.side-menu::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 10px;
}

/* --- MODALE REPORT --- */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(5px);
}

.modal-content {
  background: var(--card);
  margin: 5% auto;
  padding: 30px;
  width: 90%;
  max-width: 900px;
  border-radius: 15px;
  border: 1px solid var(--border);
  position: relative;
}

.close-btn {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 2rem;
  cursor: pointer;
  color: #94a3b8;
}

.print-btn {
  background: #10b981;
  color: white;
  border: none;
  padding: 12px 25px;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 10px;
}

/* --- REGOLE PER LA STAMPA --- */
@media print {
  @page {
    size: landscape;
    margin: 1cm;
  }

  html,
  body {
    height: 100%;
    overflow: hidden !important;
  }

  body * {
    visibility: hidden;
  }

  #report-modal,
  #report-modal *,
  #canvas-modal {
    visibility: visible !important;
  }

  #report-modal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }

  .modal-content {
    border: none !important;
    box-shadow: none !important;
    width: 100% !important;
  }

  #canvas-modal {
    width: 100% !important;
    height: 480px !important;
    display: block !important;
  }

  .modal-footer,
  .print-btn,
  .close-btn,
  .hamburger-btn {
    display: none !important;
  }

  canvas {
    print-color-adjust: exact !important;
    -webkit-print-color-adjust: exact !important;
    filter: brightness(0.7) contrast(1.3);
  }
}

/* RESPONSIVE PER TELEFONI */
@media (max-width: 768px) {
  .container {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .card {
    height: 200px;
  }
  h1 {
    font-size: 1.2rem;
    margin-top: 60px;
  }
}
