/* SynTel™ Server — Custom CSS beyond TailwindCSS */

:root {
  --color-active: #22c55e;
  --color-degraded: #eab308;
  --color-down: #ef4444;
  --color-maintenance: #6b7280;
  --color-primary: #3b82f6;
  --color-accent: #06b6d4;
  --bg-dark: #0a0a0a;
  --bg-card: #1a1a1a;
  --bg-input: #2a2a2a;
  --bg-overlay: rgba(10, 10, 10, 0.88);
  --border-color: #333;
  --text-primary: #f8fafc;
  --text-secondary: #999;
  --bottom-panel-height: 15vh;
}

body {
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  overflow: hidden;
  height: 100vh;
}

/* Global themed scrollbar */
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: #444; border-radius: 2px; }
*::-webkit-scrollbar-thumb:hover { background: #666; }

/* ── Full-screen map (always full viewport, independent of bottom panel) ── */
#map {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
}

#infrastructure {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: var(--bg-dark);
}

/* ── Logo overlay (top-left) ── */
.overlay-logo {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 1000;
  background: var(--bg-overlay);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  height: 38px;
  box-sizing: border-box;
}

/* ── View toggle — matches logo container style ── */
.overlay-view-toggle {
  position: fixed;
  top: 0.75rem;
  left: calc(0.75rem + var(--logo-width, 110px) + 0.5rem);
  z-index: 1000;
  display: flex;
  align-items: center;
  height: 38px;
  box-sizing: border-box;
  gap: 0;
  border-radius: 0.5rem;
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.view-btn {
  padding: 0 0.5rem;
  height: 100%;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 36px;
}

.view-btn:hover {
  color: var(--text-primary);
  background: var(--bg-input);
}

.view-btn.active {
  background: #00ba61;
  color: #fff;
}

/* ── Status overlay (top-right) — real clock ── */
.overlay-status {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-overlay);
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  height: 38px;
  box-sizing: border-box;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.green { background: var(--color-active); }
.status-dot.yellow { background: var(--color-degraded); }
.status-dot.red { background: var(--color-down); }

.clock-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Courier New', monospace;
  font-size: 0.75rem;
}

.clock-date {
  color: var(--text-primary);
  font-weight: 600;
  letter-spacing: 0.03em;
}

.clock-sep {
  color: var(--border-color);
}

.clock-time {
  color: var(--text-secondary);
}

.clock-zulu {
  color: #f59e0b;
}

/* ── Filter bars (top-center, always visible, no collapse) ── */
.overlay-filter-bar {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.overlay-filter-bar .bar-content {
  display: flex;
  gap: 0.75rem;
  background: var(--bg-overlay);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  align-items: center;
  height: 38px;
  box-sizing: border-box;
}

.filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

.filter-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cb-custom {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--text-secondary);
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.cb-custom::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity 0.15s;
}

.filter-checkbox input[type="checkbox"]:checked + .cb-custom {
  border-color: var(--color-primary);
}

.filter-checkbox input[type="checkbox"]:checked + .cb-custom::after {
  opacity: 1;
}

/* ══════════════════════════════════════════════════════
   ═══ Bottom Panel (metrics | charts | activity) ═══
   ══════════════════════════════════════════════════════ */
#bottom-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100vw;
  height: var(--bottom-panel-height);
  min-height: 80px;
  max-height: 60vh;
  z-index: 1000;
  background: rgba(10, 10, 10, 0.95);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.bottom-panel-drag {
  height: 6px;
  cursor: ns-resize;
  background: transparent;
  position: relative;
  flex-shrink: 0;
}

.bottom-panel-drag::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 3px;
  border-radius: 2px;
  background: #555;
  transition: background 0.15s;
}

.bottom-panel-drag:hover::after {
  background: #888;
}

.bottom-panel-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 1px;
}

.bottom-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0.375rem 0.5rem;
}

.bottom-col-title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
  flex-shrink: 0;
}

/* Left column: metrics */
.bottom-col-metrics {
  width: 300px;
  flex-shrink: 0;
  border-right: 1px solid var(--border-color);
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.375rem;
  flex: 1;
  align-content: start;
}

.metric-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 0.375rem 0.5rem;
  text-align: center;
  min-width: 0;
}

.metric-label {
  font-size: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Center column: charts */
.bottom-col-charts {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--border-color);
}

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 0.5rem;
  flex: 1;
  min-height: 0;
}

.chart-cell {
  min-height: 0;
  display: flex;
  align-items: stretch;
}

.chart-cell canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Right column: activity feed */
.bottom-col-activity {
  width: 320px;
  flex-shrink: 0;
}

.activity-body {
  overflow-y: auto;
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 0.65rem;
  line-height: 1.5;
  color: #4ade80;
  pointer-events: auto;
  user-select: text;
}

.activity-body::-webkit-scrollbar {
  width: 4px;
}

.activity-body::-webkit-scrollbar-track {
  background: transparent;
}

.activity-body::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 2px;
}

.activity-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-line .ts {
  color: #666;
}

.activity-line .ue-event {
  color: #4ade80;
}

.activity-line .msg-event {
  color: #38bdf8;
}

.activity-line .ho-event {
  color: #c084fc;
}

.activity-line .data-event {
  color: #22d3ee;
}

.activity-line .voice-event {
  color: #fbbf24;
}

/* ── Side panels (infra detail — still collapse-able) ── */
.side-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #fff;
  background: #00ba61;
  border: 1px solid rgba(0, 186, 97, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s;
  flex-shrink: 0;
  user-select: none;
  width: 28px;
  padding: 12px 0;
  flex-direction: column;
  gap: 8px;
}

.side-tab:hover {
  background: #00d470;
}

.tab-icon {
  font-size: 0.5rem;
  transition: transform 0.3s;
  display: block;
  line-height: 1;
  opacity: 0.8;
}

.tab-label-v {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  writing-mode: vertical-lr;
  text-orientation: mixed;
}

.overlay-side {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1000;
  display: flex;
  align-items: center;
  max-height: calc(100vh - 8rem);
}

.overlay-side.right {
  right: 0.5rem;
}

.overlay-side.right .side-tab {
  border-radius: 0.375rem 0 0 0.375rem;
  border-right: none;
}

.side-content {
  width: 280px;
  max-height: calc(100vh - 8rem);
  background: var(--bg-overlay);
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease, opacity 0.3s ease;
  opacity: 1;
}

.overlay-side.collapsed .side-content {
  width: 0;
  opacity: 0;
  border-color: transparent;
  padding: 0;
}

.overlay-side.collapsed .side-tab .tab-icon {
  transform: rotate(180deg);
}

/* ── Leaflet overrides ── */
.leaflet-popup-content-wrapper {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border-radius: 0.5rem !important;
}

.leaflet-popup-tip {
  background: var(--bg-card) !important;
}

.leaflet-control-zoom a {
  background: var(--bg-overlay) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-color) !important;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.leaflet-control-zoom a:hover {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
}

.leaflet-control-attribution {
  background: rgba(10, 10, 10, 0.7) !important;
  color: #666 !important;
  font-size: 0.6rem !important;
}

.leaflet-control-attribution a {
  color: #888 !important;
}

.leaflet-control-layers {
  display: none !important;
}

/* Individual site dot markers */
.site-dot {
  background: transparent !important;
  border: none !important;
}

.site-dot div {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid;
  opacity: 0.9;
}

/* MarkerCluster */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
  transition: transform 0.3s ease-out, opacity 0.3s ease-in;
}

.leaflet-cluster-spider-leg {
  transition: stroke-dashoffset 0.3s ease-out, stroke-opacity 0.3s ease-in;
}

.syntel-cluster {
  background: transparent !important;
  border: none !important;
  margin: 0 !important;
}

.cluster-donut {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cluster-inner {
  background: rgba(26, 26, 26, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 0.75rem;
  font-weight: 700;
}

/* Site popup styles */
.site-popup .popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  padding-bottom: 0.375rem;
  border-bottom: 1px solid var(--border-color);
}

.site-popup .popup-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.popup-status-badge {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  color: #fff;
}

.popup-kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.375rem;
  margin-bottom: 0.5rem;
}

.popup-kpi {
  background: var(--bg-input);
  border-radius: 0.25rem;
  padding: 0.25rem 0.375rem;
  text-align: center;
}

.popup-kpi-val {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.popup-kpi-label {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.popup-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.5rem;
}

.popup-tag {
  font-size: 0.55rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  border-radius: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.popup-tag.tech {
  background: rgba(59, 130, 246, 0.2);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.popup-tag.band {
  background: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.25);
}

.site-popup .popup-actions {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.popup-btn-row {
  display: flex;
  gap: 0.25rem;
}

.popup-status-btn {
  flex: 1;
  padding: 0.25rem 0;
  border-radius: 0.25rem;
  border: 1px solid var(--border-color);
  font-size: 0.6rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg-input);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: all 0.15s;
  text-align: center;
}

.popup-status-btn:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.popup-status-btn.active-status { background: var(--color-active); color: white; border-color: var(--color-active); }
.popup-status-btn.degraded-status { background: var(--color-degraded); color: var(--bg-dark); border-color: var(--color-degraded); }
.popup-status-btn.down-status { background: var(--color-down); color: white; border-color: var(--color-down); }
.popup-status-btn.maintenance-status { background: var(--color-maintenance); color: white; border-color: var(--color-maintenance); }

/* Sector arc tooltip */
.sector-tooltip {
  background: var(--bg-card) !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 0.375rem !important;
  padding: 0.375rem 0.5rem !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5) !important;
}

.sector-tooltip::before {
  border-top-color: var(--border-color) !important;
}

/* ── Infrastructure detail panel ── */
.infra-detail-body {
  padding: 0.75rem;
  font-size: 0.8rem;
}

.infra-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.infra-detail-name { font-weight: 700; font-size: 1rem; color: var(--text-primary); }
.infra-detail-badge { font-size: 0.6rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; padding: 0.15rem 0.5rem; border-radius: 0.25rem; color: #fff; }
.infra-detail-meta { margin-bottom: 0.75rem; font-size: 0.75rem; color: var(--text-secondary); line-height: 1.6; }
.infra-detail-metrics { margin-bottom: 0.75rem; }
.infra-detail-section-title { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 0.375rem; margin-top: 0.5rem; }
.infra-detail-metric-row { display: flex; justify-content: space-between; padding: 0.25rem 0; border-bottom: 1px solid rgba(51, 51, 51, 0.5); font-size: 0.75rem; }
.infra-detail-metric-key { color: var(--text-secondary); }
.infra-detail-metric-val { color: var(--text-primary); font-weight: 600; font-family: 'Courier New', monospace; }

/* ── Infrastructure legend ── */
.overlay-legend {
  position: fixed;
  bottom: calc(var(--bottom-panel-height) + 0.75rem);
  left: 0.75rem;
  z-index: 1000;
  background: var(--bg-overlay);
  padding: 0.625rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  font-size: 0.7rem;
  max-width: 180px;
}

.legend-title { font-weight: 700; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-primary); margin-bottom: 0.5rem; }
.legend-section { margin-bottom: 0.5rem; }
.legend-subtitle { font-weight: 600; font-size: 0.65rem; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.25rem; }
.legend-item { display: flex; align-items: center; gap: 0.375rem; color: var(--text-secondary); padding: 0.1rem 0; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }
.legend-line { width: 16px; height: 3px; border-radius: 1px; flex-shrink: 0; }

/* ── Infrastructure map markers ── */
.infra-map-marker { background: transparent !important; border: none !important; }
.infra-map-marker-inner {
  width: 24px; height: 24px; border-radius: 4px;
  border: 2px solid; display: flex; align-items: center; justify-content: center;
  font-size: 0.5rem; font-weight: 700; color: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5); cursor: pointer;
}

/* ── Infrastructure filter bar ── */
.infra-filter-checkbox {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}

.infra-filter-checkbox input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.infra-cb-custom {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--text-secondary);
  background: var(--bg-input);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}

.infra-cb-custom::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 2px;
  opacity: 0;
  transition: opacity 0.15s;
}

.infra-filter-checkbox input[type="checkbox"]:checked + .infra-cb-custom {
  border-color: var(--cat-color, var(--color-primary));
}

.infra-filter-checkbox input[type="checkbox"]:checked + .infra-cb-custom::after {
  background: var(--cat-color, var(--color-primary));
  opacity: 1;
}

.infra-severity-select,
.infra-search-input {
  padding: 0.25rem 0.5rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  color: var(--text-primary);
  font-size: 0.7rem;
}

.infra-search-input {
  width: 120px;
}

.infra-search-input::placeholder {
  color: var(--text-secondary);
}

/* ── Responsive ── */
@media (max-width: 1200px) {
  .bottom-col-metrics { width: 240px; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .bottom-col-activity { width: 260px; }
  .charts-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 800px) {
  .bottom-col-metrics { width: 180px; }
  .metrics-grid { grid-template-columns: 1fr; }
  .bottom-col-activity { width: 200px; }
  .charts-grid { grid-template-columns: 1fr; }
}
