/* /opt/asl-dashboard-v10/public/styles.css */
:root{
  --bg: #F7F9FB;
  --panel: #FFFFFF;
  --panel2:#FFFFFF;
  --text:#0B1F33;
  --muted:#5B6B7A;
  --border:#D7DEE7;
  --shadow: 0 6px 20px rgba(12, 30, 60, .08);

  --row: rgba(10,110,209,.10);
  --row2: rgba(0,0,0,.03);

  --asl:#0A6ED1;
  --ech:#F5A623;
  --sip:#2E7D32;
  --iax:#6A1B9A;
  --dmr:#C62828;

  --ok:#2E7D32;
  --warn:#FF8F00;
  --bad:#C62828;

  --chip:#EEF3F8;
  --btn:#0A6ED1;
  --btnText:#fff;
  --btnGhost:#EEF3F8;

  --radius:16px;
  --radius2:12px;

  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

[data-theme="dark"]{
  --bg:#0B1220;
  --panel:#0F1A2B;
  --panel2:#0F1A2B;
  --text:#EAF1FA;
  --muted:#9FB2C6;
  --border:#203047;
  --shadow: 0 10px 28px rgba(0,0,0,.35);

  --row: rgba(77,177,255,.14);
  --row2: rgba(255,255,255,.05);

  --asl:#4DB1FF;
  --ech:#FFB74D;
  --sip:#66BB6A;
  --iax:#B39DDB;
  --dmr:#EF5350;

  --ok:#66BB6A;
  --warn:#FFB74D;
  --bad:#EF5350;

  --chip:#15233A;
  --btn:#4DB1FF;
  --btnText:#06111F;
  --btnGhost:#15233A;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--sans);
  background:var(--bg);
  color:var(--text);
}

.muted{ color:var(--muted); }
.mono{ font-family:var(--mono); }
.mini{ font-size:12px; line-height:1.25; }
.hidden{ display:none !important; }

.app{ min-height:100vh; display:flex; flex-direction:column; }

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  gap:16px;
}

.brand-title{ display:flex; align-items:center; gap:10px; }
.brand-name{ font-weight:800; letter-spacing:.2px; font-size:18px; }
.brand-sub{ font-size:12px; }

.statusbar{ display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end; }
.chip{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border-radius:999px;
  background:var(--chip);
  border:1px solid rgba(0,0,0,0);
  font-size:13px;
}
.dot{
  width:10px; height:10px; border-radius:50%;
  background:var(--ok);
  box-shadow:0 0 0 4px rgba(46,125,50,.18);
}

.btn{
  border:0;
  background:var(--btn);
  color:var(--btnText);
  padding:9px 12px;
  border-radius:12px;
  font-weight:700;
  cursor:pointer;
}
.btn:hover{ filter:brightness(1.03); }
.btn:active{ transform:translateY(1px); }
.btn-ghost{
  background:var(--btnGhost);
  color:var(--text);
  border:1px solid var(--border);
  font-weight:700;
}

.grid{
  display:grid;
  grid-template-columns: 380px 1fr 460px;
  gap:14px;
  padding:0 14px 14px 14px;
  flex:1;
}

.panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  min-height: 200px;
}

.panel-h{
  padding:14px 14px 10px 14px;
  border-bottom:1px solid var(--border);
}
.panel-title{ font-weight:800; }
.panel-sub{ font-size:12px; margin-top:4px; }

.section{ padding:12px 14px; border-bottom:1px solid var(--border); }
.section:last-child{ border-bottom:0; }
.section-title{ font-weight:800; font-size:12px; text-transform:uppercase; letter-spacing:.5px; margin-bottom:10px; color:var(--muted); }

.tabs{ display:flex; gap:10px; padding:12px 12px 0 12px; }
.tab{
  border:1px solid var(--border);
  background:var(--panel2);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
  font-weight:800;
}
.tab.is-active{
  border-color: rgba(10,110,209,.55);
  box-shadow:0 0 0 4px rgba(10,110,209,.12);
}
.tabpane{ display:none; padding: 12px; }
.tabpane.is-active{ display:block; }

.pane-h{ display:flex; align-items:flex-end; justify-content:space-between; gap:12px; margin-bottom:10px; }
.pane-title{ font-weight:900; display:flex; align-items:center; gap:10px; }
.pane-sub{ font-size:12px; }

.pill{
  padding:4px 10px;
  border-radius:999px;
  font-weight:800;
  font-size:12px;
  border:1px solid var(--border);
  background: transparent;
}
.pill-neutral{ background: var(--chip); border-color: transparent; }

/* KEY badges: IDLE / TX */
.pill-idle{
  background: rgba(96,125,139,.12);
  border-color: rgba(96,125,139,.28);
  color: var(--text);
}
.pill-tx{
  background: rgba(198,40,40,.12);
  border-color: rgba(198,40,40,.30);
  color: var(--text);
}
[data-theme="dark"] .pill-tx{
  background: rgba(239,83,80,.16);
  border-color: rgba(239,83,80,.35);
}

/* extra pills for DMR state */
.pill-ok{ background: rgba(46,125,50,.12); border-color: rgba(46,125,50,.35); }
.pill-warn{ background: rgba(255,143,0,.12); border-color: rgba(255,143,0,.35); }
.pill-bad{ background: rgba(198,40,40,.12); border-color: rgba(198,40,40,.35); }

.tablewrap{
  border:1px solid var(--border);
  border-radius:var(--radius);
  overflow:auto;
}
.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
}
thead th{
  position:sticky;
  top:0;
  background:var(--panel);
  z-index:2;
  text-align:left;
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  font-size:12px;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.4px;
}
tbody td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  vertical-align:middle;
}
tbody tr:hover{ background: var(--row2); cursor:pointer; }
tbody tr.is-tx{ background: var(--row); }

/* selected row (click) */
tbody tr.selected{
  background: rgba(10,110,209,.14);
  outline: 2px solid rgba(10,110,209,.25);
  outline-offset: -2px;
}

.tag{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border-radius:12px;
  font-weight:900;
  font-size:12px;
  border:1px solid transparent;
  color:#fff;
}
.tag-neutral{ background: #607D8B; }
.tag-asl{ background: var(--asl); }
.tag-ech{ background: var(--ech); color:#241A00; }
[data-theme="dark"] .tag-ech{ color:#1A1200; }
.tag-sip{ background: var(--sip); }
.tag-iax{ background: var(--iax); }
.tag-dmr{ background: var(--dmr); }

/* SIP status tags */
.tag-off{ background:#607D8B; }
.tag-reg{ background: var(--asl); }
.tag-incall{ background: var(--ok); }

/* Cards */
.cards{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.card{
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px;
  background:var(--panel2);
}
.card-h{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:10px;
}
.card-title{ font-weight:900; }

.kv{
  display:grid;
  grid-template-columns: 120px 1fr;
  gap:8px 10px;
  font-size:13px;
}
.k{ color:var(--muted); font-weight:800; font-size:12px; text-transform:uppercase; letter-spacing:.4px; }
.v{ font-weight:700; }

.empty{ padding:20px 14px; }
.empty-title{ font-weight:900; font-size:16px; }
.empty-sub{ margin-top:6px; font-size:13px; }

.details{ padding:12px 14px 14px 14px; }
.details-h{ margin-bottom:12px; }
.details-title{ display:flex; align-items:center; gap:10px; font-weight:900; font-size:16px; }
.details-sub{ margin-top:4px; color:var(--muted); font-weight:700; }

.details-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:12px;
  margin-bottom:12px;
}

/* Left sidebar */
.side-brand{ display:flex; gap:12px; align-items:flex-start; }
.side-logo{
  width:46px; height:46px;
  border-radius:14px;
  border:1px solid var(--border);
  background: var(--panel2);
  padding:6px;
  object-fit:contain;
}
.side-brand-title{ font-weight:900; font-size:13px; line-height:1.2; }
.side-brand-desc{ font-size:12px; line-height:1.35; margin-top:4px; }

.links-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:10px; }
.linkbtn{
  display:flex; align-items:center; justify-content:center;
  text-decoration:none;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid var(--border);
  background: var(--btnGhost);
  color: var(--text);
  font-weight:900;
  font-size:13px;
}
.linkbtn:hover{ filter:brightness(1.02); }
.linkbtn:active{ transform:translateY(1px); }

.sysgrid{ display:grid; grid-template-columns: 110px 1fr; gap:8px 10px; font-size:13px; }

/* Right column stack */
.panel-right{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding-bottom:12px;

  /* stabile: scroll interno colonna destra */
  height: calc(100vh - 90px);
  overflow: auto;
}
.right-card{
  margin:0 12px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:var(--panel2);
  overflow:hidden;
  contain: layout paint;
}
.right-card .rc-h{
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.right-card .rc-title{ font-weight:900; }
.right-card .rc-sub{ font-size:12px; color:var(--muted); }
.right-card .rc-b{ padding:10px 12px; }

/* TX NOW list */
.tx-list{ display:flex; flex-direction:column; gap:8px; }
.tx-item{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 10px;
  border-radius:14px;
  border:1px solid var(--border);
  background: transparent;
}
.tx-left{ min-width:0; display:flex; flex-direction:column; gap:3px; }
.tx-who{ font-weight:900; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tx-what{ font-size:12px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.tx-tag{
  padding:3px 9px;
  border-radius:999px;
  border:1px solid var(--border);
  font-weight:900;
  font-size:12px;
}
.tx-tag-asl{ background: rgba(10,110,209,.12); border-color: rgba(10,110,209,.28); }
.tx-tag-ech{ background: rgba(245,166,35,.18); border-color: rgba(245,166,35,.35); }
.tx-tag-dmr{ background: rgba(198,40,40,.12); border-color: rgba(198,40,40,.30); }
.tx-tag-xlx{ background: rgba(10,110,209,.12); border-color: rgba(10,110,209,.28); }
.tx-tag-urf{ background: rgba(245,166,35,.18); border-color: rgba(245,166,35,.35); }
[data-theme="dark"] .tx-tag-ech{ color:#1A1200; }
[data-theme="dark"] .tx-tag-urf{ color:#1A1200; }
.tx-empty{ padding:6px 2px; }

.list{ display:flex; flex-direction:column; gap:10px; }
.listrow{
  border:1px solid var(--border);
  background: transparent;
  border-radius: 14px;
  padding:10px 10px;
}
.lr-title{ font-weight:900; }
.lr-sub{ margin-top:4px; font-size:12px; }

/* VOTER bar */
#voterPanel .voter-head{
  margin-top:8px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
#voterPanel .voter-bar{
  margin-top: 10px;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.18);
  background: rgba(0,0,0,.10);
}
[data-theme="dark"] #voterPanel .voter-bar{
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.10);
}
#voterPanel .voter-bar-fill{
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.10);
  transition: width .15s linear;
}

/* Compact mode */
.compact .topbar{ padding:10px 12px; }
.compact .grid{ gap:10px; padding:0 10px 10px 10px; }
.compact .panel-h{ padding:10px 12px 8px 12px; }
.compact .section{ padding:10px 12px; }
.compact .tab{ padding:8px 10px; }
.compact .table{ font-size:12px; }
.compact tbody td{ padding:8px 8px; }

@media (max-width: 1200px){
  .grid{ grid-template-columns: 280px 1fr; }
  .panel-right{ grid-column: 1 / -1; height:auto; overflow:visible; }
}
@media (max-width: 900px){
  .grid{ grid-template-columns: 1fr; }
  .panel-left{ order:2; }
  .panel-center{ order:1; }
  .panel-right{ order:3; height:auto; overflow:visible; }
}

.panel-left,
.panel-right{
  font-size:14px;
}

.panel-right .rc-title{ font-size:14px; }
.panel-right .rc-sub{ font-size:12.5px; }

/* ---------------------------------------
   TX NOW: card fissa (anti "salto" layout)
   --------------------------------------- */
#txNowPanel{ height: 190px; }
#txNowPanel .rc-b{
  height: 138px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Sposta header Dettagli nel box details */
.panel-right > .panel-h{ display:none; }

#detailsEmpty,
#details{
  margin: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel2);
  overflow: hidden;
  padding: 0;
}
#detailsEmpty::before,
#details::before{
  content: "Dettagli";
  display:block;
  padding:10px 12px;
  border-bottom:1px solid var(--border);
  font-weight:900;
  background: var(--panel2);
}
#detailsEmpty::after{
  content:"clicca una riga per espandere";
  display:block;
  padding: 0 12px 10px 12px;
  color: var(--muted);
  font-size: 12px;
  border-bottom:1px solid var(--border);
  background: var(--panel2);
}
#detailsEmpty .empty,
#details .details{
  padding:12px 14px 14px 14px;
}

/* ==========================================================
   MeshMsg (nuovo) — tabella compatta e stabile in colonna dx
   ========================================================== */
#meshMsgPanel{ height: 250px; }
#meshMsgPanel .rc-b{
  height: 198px;
  overflow: hidden;
}

.meshmsg-wrap{
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: auto;
  background: transparent;
}

.meshmsg-table{
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}

.meshmsg-table thead th{
  position: sticky;
  top: 0;
  background: var(--panel2);
  z-index: 2;
  text-align: left;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .35px;
}

.meshmsg-table tbody td{
  padding: 7px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.meshmsg-table tbody tr:hover{
  background: var(--row2);
}

.mm-col-time{ width: 64px; }
.mm-col-dir{ width: 44px; }
.mm-col-from{ width: 52px; }
.mm-col-to{ width: 52px; }

.mm-dir-in{ font-weight: 900; }
.mm-dir-out{ font-weight: 900; }

.mm-text{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}
/* ==========================================
   Connessioni: TX LED + recent-TK highlight
   ========================================== */

/* LED TX: al posto di TU/TK */
.txled{
  display:inline-block;
  width:12px;
  height:12px;
  border-radius:50%;
  vertical-align:middle;
  border:1px solid rgba(0,0,0,.14);
}
[data-theme="dark"] .txled{
  border-color: rgba(255,255,255,.16);
}
.txled.idle{
  background: rgba(120,140,160,.25);
}
.txled.tu{
  background: rgba(255,143,0,.78);
  box-shadow: 0 0 0 4px rgba(255,143,0,.14);
}
.txled.tk{
  background: rgba(198,40,40,.85);
  box-shadow: 0 0 0 4px rgba(198,40,40,.14);
}
[data-theme="dark"] .txled.tk{
  background: rgba(239,83,80,.88);
  box-shadow: 0 0 0 4px rgba(239,83,80,.14);
}

/* riga “recent TK linger” (4s) quando è già tornato TU */
tbody tr.is-recent-tk{
  background: rgba(255,143,0,.08);
}
[data-theme="dark"] tbody tr.is-recent-tk{
  background: rgba(255,183,77,.10);
}

/* Ultimo TX table: colonne (usiamo la tua .table) */
#tblLastTx th.col-ltx-time{ width: 92px; }
#tblLastTx th.col-ltx-node{ width: 90px; }
#tblLastTx th.col-ltx-mode{ width: 90px; }      /* ref: panels.js */

/* ===== Map (Leaflet) ===== */
.mapwrap{
  position: relative;
  height: calc(100vh - 220px);
  min-height: 520px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.map{
  width: 100%;
  height: 100%;
}

/* legenda */
.mapLegend{
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  backdrop-filter: blur(6px);
  box-shadow: var(--shadow);
}

.mapLegend .ml-row{
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}

.ml-dot{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid rgba(198,40,40,.65); /* accento rosso BM */
  display: inline-block;
}

.ml-dot.ok{ background: var(--ok); }
.ml-dot.out{ background: var(--asl); }     /* blu */
.ml-dot.in{ background: var(--warn); }     /* arancio */
.ml-dot.off{ background: #9aa4ad; }        /* grigio */
.ml-dot.iax{ background: var(--iax); }     /* viola */

/* marker leaflet custom */
.asl-marker{
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(198,40,40,.65); /* accento rosso BM */
  box-shadow: 0 6px 18px rgba(12,30,60,.18);
}
.asl-marker.ok{ background: var(--ok); }
.asl-marker.out{ background: var(--asl); }
.asl-marker.in{ background: var(--warn); }
.asl-marker.off{ background: #9aa4ad; }
.asl-marker.iax{ background: var(--iax); }
