/* ============================================================
   SIRENE — Videowall (sala de situação)
   Painéis flutuantes em material translúcido sobre o globo
   CesiumJS, no mesmo template iPadOS do restante do sistema:
   cantos arredondados, hairlines, tipografia SF e cores do
   sistema. Tokens --vw-* com variante clara em [data-theme].
   ============================================================ */
:root,
[data-theme="dark"] {
  --vw-material: rgba(28, 28, 30, 0.46);
  --vw-material-strong: rgba(28, 28, 30, 0.78);
  --vw-hairline: rgba(255, 255, 255, 0.1);
  --vw-row: rgba(120, 120, 128, 0.18);
  --vw-row-hover: rgba(120, 120, 128, 0.28);
  --vw-seg-on: #636366;
  --vw-txt: #ffffff;
  --vw-txt2: #adadb5;
  --vw-txt3: #85858c;
  --vw-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --vw-globe: #000000;
}

[data-theme="light"] {
  --vw-material: rgba(255, 255, 255, 0.55);
  --vw-material-strong: rgba(255, 255, 255, 0.85);
  --vw-hairline: rgba(0, 0, 0, 0.08);
  --vw-row: rgba(120, 120, 128, 0.12);
  --vw-row-hover: rgba(120, 120, 128, 0.2);
  --vw-seg-on: #ffffff;
  --vw-txt: #1c1c1e;
  --vw-txt2: #55555a;
  --vw-txt3: #78787e;
  --vw-shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
  --vw-globe: #dfe3e8;
}

.vw-body {
  margin: 0;
  background: var(--vw-globe);
  color: var(--vw-txt);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.vw {
  position: fixed;
  inset: 0;
  background: var(--vw-globe);
}

.vw-scene { position: absolute; inset: 0; }
.vw-scene .cesium-viewer,
.vw-scene .cesium-widget,
.vw-scene canvas { width: 100%; height: 100%; }
.vw-scene .cesium-viewer-bottom,
.vw-scene .cesium-widget-credits { display: none !important; }

/* material translúcido dos painéis flutuantes */
.vw-glass {
  background: var(--vw-material);
  border: 1px solid var(--vw-hairline);
  border-radius: var(--radius-xl);
  box-shadow: var(--vw-shadow);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

/* ---------- barra superior ---------- */
.vw-top {
  position: absolute;
  left: 16px;
  right: 16px;
  top: 16px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 12px 0 16px;
  z-index: 5;
}

.vw-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.vw-logo {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--ipad-blue);
  color: #fff;
  font-size: 17px;
  flex: none;
}

.vw-brand-txt { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.vw-brand-txt b { font-size: 17px; font-weight: 650; letter-spacing: -0.2px; color: var(--vw-txt); }
.vw-glass { text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18); }
[data-theme="light"] .vw-glass { text-shadow: 0 1px 2px rgba(255, 255, 255, 0.35); }
.vw-brand-txt span { font-size: 12px; color: var(--vw-txt2); white-space: nowrap; }

.vw-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--ipad-fill-tertiary);
  color: var(--vw-txt2);
  white-space: nowrap;
}
.vw-pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.vw-pill.live { background: rgba(48, 209, 88, 0.18); color: var(--ipad-green); }
.vw-pill.live::before { animation: vw-blink 2s ease-in-out infinite; }
.vw-pill.sim { background: rgba(255, 214, 10, 0.2); color: var(--ipad-yellow); }
.vw-pill.off { background: rgba(255, 69, 58, 0.18); color: var(--ipad-red); }
.vw-pill.plain::before { display: none; }
@keyframes vw-blink { 50% { opacity: 0.25; } }

/* indicadores do plantão */
.vw-stats { display: flex; align-items: center; gap: 8px; }
.vw-kpi {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 78px;
  padding: 6px 12px;
  border-radius: 14px;
  background: var(--ipad-fill-tertiary);
}
.vw-kpi b { font-size: 22px; font-weight: 650; line-height: 1; letter-spacing: -0.4px; color: var(--vw-txt); font-variant-numeric: tabular-nums; }
.vw-kpi span { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--vw-txt2); }
.vw-kpi.red b { color: var(--ipad-red); }
.vw-kpi.orange b { color: var(--ipad-orange); }
.vw-kpi.green b { color: var(--ipad-green); }
.vw-kpi.cyan b { color: var(--ipad-cyan); }

.vw-clock { display: flex; align-items: center; gap: 12px; }
.vw-time { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.vw-time b { font-size: 22px; font-weight: 650; letter-spacing: -0.3px; color: var(--vw-txt); font-variant-numeric: tabular-nums; }
.vw-time span { font-size: 11px; color: var(--vw-txt2); text-transform: capitalize; }

.vw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--ipad-fill-tertiary);
  color: var(--vw-txt);
  font-size: 15px;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--animation-fast) var(--ease-ios), transform var(--animation-fast) var(--ease-ios);
}
.vw-btn:hover { background: var(--ipad-fill-secondary); }
.vw-btn:active { transform: scale(0.94); }

/* ---------- painéis laterais ---------- */
.vw-panel {
  position: absolute;
  top: 96px;
  bottom: 88px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  z-index: 4;
  overflow: hidden;
}
.vw-left { left: 16px; }
.vw-right { right: 16px; bottom: auto; height: auto; max-height: calc(100% - 184px); overflow-y: auto; }

.vw-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--vw-txt);
}
.vw-panel-title i:first-child { color: var(--vw-txt2); font-size: 12px; }
.vw-panel-title .vw-count {
  margin-left: auto;
  font: 600 12px/1 var(--font-mono);
  color: var(--vw-txt2);
  background: var(--ipad-fill-tertiary);
  padding: 4px 8px;
  border-radius: var(--radius-pill);
}
.vw-panel-title.mt { margin-top: 6px; }
.vw-hint { margin-left: auto; font-size: 11px; font-weight: 400; color: var(--vw-txt3); }

/* segmentado (Ocorrências · Unidades) */
.vw-tabs {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: var(--ipad-fill-tertiary);
}
.vw-tabs button {
  flex: 1;
  min-height: 30px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--vw-txt2);
  font: 600 13px var(--font);
  cursor: pointer;
  transition: background var(--animation-fast) var(--ease-ios), color var(--animation-fast) var(--ease-ios);
}
.vw-tabs button.on {
  background: var(--vw-seg-on);
  color: var(--vw-txt);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* chips de opção (câmera, imagem, camadas, ações) */
.vw-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.vw-btns button {
  flex: 1 1 auto;
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--ipad-fill-tertiary);
  color: var(--vw-txt2);
  font: 500 13px var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--animation-fast) var(--ease-ios), color var(--animation-fast) var(--ease-ios);
}
.vw-btns button:hover { background: var(--ipad-fill-secondary); }
.vw-btns button.on { background: var(--ipad-blue); color: #fff; font-weight: 600; }
.vw-btns button i { margin-right: 6px; opacity: 0.9; }

/* lista de contatos */
.vw-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.vw-list::-webkit-scrollbar,
.vw-right::-webkit-scrollbar { width: 6px; }
.vw-list::-webkit-scrollbar-thumb,
.vw-right::-webkit-scrollbar-thumb { background: var(--ipad-fill-secondary); border-radius: 4px; }

.vw-contact {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-medium);
  background: var(--vw-row);
  cursor: pointer;
  transition: background var(--animation-fast) var(--ease-ios), box-shadow var(--animation-fast) var(--ease-ios);
}
.vw-contact:hover { background: var(--vw-row-hover); }
.vw-contact > div { min-width: 0; }
.vw-contact.on {
  background: color-mix(in srgb, var(--ipad-blue) 20%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ipad-blue) 55%, transparent);
}
.vw-contact .bar { width: 10px; height: 10px; border-radius: 50%; background: var(--ipad-gray); }
.vw-contact .bar.P0 { background: var(--ipad-red); box-shadow: 0 0 0 4px rgba(255, 69, 58, 0.2); }
.vw-contact .bar.P1 { background: var(--ipad-orange); }
.vw-contact .bar.P2 { background: var(--ipad-yellow); }
.vw-contact .bar.P3,
.vw-contact .bar.P4 { background: var(--ipad-blue); }
.vw-contact .bar.SAMU { background: var(--ipad-red); }
.vw-contact .bar.CB { background: var(--ipad-orange); }
.vw-contact .bar.PM { background: var(--ipad-blue); }
.vw-contact .bar.DC { background: var(--ipad-teal); }
.vw-contact .t {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--vw-txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vw-contact .s {
  font-size: 12px;
  color: var(--vw-txt2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.vw-contact .s.rua { color: var(--ipad-blue); font-weight: 500; }
.vw-contact .d {
  font: 600 13px var(--font);
  font-variant-numeric: tabular-nums;
  color: var(--vw-txt);
  text-align: right;
  white-space: nowrap;
}
.vw-contact .d small { display: block; font-size: 11px; font-weight: 400; color: var(--vw-txt2); }

/* telemetria — lista agrupada iPadOS */
.vw-tele {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
  padding: 2px 12px;
  border-radius: var(--radius-medium);
  background: var(--vw-row);
}
.vw-tele div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 0.5px solid var(--vw-hairline);
}
.vw-tele div:nth-last-child(-n + 2) { border-bottom: 0; }
.vw-tele span { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--vw-txt2); }
.vw-tele b { font-size: 13px; font-weight: 600; color: var(--vw-txt); font-variant-numeric: tabular-nums; white-space: nowrap; }
.vw-tele b.green { color: var(--ipad-green); }
.vw-tele-sep {
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 8px 0 4px;
  border-top: 0.5px solid var(--vw-hairline);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--vw-txt2);
}

/* origem dos dados */
.vw-fonte { display: flex; }
.vw-fonte span { white-space: normal; line-height: 1.35; }
.vw-fonte span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
}
.vw-fonte span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.vw-fonte .vw-live { background: rgba(48, 209, 88, 0.18); color: var(--ipad-green); }
.vw-fonte .vw-sim { background: rgba(255, 214, 10, 0.2); color: var(--ipad-yellow); }
.vw-fonte .vw-off { background: rgba(255, 69, 58, 0.18); color: var(--ipad-red); }

/* ---------- marcadores sobre o mapa ---------- */
.vw-detections { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.vw-box { position: absolute; transform: translate(-50%, -50%); pointer-events: none; }
.vw-box i {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: var(--c, var(--ipad-blue));
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--c, var(--ipad-blue)) 28%, transparent), 0 2px 6px rgba(0, 0, 0, 0.5);
}
.vw-box span {
  position: absolute;
  left: 16px;
  top: -14px;
  display: block;
  padding: 5px 10px;
  border-radius: 12px;
  background: var(--vw-material-strong);
  border: 1px solid var(--vw-hairline);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  font: 600 12px var(--font);
  letter-spacing: -0.1px;
  color: var(--vw-txt);
  white-space: nowrap;
}
.vw-box span small { display: block; font-weight: 400; font-size: 11px; color: var(--vw-txt2); }
.vw-box.unit i { width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; }
.vw-box.p0 i { animation: vw-ping 1.4s ease-out infinite; }
@keyframes vw-ping {
  0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 45%, transparent); }
  70% { box-shadow: 0 0 0 16px color-mix(in srgb, var(--c) 0%, transparent); }
  100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 0%, transparent); }
}

/* ---------- alerta de nova ocorrência ---------- */
.vw-alert {
  position: absolute;
  left: 50%;
  top: 96px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-radius: var(--radius-large);
  background: var(--vw-material-strong);
  border: 1px solid color-mix(in srgb, var(--ipad-red) 55%, transparent);
  box-shadow: var(--shadow-elevated);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  z-index: 6;
  animation: vw-alert-in var(--animation-normal) var(--ease-spring);
}
.vw-alert[hidden] { display: none; }
.vw-alert i { font-size: 22px; color: var(--ipad-red); }
.vw-alert b { display: block; font-size: 15px; font-weight: 650; letter-spacing: -0.2px; color: var(--vw-txt); }
.vw-alert span { font-size: 13px; color: var(--vw-txt2); }
@keyframes vw-alert-in { from { transform: translate(-50%, -14px); opacity: 0; } }

/* ---------- rodapé: últimos eventos ---------- */
.vw-bottom {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  z-index: 5;
}
.vw-ticker { flex: 1; display: flex; align-items: center; gap: 10px; overflow: hidden; }
.vw-ticker-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--vw-txt2); white-space: nowrap; }
.vw-ticker-track {
  display: flex;
  gap: 8px;
  overflow: hidden;
  mask-image: linear-gradient(90deg, #000 88%, transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
}
.vw-ticker-track span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--ipad-fill-tertiary);
  font-size: 13px;
  color: var(--vw-txt);
  white-space: nowrap;
}
.vw-ticker-track span b { font: 500 12px var(--font-mono); color: var(--vw-txt2); }
.vw-ticker-track span.red { background: rgba(255, 69, 58, 0.18); color: var(--ipad-red); }
.vw-ticker-track span.red b { color: color-mix(in srgb, var(--ipad-red) 80%, var(--vw-txt)); }
.vw-credits { position: relative; font-size: 11px; color: var(--vw-txt3); white-space: nowrap; }
.vw-credits a { color: var(--vw-txt2); text-decoration: none; }
.vw-credits img { display: none; }
.vw-credits .cesium-widget-credits,
.vw-credits .cesium-credit-lightbox-overlay { position: static !important; font: 400 11px var(--font) !important; color: var(--vw-txt3) !important; }
.vw-credits .cesium-credit-expand-link { color: var(--vw-txt2) !important; text-decoration: none !important; }

/* ---------- carregamento ---------- */
.vw-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  background: var(--vw-globe);
  z-index: 10;
  color: var(--vw-txt2);
  font: 500 14px var(--font);
}
.vw-loading i { font-size: 28px; color: var(--ipad-blue); animation: vw-spin 1.4s linear infinite; }
@keyframes vw-spin { to { transform: rotate(360deg); } }

@media (max-width: 1280px) {
  .vw-panel { width: 280px; }
  .vw-kpi { min-width: 66px; padding: 6px 8px; }
}
@media (max-width: 1100px) { .vw-stats { display: none; } }
@media (max-width: 820px) {
  .vw-right { display: none; }
  .vw-left { bottom: 84px; width: 220px; }
}
