html,
body,
#app {
  height: 100%;
  margin: 0;
  /* Let nested grid/flex shrink below content so inner panes can scroll (incl. browser zoom). */
  min-height: 0;
}

body {
  overflow: hidden;
}

.coastal-surveillance-sim {
  /* SEA.AI Design Tokens — DARK theme (default) */
  --surface-1: #101214;
  --surface-2: #181B1E;
  --surface-3: #202428;
  --surface-4: #292E33;
  --surface-5: #31373D;

  --content-hi:  #DCDEE0;
  --content-mid: #B9BDC1;
  --content-lo:  #6B7177;

  --primary:         #0A67C2;
  --primary-dim:     #084C91;
  --primary-content: #CFE5FC;
  --primary-rgb:     10, 103, 194;

  --danger:         #C20A20;
  --danger-dim:     #910818;
  --danger-content: #FA9EA9;
  --danger-rgb:     194, 10, 32;

  --warning:         #C2940A;
  --warning-content: #FAE39E;
  --warning-rgb:     194, 148, 10;

  --success:         #14A87A;
  --success-content: #6EDEB9;
  --success-rgb:     20, 168, 122;

  --stroke: 1px solid rgba(255, 255, 255, 0.07);

  --radious-s: 4px;
  --radious-m: 8px;

  --sp-xs: 4px;
  --sp-s:  8px;
  --sp-m:  12px;
  --sp-l:  16px;
  --sp-xl: 24px;

  --font: 'Saira Condensed', 'Arial Narrow', Arial, sans-serif;

  box-sizing: border-box;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--surface-1);
  color: var(--content-hi);
  font-family: var(--font);
  font-size: 16px;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 304px;
  grid-template-rows: 46px minmax(0, 1fr);
}

/* SEA.AI Design Tokens — LIGHT theme */
.coastal-surveillance-sim[data-theme="light"] {
  --surface-1: #B9BDC1;
  --surface-2: #CBCED1;
  --surface-3: #DCDEE0;
  --surface-4: #EEEFF0;
  --surface-5: #FFFFFF;

  --content-hi:  #101214;
  --content-mid: #292E33;
  --content-lo:  #6B7177;

  --primary-dim:     rgba(10, 103, 194, 0.12);
  --primary-content: #0A67C2;

  --danger-dim:     rgba(194, 10, 32, 0.1);
  --danger-content: #C20A20;

  --warning-content: #9B7508;

  --success-content: #0A6E50;

  --stroke: 1px solid rgba(0, 0, 0, 0.1);
}

.coastal-surveillance-sim *,
.coastal-surveillance-sim *::before,
.coastal-surveillance-sim *::after {
  box-sizing: border-box;
}

/* ── Header ─────────────────────────────────────────── */

#header {
  grid-column: 1 / -1;
  padding: 0 var(--sp-l);
  border-bottom: var(--stroke);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: var(--sp-l);
}

#header h1 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--content-hi);
  text-transform: uppercase;
  margin: 0;
}

#header .sub {
  font-size: 14px;
  font-weight: 400;
  color: var(--content-lo);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

#header .spacer {
  flex: 1;
}


.blink {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  animation: blink 1.4s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.15; }
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  gap: 1px;
  background: var(--surface-4);
  border-radius: var(--radious-s);
  padding: 2px;
}

.theme-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 3px;
  color: var(--content-lo);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease-in-out, color 0.2s ease-in-out;
}

.theme-btn:hover { color: var(--content-hi); }

.theme-btn.active {
  background: var(--surface-2);
  color: var(--content-hi);
}

/* ── Canvas ──────────────────────────────────────────── */

#canvas-wrap {
  position: relative;
  min-height: 0;
  background: var(--surface-1);
  overflow: hidden;
  /* Own stacking context so heavy SVG repaints don’t fight the grid panel (paint isolation). */
  isolation: isolate;
  contain: paint;
  z-index: 0;
  /* Drags were selecting compass/ring labels as text; map chrome isn’t meant to be selectable. */
  user-select: none;
  -webkit-user-select: none;
}

#canvas-wrap svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  shape-rendering: optimizeSpeed;
  -webkit-user-select: none;
  user-select: none;
}


/* ── Zoom bar ────────────────────────────────────────── */

.zoom-bar {
  position: absolute;
  bottom: var(--sp-m);
  right: var(--sp-m);
  display: flex;
  align-items: center;
  gap: var(--sp-s);
  z-index: 10;
}

.zoom-label {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 500;
  color: var(--content-mid);
  min-width: 50px;
  text-align: center;
}

.zoom-btn {
  width: 52px;
  height: 52px;
  background: var(--surface-3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radious-m);
  color: var(--content-mid);
  font-family: var(--font);
  font-size: 28px;
  font-weight: 400;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease-in-out, color 0.2s ease-in-out;
  line-height: 1;
}

.zoom-btn:hover {
  background: var(--surface-4);
  color: var(--content-hi);
}

/* ── Side panel ──────────────────────────────────────── */

#panel {
  background: var(--surface-2);
  border-left: var(--stroke);
  padding: var(--sp-s);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: var(--sp-s);
  position: relative;
  z-index: 1;
  -webkit-overflow-scrolling: touch;
}

/* ── Sections ────────────────────────────────────────── */

/* Keep natural height so the panel scrolls instead of squishing controls. */
#panel > .section {
  flex-shrink: 0;
}

.section {
  background: var(--surface-3);
  border-radius: var(--radious-m);
  overflow: hidden;
}

.section-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--content-lo);
  padding: var(--sp-s) var(--sp-m);
}

.section-body {
  padding: 0 var(--sp-m) var(--sp-m);
}

/* ── Stats grid ──────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--surface-2);
}

.stat {
  background: var(--surface-4);
  padding: var(--sp-s) var(--sp-m);
}

.stat .lbl {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--content-lo);
  margin-bottom: 2px;
}

.stat .val {
  font-size: 23px;
  font-weight: 400;
  color: var(--content-hi);
  line-height: 1.2;
}

.stat .val.active   { color: var(--success-content); }
.stat .val.inactive { color: var(--danger-content); }

.stats-extra {
  margin-top: 1px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--surface-2);
}

.st-sm { font-size: 18px; }

.stat-sub {
  font-size: 16px;
  font-weight: 400;
  color: var(--content-lo);
  margin-top: 2px;
}

.risk-row {
  display: flex;
  align-items: center;
  gap: var(--sp-s);
  margin-top: 4px;
}

.st-risk-val {
  font-size: 18px;
  min-width: 50px;
}

.risk-track {
  flex: 1;
  height: 3px;
  background: var(--surface-5);
  border-radius: 2px;
  overflow: hidden;
}

.risk-fill {
  height: 100%;
  width: 0%;
  background: var(--danger);
  border-radius: 2px;
  transition: width 0.4s ease-in-out;
}

/* ── Controls ────────────────────────────────────────── */

.ctrl {
  margin-bottom: var(--sp-m);
}

.ctrl:last-child {
  margin-bottom: 0;
}

.ctrl label {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  color: var(--content-lo);
  margin-bottom: var(--sp-xs);
  text-transform: uppercase;
}

.ctrl label span {
  color: var(--content-hi);
  font-size: 16px;
  font-weight: 400;
}

/* Range slider */
input[type='range'] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 3px;
  background: var(--surface-5);
  outline: none;
  cursor: pointer;
  border-radius: 2px;
}

input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--primary);
  cursor: pointer;
  border-radius: 50%;
}

input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--primary);
  cursor: pointer;
  border-radius: 50%;
  border: none;
}

/* Camera presets */
.preset-select {
  width: 100%;
  height: 42px;
  padding: 0 var(--sp-m);
  background-color: var(--surface-4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radious-s);
  color: var(--content-hi);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.preset-select:hover {
  border-color: rgba(255, 255, 255, 0.16);
}

.preset-select:focus {
  border-color: var(--primary);
}

.coastal-surveillance-sim[data-theme="light"] .preset-select {
  border-color: rgba(0, 0, 0, 0.1);
}

.coastal-surveillance-sim[data-theme="light"] .preset-select:hover {
  border-color: rgba(0, 0, 0, 0.18);
}

/* Camera rotation — overlay (pairs with .zoom-bar on the right) */
.dir-bar {
  position: absolute;
  bottom: var(--sp-m);
  left: var(--sp-m);
  display: flex;
  align-items: center;
  gap: var(--sp-s);
  z-index: 10;
}

.dir-btn {
  flex: 0 0 auto;
  box-sizing: border-box;
  min-width: 5.25rem;
  height: 52px;
  padding: 0 var(--sp-m);
  background: var(--surface-3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radious-m);
  color: var(--content-mid);
  font-family: var(--font);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.015em;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-transform: uppercase;
  transition: background 0.2s ease-in-out, color 0.2s ease-in-out, border-color 0.2s ease-in-out;
  line-height: 1;
}

.dir-btn:hover {
  background: var(--surface-4);
  color: var(--content-hi);
}

.dir-btn.active {
  background: var(--primary-dim);
  border-color: var(--primary);
  color: var(--primary-content);
}

/* Hint */
.hint {
  font-size: 14px;
  font-weight: 400;
  color: var(--content-lo);
  line-height: 1.5;
}

.hint-s { color: var(--danger-content); }
.hint-e { color: var(--warning-content); }


/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 700px) {
  .coastal-surveillance-sim {
    grid-template-columns: 1fr;
    grid-template-rows: 46px minmax(0, 55vw) minmax(0, 1fr);
  }
  #panel {
    border-left: none;
    border-top: var(--stroke);
  }
}
