/* Cell-network page — built on the same dark-tactical palette as the
   main jafo dashboard. Loaded after style.css, only the cell-* / KPI
   selectors here are scoped to this page. */

/* Override the global html/body lock from style.css (which is built for
   the scanner dashboard's fixed-viewport grid). This page is a long
   document that needs to scroll. */
html, body.cell-page {
  height: auto !important;
  overflow: visible !important;
}
body.cell-page {
  background: #0a1218;
  color: #e8eef3;
  display: block;          /* override grid from style.css */
}

.brand-link { display: inline-block; }

/* Keep the topbar visible while scrolling so the "← Scanner" link is
   always reachable. */
body.cell-page > .topbar {
  position: sticky;
  top: 0;
  z-index: 50;
}

.cell-main {
  max-width: 1280px;       /* slightly narrower for better centered feel */
  margin: 0 auto;
  padding: 20px 24px 80px;
}

/* ---------- KPI row ---------- */
.cell-dash {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.cell-card.kpi {
  background: #111c25;
  border: 1px solid #1f2c37;
  border-radius: 8px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cell-card.kpi .kpi-label {
  font: 600 11px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7aa6c7;
}
.cell-card.kpi .kpi-value {
  font: 600 22px/1.1 system-ui, sans-serif;
  color: #ffe87a;
  letter-spacing: -0.01em;
}
.cell-card.kpi .kpi-sub {
  font: 11px/1.3 ui-monospace, "SF Mono", Menlo, monospace;
  color: #8da4b6;
}
.cell-card.kpi.alert .kpi-value { color: #ff8a4c; }
.cell-card.kpi.new   .kpi-value { color: #4cc06b; }

/* ---------- Map ---------- */
.cell-map-section {
  margin-bottom: 16px;
}
.cell-map {
  height: 380px;
  border-radius: 8px;
  border: 1px solid #1f2c37;
  background: #0a1218;
  overflow: hidden;
  /* Lighten the OSM tiles to match the rest of jafo's color scheme */
  filter: brightness(0.92) contrast(1.05) saturate(0.85);
}

/* operator-coded tower dots */
.cell-marker.q-excellent { filter: drop-shadow(0 0 6px currentColor); }
.cell-marker.q-poor      { opacity: 0.65; }
.cell-marker.q-marginal  { opacity: 0.4; }

.cell-popup .popup-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid #cfd9e1;
  padding-bottom: 4px;
}
.cell-popup .popup-rat {
  font: 10px/1 ui-monospace, "SF Mono", Menlo, monospace;
  color: #6c7a86;
}
.cell-popup .popup-row {
  display: flex;
  justify-content: space-between;
  font: 12px/1.4 system-ui, sans-serif;
}
.cell-popup .popup-row span:first-child {
  color: #6c7a86;
}

/* ---------- Block sections ---------- */
.cell-block {
  background: #111c25;
  border: 1px solid #1f2c37;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.cell-block h2 {
  font: 600 13px/1 ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7aa6c7;
  margin: 0 0 10px;
}
.cell-block.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.cell-block.grid-2 > div { min-width: 0; }
@media (max-width: 760px) {
  .cell-block.grid-2 { grid-template-columns: 1fr; }
}

.block-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}
.block-controls { display: flex; gap: 8px; }
.block-controls select {
  background: #0c151c;
  border: 1px solid #1f2c37;
  color: #d6e0e8;
  padding: 4px 8px;
  border-radius: 5px;
  font: 12px ui-monospace, "SF Mono", Menlo, monospace;
}

/* ---------- Tables ---------- */
.cell-table {
  width: 100%;
  border-collapse: collapse;
  font: 12px/1.45 ui-monospace, "SF Mono", Menlo, monospace;
}
.cell-table th, .cell-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #1a2632;
  text-align: left;
  white-space: nowrap;
}
.cell-table th {
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7aa6c7;
  font-weight: 600;
}
.cell-table tbody tr {
  transition: background 0.1s ease;
  cursor: pointer;
}
.cell-table tbody tr:hover {
  background: #182632;
}
.cell-table .empty {
  text-align: center;
  color: #6c7a86;
  font-style: italic;
}
.cell-table.compact th, .cell-table.compact td { padding: 4px 8px; }

.op-dot {
  display: inline-block;
  width: 9px; height: 9px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: -1px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

/* RSRP quality chips */
.quality {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 11px;
  font-size: 11px;
  border: 1px solid currentColor;
  letter-spacing: 0.02em;
}
.q-excellent { color: #4cc06b; }
.q-good      { color: #88c060; }
.q-fair      { color: #e8d23c; }
.q-poor      { color: #ec8a3c; }
.q-marginal  { color: #ec4848; }
.q-unknown   { color: #8da4b6; }

.cell-empty {
  margin-top: 10px;
  padding: 14px;
  background: #0c151c;
  border: 1px dashed #1f2c37;
  border-radius: 6px;
  color: #7aa6c7;
  font: 12px/1.45 ui-monospace, "SF Mono", Menlo, monospace;
}
.cell-empty code {
  background: #1a2632;
  padding: 1px 5px;
  border-radius: 3px;
  color: #ffe87a;
}

/* FCC ASR towers — sized by cell count, colored by dominant operator.
   Only towers with at least one observed cell pinned to them appear; the
   color matches the cell-observation dots so a tower and its cells read
   as visually-linked. */
.asr-marker {
  width: 0; height: 0;
  border-left:  calc(var(--asr-size, 16px) / 2) solid transparent;
  border-right: calc(var(--asr-size, 16px) / 2) solid transparent;
  border-bottom: var(--asr-size, 16px) solid var(--asr-color, #ffffff);
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.9))
          drop-shadow(0 0 4px rgba(255, 255, 255, 0.4));
  opacity: 0.9;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.asr-marker:hover {
  opacity: 1;
  transform: scale(1.25);
}
.asr-toggle-wrap {
  background: #111c25;
  border: 1px solid #1f2c37 !important;
  border-radius: 5px !important;
}
.asr-toggle {
  background: transparent;
  border: 0;
  color: #d6e0e8;
  padding: 5px 9px;
  font: 11px ui-monospace, "SF Mono", Menlo, monospace;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.asr-toggle.active { color: #ffe87a; }
.asr-toggle:hover  { background: #182632; }

/* "Where am I" marker — bright blue dot with a soft pulse, plus an
   accuracy circle (rendered as a Leaflet L.circle, not styled here).
   Sits non-interactive so it doesn't intercept clicks on cell markers. */
.my-location {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #3a8df0;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.95),
              0 0 12px rgba(58, 141, 240, 0.85);
  animation: my-loc-pulse 2.4s ease-in-out infinite;
}
@keyframes my-loc-pulse {
  0%, 100% { transform: scale(1);   opacity: 1;   }
  50%      { transform: scale(1.18); opacity: 0.85; }
}

/* "Use my location" fallback button — appears only if the initial
   geolocation request was denied / blocked by a non-secure context. */
.locate-wrap {
  background: #111c25;
  border: 1px solid #1f2c37 !important;
  border-radius: 5px !important;
}
.locate-btn {
  background: transparent;
  border: 0;
  color: #d6e0e8;
  padding: 4px 8px;
  font-size: 14px;
  cursor: pointer;
}
.locate-btn:hover { background: #182632; }

/* Status banner that flashes above the map when geolocation succeeds/fails.
   Hidden by default; .show fades it in for ~6 seconds. */
.locate-msg {
  margin: 0 0 8px 0;
  padding: 7px 12px;
  background: #0c2538;
  border: 1px solid #1f3a52;
  border-radius: 6px;
  color: #b0d2ed;
  font: 12px/1.4 ui-monospace, "SF Mono", Menlo, monospace;
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.2s ease, max-height 0.25s ease;
}
.locate-msg.show {
  opacity: 1;
  max-height: 80px;
}
.locate-msg.err {
  background: #2c1418;
  border-color: #5a1f25;
  color: #ffb0b0;
}

/* On touch devices, drop the map to the bottom of the page so the KPI cards
   and tables read first under the topbar — same pattern as the main jafo
   dashboard. (pointer: coarse) covers phones + tablets + touch laptops. */
@media (pointer: coarse) {
  .cell-main {
    display: flex;
    flex-direction: column;
  }
  .cell-main > .cell-dash         { order: 1; }
  .cell-main > .cell-block        { order: 2; }
  .cell-main > .cell-block.grid-2 { order: 3; }
  .cell-main > .cell-map-section  { order: 4; }
  /* Slightly shorter map at the bottom so it doesn't dominate the screen */
  .cell-map { height: 320px; }
}
