/* Menhaden — AIS Vessel Tracker — Maritime Dark Theme
   Extends WindApp's CSS variable palette for brand consistency. */

:root {
  --bg-deep:     #0a1628;
  --bg-surface:  #0f2035;
  --bg-elevated: #162942;
  --bg-panel:    #112236;

  --accent-wind:    #60a5fa;
  --accent-water:   #22d3ee;
  --accent-brass:   #d4a574;
  --accent-alert:   #f97316;
  --accent-calm:    #34d399;
  --accent-warn:    #fbbf24;

  /* Vessel state colors */
  --state-transit: #60a5fa;   /* blue   — steaming */
  --state-setting: #f97316;   /* orange — fishing dwell */
  --state-slow:    #fbbf24;   /* amber  — between states */
  --state-idle:    #6b7280;   /* gray   — no recent data */

  /* Confidence colors */
  --conf-high:   #34d399;
  --conf-medium: #fbbf24;

  --text-primary:   #f0f6ff;
  --text-secondary: #8aa8d4;
  --text-muted:     #4a6589;

  --border-subtle: rgba(96,165,250,0.12);
  --border-accent: rgba(96,165,250,0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Outfit', -apple-system, sans-serif;
  color: var(--text-primary);
  background: var(--bg-deep);
  overflow: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.018;
  pointer-events: none;
  z-index: 9999;
}

/* ── Header ── */
header {
  height: 50px;
  padding: 0 20px;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-deep) 100%);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  z-index: 1000;
}

.header-title {
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--text-primary) 20%, var(--accent-brass) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.header-sep { color: var(--text-muted); font-size: 0.8rem; }

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.nav-tab.active {
  background: var(--bg-elevated);
  border-color: var(--border-accent);
  color: var(--accent-wind);
}

.header-status {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--state-idle);
  transition: background 0.3s;
}

.status-dot.live { background: var(--accent-calm); animation: pulse 2s infinite; }
.status-dot.stale { background: var(--accent-warn); }
.status-dot.offline { background: var(--state-idle); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Layout ── */
#app {
  display: flex;
  height: calc(100vh - 50px);
  position: relative;
}

/* ── Map ── */
#map {
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Override Leaflet attribution color */
.leaflet-control-attribution {
  background: rgba(10,22,40,0.85) !important;
  color: var(--text-muted) !important;
  font-size: 0.7rem !important;
}

.leaflet-control-attribution a { color: var(--text-secondary) !important; }

/* ── Vessel Markers ── */
.vessel-marker {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.vessel-icon {
  cursor: pointer;
  filter: drop-shadow(0 0 6px currentColor);
  transition: filter 0.2s;
}

.vessel-icon:hover {
  filter: drop-shadow(0 0 12px currentColor);
}

.vessel-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 2px;
  font-size: 0.65rem;
  font-weight: 600;
  white-space: nowrap;
  color: var(--text-primary);
  text-shadow: 0 0 6px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.7);
  pointer-events: none;
  letter-spacing: 0.05em;
}

/* ── Vessel Panel ── */
#vessel-panel {
  width: 320px;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-panel) 100%);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 100;
  transition: width 0.25s ease;
}

#vessel-panel.hidden { width: 0; border-left: none; }

.panel-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.panel-vessel-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

.panel-mmsi {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

.panel-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 0 4px;
  line-height: 1;
  transition: color 0.15s;
}
.panel-close:hover { color: var(--text-primary); }

.panel-state-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel-body::-webkit-scrollbar { width: 4px; }
.panel-body::-webkit-scrollbar-track { background: transparent; }
.panel-body::-webkit-scrollbar-thumb { background: var(--border-accent); border-radius: 2px; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
}

.stat-card-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}

.stat-card-value {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
}

.stat-card-unit {
  font-size: 0.7rem;
  color: var(--text-secondary);
  margin-left: 3px;
}

.panel-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.chart-container {
  position: relative;
  height: 140px;
}

.net-set-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.net-set-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.75rem;
}

.net-set-time {
  color: var(--text-secondary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
}

.net-set-zone {
  color: var(--accent-wind);
  font-weight: 600;
  margin-left: 6px;
}

.conf-badge {
  float: right;
  font-size: 0.65rem;
  padding: 1px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.conf-high   { background: rgba(52,211,153,0.15); color: var(--conf-high); }
.conf-medium { background: rgba(251,191,36,0.15);  color: var(--conf-medium); }

/* ── Dashboard Overlay ── */
#dashboard {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--bg-deep) 0%, rgba(10,22,40,0.97) 100%);
  z-index: 50;
  overflow-y: auto;
  padding: 24px;
  display: none;
}

#dashboard.visible { display: block; }

.dash-title {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.dash-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.dash-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 18px;
}

.dash-card-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.dash-card-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
  line-height: 1;
}

.dash-card-sub {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.dash-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 700px) {
  .dash-charts { grid-template-columns: 1fr; }
}

.dash-chart-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 18px;
}

.dash-chart-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.dash-chart-wrap {
  position: relative;
  height: 220px;
}

/* ── Legend ── */
.map-legend {
  position: absolute;
  bottom: 30px;
  left: 10px;
  z-index: 400;
  background: rgba(10,22,40,0.88);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.72rem;
  backdrop-filter: blur(4px);
}

.legend-title {
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 7px;
  font-size: 0.68rem;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ── Net-set map markers ── */
.netset-marker {
  border-radius: 50%;
  border: 2px solid rgba(249,115,22,0.6);
  background: rgba(249,115,22,0.25);
  cursor: pointer;
}

/* ── Loading / empty states ── */
.panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-accent);
  border-top-color: var(--accent-wind);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }
