* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0b1020;
  color: #e6e9ef;
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

#canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}
#bottomHud {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 11;
  pointer-events: none;
}
#bottomHud .row {
  pointer-events: auto;
}
/* reset toggleControls to behave like a normal button inside HUD */
#toggleControls { position: static; right: auto; bottom: auto; z-index: auto; }

/* Icon-only button style for HUD controls */
#toggleControls.icon-btn, #toggleBgLock.icon-btn, #zoomIn.icon-btn, #zoomOut.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: #e6e9ef;
  background: #11182a;
  border: 1px solid #2a3550;
  border-radius: 6px;
}
#toggleControls.icon-btn:hover, #toggleBgLock.icon-btn:hover, #zoomIn.icon-btn:hover, #zoomOut.icon-btn:hover { background: #162038; }
#toggleControls.icon-btn:focus-visible, #toggleBgLock.icon-btn:focus-visible, #zoomIn.icon-btn:focus-visible, #zoomOut.icon-btn:focus-visible { outline: 2px solid #7aa2f7; outline-offset: 2px; }
#toggleControls.icon-btn svg, #toggleBgLock.icon-btn svg { fill: currentColor; opacity: 0.95; width: 18px; height: 18px; }

/* Active state for BG lock */
#toggleBgLock.active { background: #162038; border-color: #3a4a72; color: #a6d189; }

/* Brand widget uses the same background as modal panels for clarity */
#brandWidget {
  background: #1d2742;
  border: none;
  border-radius: 8px;
  padding: 6px 8px;
}


#ui {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

#ui .row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(20, 26, 40, 0.5);
  backdrop-filter: blur(6px);
  pointer-events: auto;
  flex-wrap: wrap;
}

#dronesHud {
  align-self: flex-start;
  width: auto;
}

#dronesHudTable {
  table-layout: fixed;
}

#dronesHudTable th,
#dronesHudTable td {
  white-space: nowrap;
}

/* Fixed column widths */
#dronesHudTable th:nth-child(1),
#dronesHudTable td:nth-child(1) { width: 80px; }
#dronesHudTable th:nth-child(2),
#dronesHudTable td:nth-child(2) { width: 80px; }
#dronesHudTable th:nth-child(3),
#dronesHudTable td:nth-child(3) { width: 90px; }
#dronesHudTable th:nth-child(4),
#dronesHudTable td:nth-child(4) { width: 60px; }
#dronesHudTable th:nth-child(5),
#dronesHudTable td:nth-child(5) { width: 60px; }
#dronesHudTable th:nth-child(6),
#dronesHudTable td:nth-child(6) { width: 60px; }
#dronesHudTable th:nth-child(7),
#dronesHudTable td:nth-child(7) { width: 70px; }
#dronesHudTable th:nth-child(8),
#dronesHudTable td:nth-child(8) { width: 70px; }

.hud-line {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
.hud-left, .hud-center, .hud-right { display: flex; }
.hud-left { justify-content: flex-start; }
.hud-center { justify-content: center; }
.hud-right { justify-content: flex-end; }
/* Pin settings/reload to top-right of window */
#topRightButtons {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 12;
  background: transparent;
  border: none;
  padding: 0;
}
#topRightButtons .hud-widget { background: transparent; }
/* Rounded containers for each HUD cell */
.hud-left, .hud-center, .hud-right {
  border: 1px solid #2b2f3a;
  border-radius: 8px;
  background: rgba(20, 26, 40, 0.55);
  backdrop-filter: blur(6px);
  padding: 6px;
}
/* Avoid double backgrounds by neutralizing inner row styling inside HUD cells */
.hud-left > .row, .hud-center > .row, .hud-right > .row {
  background: transparent;
  padding: 0;
}
.brand { display:flex; align-items:center; gap:10px; padding-right:8px; border-right:1px solid #2b2f3a; }
.brand-logo { width:28px; height:28px; object-fit:contain; border-radius:4px; background:#fff; }
.brand-text { display:flex; flex-direction:column; line-height:1.1; }
.brand-name { font-weight:700; letter-spacing:0.2px; font-size:14px; }
.brand-sub { font-size:12px; opacity:0.85; }
.title-block { gap:12px; }
.title-text { line-height:1.05; }
.brand-title { font-size:14px; }
.brand-subtitle { font-size:11px; opacity:0.85; }
.brand-actions { display:none; }
.hud-widget { display: flex; align-items: center; gap: 10px; }

/* Reuse row styling inside modal panel as well */
.modal .row {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(6px);
  margin-bottom: 8px;
}

.settings-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 960px) {
  .settings-sections {
    grid-template-columns: 1fr;
  }
}

.sidget {
  border: 1px solid #2b2f3a;
  border-radius: 8px;
  background: rgba(20, 26, 40, 0.85);
  box-shadow: 0 2px 12px rgba(0,0,0,0.35);
}

.sidget-title {
  padding: 8px 10px;
  border-bottom: 1px solid #2b2f3a;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.sidget-body {
  padding: 8px;
}

/* Refined layout inside sidget bodies */
.sidget-body .row {
  background: transparent;
  backdrop-filter: none;
  padding: 8px 10px 4px 10px;
  gap: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  column-gap: 16px;
  row-gap: 12px;
}

.sidget .row label {
  flex: 1 1 260px;
  min-width: 240px;
}

/* Align label text and input boxes in controls dialog */
.sidget .row label {
  display: grid;
  grid-template-columns: 1fr 220px;
  align-items: center;
  justify-items: start;
  column-gap: 8px;
  width: 100%;
}

/* Labels that include a live value after the input (e.g., range + span) */
.sidget .row label:has(input[type="range"] + span),
.sidget .row label:has(input[type="number"] + span),
.sidget .row label:has(input[type="text"] + span),
.sidget .row label:has(select + span) {
  grid-template-columns: 1fr 220px auto;
}

/* Keep simple checkbox labels inline so the box remains next to the text */
.sidget .row label:has(input[type="checkbox"]) {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-start;
}

.sidget input[type="number"] {
  width: 220px;
  text-align: left;
}

.sidget input[type="text"] {
  width: 220px;
}

.sidget input[type="range"] {
  width: 220px;
}

.sidget select {
  width: 220px;
}

/* Increase vertical spacing between elements inside controls dialog */
.sidget-body .row {
  row-gap: 12px;
  padding: 10px 12px 8px 12px;
}

.sidget input[type="file"] {
  max-width: 100%;
}

#ui .row.stats {
  gap: 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  align-items: stretch;
}
.modal { z-index: 50; background: rgba(0,0,0,0.25) !important; }
.modal .panel, .panel {
  background: #1d2742 !important;
  border-color: #3a4a72 !important;
  box-shadow: 0 10px 28px rgba(0,0,0,0.45), 0 2px 8px rgba(0,0,0,0.3) !important;
}
/* Slightly lighter sidgets inside modals for contrast */
.modal .sidget {
  background: rgba(29, 39, 66, 0.92);
  border-color: #3a4a72;
}
.modal > div {
  background: #1d2742 !important;
  border-color: #3a4a72 !important;
}
#flightPlansModal { background: rgba(29, 39, 66, 0.94) !important; }
#fpCreateDialog > div {
  background: #1d2742 !important;
  border-color: #3a4a72 !important;
}
#initOverlay > div {
  background: #1d2742 !important;
  border-color: #3a4a72 !important;
}
#resetOverlay > div {
  background: #1d2742 !important;
  border-color: #3a4a72 !important;
}
.stat-cell {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid #2b2f3a;
  border-radius: 6px;
  padding: 6px 8px;
  background: rgba(20, 26, 40, 0.45);
}
.stat-label {
  font-size: 8px;
  opacity: 0.6;
}
.stat-value {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
/* Legacy ids alignment if used elsewhere */
#clock { text-align: left; }
#diagStatus { text-align: left; }

/* Hide specific HUD metric values, leave labels visible */
#agentsValueWrap,
#agentsWeighted,
#citiesCount,
#intercityValueWrap { display: none !important; }

/* Hide the entire cells (labels + values) for these metrics */
.stat-cell:has(#agentsValueWrap),
.stat-cell:has(#agentsWeighted),
.stat-cell:has(#citiesCount),
.stat-cell:has(#intercityValueWrap) { display: none !important; }

button {
  padding: 8px 12px;
  border: 1px solid #2a3550;
  background: #11182a;
  color: #e6e9ef;
  border-radius: 6px;
  cursor: pointer;
}

button:hover {
  background: #162038;
}

/* Avoid horizontal shift when toggling Run/Pause text */
#toggleRun,
#fpToggleRun {
  width: 72px;
  text-align: center;
  white-space: nowrap;
}

/* Danger variant for Close buttons */
button[id*="Close"],
button[id*="close"] {
  background: #dc3545;
  border-color: #dc3545;
  color: #fff;
}
button[id*="Close"]:hover,
button[id*="close"]:hover { background: #bb2d3b; border-color: #b02a37; }
button[id*="Close"]:focus-visible,
button[id*="close"]:focus-visible { outline: 2px solid rgba(220,53,69,0.6); outline-offset: 2px; }

/* Primary variant (Bootstrap blue) */
button.btn-primary {
  background: #0d6efd;
  border-color: #0d6efd;
  color: #fff;
}
button.btn-primary:hover { background: #0b5ed7; border-color: #0a58ca; }
button.btn-primary:focus-visible { outline: 2px solid rgba(13,110,253,0.6); outline-offset: 2px; }

label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

input[type="range"] {
  accent-color: #7aa2f7;
}

#clock {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

#stats {
  opacity: 0.9;
}


/* Version badge (bottom-right) */
.version-badge {
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 20;
  pointer-events: none;
  font-size: 11px;
  color: #e6e9ef;
  background: rgba(29, 39, 66, 0.92);
  border: 1px solid #3a4a72;
  border-radius: 6px;
  padding: 4px 6px;
}
/* Toast notifications */
.toast-container {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: rgba(29, 39, 66, 0.95);
  color: #e6e9ef;
  border: 1px solid #3a4a72;
  border-radius: 6px;
  padding: 8px 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  font-size: 13px;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
