/* Railway mobile — componenti dell'app dentro la cornice del telefono.
   Token in tokens.css (copiati dalla console); forme e regole nel design system (UI-UX/design-system/). */
@import url("../../design-system/tokens.css");

/* ---------- cornice ---------- */
.phone {
  position: relative; width: 390px; height: 844px; flex: none;
  border: 10px solid #111; border-radius: 54px; overflow: hidden;
  background: var(--background); color: var(--foreground);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.43;
  box-shadow: 0 30px 60px -20px rgb(0 0 0 / 35%);
  display: flex; flex-direction: column; -webkit-font-smoothing: antialiased;
}
.phone *, .phone *::before, .phone *::after { box-sizing: border-box; }
:where(.phone) a { color: inherit; text-decoration: none; }
:where(.phone) svg { width: 16px; height: 16px; flex: none; }
:where(.phone) h1, :where(.phone) h2, :where(.phone) h3 { font-family: var(--font-display); }

.statusbar { height: 47px; flex: none; display: flex; align-items: center; justify-content: space-between;
  padding: 6px 30px 0; font-weight: 600; font-size: 15px; background: var(--bar-bg); }
.statusbar__icons { display: flex; gap: 6px; align-items: center; }
.statusbar__icons svg { width: 17px; height: 17px; }

.appbar { height: 56px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px;
  background: var(--bar-bg); border-bottom: 1px solid var(--bar-border); box-shadow: 0 1px 2px rgb(0 0 0 / 5%); position: relative; z-index: 2; }
.wordmark { font: 700 17px/1 var(--font-display); letter-spacing: -0.01em; white-space: nowrap; }
.wordmark b { color: var(--brand); font-weight: inherit; }
.appbar__title { font: 600 16px/1.2 var(--font-display); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.appbar__spacer { margin-left: auto; }

.content { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 16px 24px; scrollbar-width: none; }
.content::-webkit-scrollbar { display: none; }
.content--flush { padding: 0; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-content: start; } /* dentro .content: i figli non si comprimono quando la pagina scorre */

.tabbar { height: 83px; flex: none; display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--bar-bg); border-top: 1px solid var(--bar-border); padding: 6px 2px 30px; position: relative; }
.tabbar::after { content: ""; position: absolute; bottom: 8px; left: 50%; translate: -50% 0;
  width: 134px; height: 5px; border-radius: 3px; background: var(--foreground); }
.tabbar__item { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; font-size: 11px; color: var(--muted-foreground); min-height: var(--control-touch); }
.tabbar__item svg { width: 22px; height: 22px; }
.tabbar__item--active { color: var(--brand-text); font-weight: 600; }
.tabbar__badge { position: absolute; top: -2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--brand-tint); color: var(--brand-text); font: 600 11px/18px var(--font-mono); text-align: center; }

/* ---------- tipografia ---------- */
.h1 { font: 700 24px/1.2 var(--font-display); margin: 0; letter-spacing: -0.01em; }
.h2 { font: 600 18px/1.3 var(--font-display); margin: 0; }
.h3 { font: 600 15px/1.3 var(--font-display); margin: 0; }
.lede { font-size: 14px; color: var(--muted-foreground); margin: 4px 0 0; }
.meta { font-size: 12px; color: var(--muted-foreground); }
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-weight: 500; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.crumbs { display: flex; gap: 6px; align-items: center; font-size: 12px; color: var(--muted-foreground); margin: 0 0 4px; }
.crumbs svg { width: 12px; height: 12px; }

/* ---------- etichette di stato: testo in grassetto nel colore del significato, senza fondo né bordo ---------- */
.tag { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: 12px; font-weight: 600; color: var(--foreground); }
.tag--ok { color: var(--ok-text); } .tag--warn { color: var(--warn-text); } .tag--critical { color: var(--critical-text); }
.tag--brand { color: var(--brand-text); } .tag--offline { color: var(--offline); }
.tag--live .dot { animation: pulse 1.4s ease-in-out infinite; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; display: inline-block; }
.dot--lg { width: 8px; height: 8px; }

/* ---------- card e KPI (come le tile della Panoramica web) ---------- */
.card { position: relative; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgb(0 0 0 / 5%); overflow: hidden; }
.card__head { padding: 12px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card__body { padding: 14px; }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.kpi { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 14px; }
.kpi--accent::before { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--brand); }
.kpi__label { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 500; color: var(--muted-foreground); }
.kpi__value { font: 500 28px/1 var(--font-mono); font-variant-numeric: tabular-nums; margin: 0; }
.kpi__value small { font-size: 16px; color: var(--muted-foreground); }
.kpi--accent .kpi__value { color: var(--brand-text); }
.kpi__note { font-size: 12px; color: var(--muted-foreground); margin: 0; }
.meter { display: flex; height: 6px; gap: 2px; overflow: hidden; border-radius: 3px; background: var(--muted); }
.meter > span { display: block; height: 100%; }

/* ---------- sezioni e liste ---------- */
.section { margin-top: 28px; }
.section__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.section__desc { font-size: 13px; color: var(--muted-foreground); margin: 2px 0 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--border); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 56px; }
.row__main { flex: 1; min-width: 0; }
.row__title { font-weight: 600; margin: 0; }
.row__sub { font-size: 13px; color: var(--muted-foreground); margin: 2px 0 0; }
.row__end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.row > svg:last-child { color: var(--muted-foreground); }
.row--new { background: color-mix(in srgb, var(--brand-tint) 45%, transparent); }
.thumb { display: block; width: 96px; aspect-ratio: 16 / 9; flex: none; border-radius: 6px; overflow: hidden; background: var(--video); }
.thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumb--sm { width: 64px; }
.daylabel { font: 600 12px var(--font-sans); color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .04em; margin: 20px 0 8px; }

/* dettagli a coppie etichetta / valore (pannello laterale web) */
.facts { margin: 0; }
.facts > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.facts > div:last-child { border-bottom: 0; }
.facts dt { font-size: 11px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .04em; }
.facts dd { margin: 0; text-align: right; font-weight: 500; }

/* ---------- controlli ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--control-touch);
  padding: 0 16px; border-radius: var(--radius-control); font: 500 14px/1 var(--font-sans); white-space: nowrap;
  border: 1px solid transparent; background: none; color: var(--foreground); cursor: pointer; }
.btn--primary { background: var(--primary); color: var(--primary-foreground); }
.btn--outline { border-color: var(--border); background: var(--background); box-shadow: 0 1px 2px rgb(0 0 0 / 5%); }
.btn--ghost { color: var(--muted-foreground); }
.btn--danger { background: var(--critical); color: #fff; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn--icon { width: var(--control-touch); padding: 0; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.field { display: grid; gap: 6px; }
.label { font-size: 12px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .04em; }
.input { display: flex; align-items: center; gap: 8px; height: var(--control-touch); padding: 0 12px; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-control); background: var(--input); font-size: 16px; color: var(--foreground); }
.input:focus-within { background: var(--card); border-color: var(--teal); }
.input svg { color: var(--muted-foreground); }
.textarea { height: auto; min-height: 88px; padding: 10px 12px; align-items: flex-start; }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 17px; font-size: 13px; background: var(--card); white-space: nowrap; cursor: pointer; color: var(--foreground); }
.chip--on { border-color: var(--teal); background: var(--teal-tint); color: var(--teal); font-weight: 500; }
.chip .num { color: var(--muted-foreground); font-size: 12px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--muted); border-radius: var(--radius-control); }
.seg__item { display: flex; align-items: center; justify-content: center; min-height: 34px; border-radius: 6px; font-size: 13px;
  font-weight: 500; color: var(--muted-foreground); background: none; border: 0; cursor: pointer; }
.seg__item--on { background: var(--card); color: var(--foreground); box-shadow: 0 1px 2px rgb(0 0 0 / 12%); }

/* ---------- fotogramma: immagine reale + zona di allerta e riquadri disegnati dalla demo ---------- */
.frame { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; background: var(--video); overflow: hidden; }
.frame > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.frame__overlay { position: absolute; inset: 0; width: 100% !important; height: 100% !important; pointer-events: none; }
.frame__zone { fill: color-mix(in srgb, var(--zone) 42%, transparent); stroke: var(--zone); stroke-width: 3; }
.frame__box { fill: none; stroke: var(--critical); stroke-width: 4; rx: 4; }
.frame__label { position: absolute; transform: translateY(-100%); background: var(--critical); color: #fff;
  font: 600 10px/1 var(--font-sans); padding: 3px 5px; border-radius: 3px; white-space: nowrap; }
.frame__badge { position: absolute; left: 8px; top: 8px; display: inline-flex; align-items: center; gap: 6px; padding: 3px 7px;
  border-radius: 4px; background: rgb(0 0 0 / 55%); color: var(--video-foreground); font: 600 10px/1.2 var(--font-mono); letter-spacing: .04em; }
.frame__badge .dot { background: var(--critical); }

/* ---------- mappa statica con segnaposto (immagine OpenStreetMap, attribuzione sempre visibile) ---------- */
.map { position: relative; display: block; width: 100%; aspect-ratio: 716 / 400; overflow: hidden; background: #eef0ec; }
.map > img { display: block; width: 100%; height: 100%; object-fit: cover; }
.map__credit { position: absolute; right: 0; bottom: 0; padding: 1px 5px; background: rgb(255 255 255 / 80%); font-size: 9px; color: #525252; }
.pin { position: absolute; translate: -50% -50%; display: flex; align-items: center; gap: 4px; padding: 3px 7px 3px 5px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border); box-shadow: 0 1px 3px rgb(0 0 0 / 25%); font: 600 11px/1.2 var(--font-sans); white-space: nowrap; color: var(--foreground); }
.pin .dot { width: 8px; height: 8px; }
.pin--ok .dot { background: var(--ok); } .pin--warn .dot { background: var(--warn); } .pin--offline .dot { background: var(--offline); }
.pin--site .dot { background: var(--brand); }
.info-count { display: inline-flex; align-items: center; gap: 4px; font: 500 12px var(--font-mono); color: var(--muted-foreground); }
.info-count svg { width: 13px; height: 13px; }

/* ---------- fogli dal basso, overlay e messaggi ---------- */
.overlay { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; justify-content: flex-end; background: rgb(0 0 0 / 40%); }
.sheet { background: var(--background); border-radius: 14px 14px 0 0; max-height: 85%; display: flex; flex-direction: column; }
.sheet__handle { width: 40px; height: 5px; border-radius: 3px; background: var(--border); margin: 10px auto 4px; }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 12px 12px 16px; border-bottom: 1px solid var(--border); }
.sheet__body { overflow-y: auto; padding: 16px; display: grid; gap: 20px; scrollbar-width: none; }
.sheet__foot { display: flex; gap: 12px; padding: 12px 16px 34px; border-top: 1px solid var(--border); }
.sheet__foot > .btn { flex: 1; }
.toast { position: absolute; left: 16px; right: 16px; bottom: 96px; z-index: 6; display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 8px 24px rgb(0 0 0 / 14%); font-size: 13px; }
.toast svg { color: var(--ok); }

.empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 32px 20px; text-align: center; color: var(--muted-foreground); }
.empty svg { width: 28px; height: 28px; }
.empty__title { font-weight: 600; color: var(--foreground); margin: 10px 0 0; }

.menu { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.menu__label { padding: 14px 16px 6px; font-size: 12px; font-weight: 600; color: var(--muted-foreground); text-transform: uppercase; letter-spacing: .04em; }
.menu__item { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 0 16px; background: none; border: 0;
  font: inherit; color: inherit; text-align: left; cursor: pointer; }
.menu__item + .menu__item { border-top: 1px solid var(--border); }
.menu__item > svg:last-child { margin-left: auto; color: var(--muted-foreground); }
.avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; flex: none; }

@keyframes pulse { 50% { opacity: .35; } }
@keyframes spin { to { rotate: 360deg; } }
.spin { animation: spin 1s linear infinite; }
