/* ──────────────────────────────────────────────────────────────────
   TarantoRespira — /dati/ section: analysis, stato dei dati, report
   ────────────────────────────────────────────────────────────────── */

/* ── controls ── */
.dati-controls { display: flex; flex-direction: column; gap: 0.7rem; }
.dati-control-row { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.dati-chip {
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 0.42rem 0.85rem;
  border-radius: 2rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.dati-chip:hover { border-color: var(--teal); }
.dati-chip.active { background: var(--sea); color: #fff; border-color: var(--sea); }
.dati-select {
  font-family: var(--font);
  font-size: 0.85rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  max-width: 100%;
  flex: 1 1 14rem;
}
.dati-ranges { display: flex; gap: 0.35rem; margin-left: auto; }

/* ── chart card ── */
.dati-chart-card { margin-top: 1rem; }
.dati-chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.dati-chart-sub { font-size: 0.78rem; color: var(--muted); }
.dati-chart-wrap { position: relative; height: 300px; margin-top: 0.6rem; }
.dati-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
  gap: 0.5rem;
  margin-top: 0.9rem;
}
.dati-stat {
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  padding: 0.5rem 0.65rem;
  background: rgba(255, 255, 255, 0.6);
}
.dati-stat .k {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.dati-stat .v { font-size: 1.05rem; font-weight: 600; margin-top: 0.15rem; }
.dati-stat .v small { font-size: 0.7em; color: var(--muted); font-weight: 400; }
.dati-note {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  color: #8a5a00;
  background: rgba(217, 154, 0, 0.1);
  border: 1px solid rgba(217, 154, 0, 0.35);
  border-radius: 0.7rem;
  padding: 0.55rem 0.7rem;
}
.dati-note[hidden] { display: none; }
.dati-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1.1rem 0 0.4rem; }
.dati-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2.5rem 1rem;
}

/* ── stato dei dati — feed cards + availability table ── */
.stato-feeds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.6rem;
  margin: 0.8rem 0 1rem;
}
.stato-feed {
  border: 1px solid var(--border);
  border-radius: 0.8rem;
  padding: 0.7rem 0.8rem;
  background: var(--surface);
}
.stato-feed .k {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stato-feed .v { font-weight: 600; margin-top: 0.2rem; }
.stato-feed .s { font-size: 0.72rem; color: var(--muted); margin-top: 0.1rem; }

.stato-table-wrap { overflow-x: auto; }
table.stato-table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
.stato-table th, .stato-table td {
  padding: 0.5rem 0.55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.stato-table th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.stato-badge { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; }
.stato-badge .dot {
  width: 0.55rem; height: 0.55rem;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 4px currentColor;
}
.stato-badge.ok   { color: #2e9e5b; }
.stato-badge.late { color: #d99a00; }
.stato-badge.down { color: #d1452f; }
.stato-badge.none { color: var(--muted); font-weight: 400; }
.stato-cov { display: block; font-size: 0.68rem; color: var(--muted); margin-top: 0.15rem; }
.stato-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0.6rem 0 0.9rem;
}
.stato-updated { font-size: 0.72rem; color: var(--muted); margin-top: 0.7rem; }

/* ── report (print-friendly standalone page) ── */
.report-body {
  background: #ffffff;
  color: #12293a;
  font-family: 'Josefin Sans', system-ui, sans-serif;
  margin: 0;
  padding: 2rem 1.4rem 3rem;
}
.report-main { max-width: 760px; margin: 0 auto; }
.report-head { border-bottom: 2px solid #12293a; padding-bottom: 0.8rem; margin-bottom: 1.2rem; }
.report-head h1 { font-size: 1.4rem; margin: 0 0 0.2rem; }
.report-head .sub { color: #5b6b7a; font-size: 0.85rem; }
.report-controls { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0 1.4rem; align-items: center; font-size: 0.85rem; }
.report-controls a, .report-controls button {
  font-family: inherit;
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
  border-radius: 2rem;
  border: 1px solid rgba(20, 45, 64, 0.3);
  background: #fff;
  color: #12293a;
  text-decoration: none;
  cursor: pointer;
}
.report-controls a.active { background: #15384f; color: #fff; }
.report-section { page-break-inside: avoid; margin-bottom: 1.6rem; }
.report-section h2 { font-size: 1.05rem; border-bottom: 1px solid rgba(20,45,64,0.2); padding-bottom: 0.25rem; margin: 0 0 0.6rem; }
.report-stats { display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; font-size: 0.8rem; margin: 0.5rem 0; }
.report-stats b { font-variant-numeric: tabular-nums; }
.report-svg { width: 100%; height: auto; border: 1px solid rgba(20,45,64,0.15); border-radius: 6px; }
.report-gaps { font-size: 0.75rem; color: #5b6b7a; margin: 0.4rem 0 0; }
.report-gaps li { margin: 0.1rem 0; }
.report-foot { margin-top: 2rem; padding-top: 0.8rem; border-top: 1px solid rgba(20,45,64,0.2); font-size: 0.72rem; color: #5b6b7a; line-height: 1.5; }
.report-empty { color: #5b6b7a; font-size: 0.85rem; font-style: italic; }
@media print {
  .no-print { display: none !important; }
  .report-body { padding: 0; }
  .report-section { break-inside: avoid; }
}

@media (max-width: 640px) {
  .dati-ranges { margin-left: 0; }
  .dati-chart-wrap { height: 240px; }
}

/* ── Floating switch between /dati/ and /dati/stato/ — mirrors the map's
      bottom-right actions button so the hand already knows where to go. ── */
.dati-switch-floating {
  position: fixed;
  right:  calc(env(safe-area-inset-right, 0px)  + 1.4rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1.4rem);
  z-index: 20;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  border-radius: 2rem;
  background: var(--glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(20, 45, 64, 0.14);
  color: var(--sea);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
}
.dati-switch-floating svg {
  width: 1.1rem;
  height: 1.1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.dati-switch-floating:hover { border-color: var(--teal); color: var(--teal); }
