/* =========================
   Global / layout
========================= */
html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f6f7f9;
}

#map {
  position: fixed;
  inset: 0;
}

/* =========================
   Sidebar
========================= */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 340px;
  max-width: 90vw;
  background: #ffffff;
  color: #0b1220;
  display: flex;
  flex-direction: column;
  z-index: 10;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.sidebar-logo {
  display: block;
  max-width: 140px;
  height: auto;
  margin-bottom: 6px;
}

.title {
  font-size: 18px;
  font-weight: 800;
}

.subtitle {
  font-size: 12px;
  color: rgba(11,18,32,0.6);
}

.icon-btn {
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.08);
  color: inherit;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 16px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(0,0,0,0.06); }

.sidebar-controls {
  padding: 12px 16px;
  display: grid;
  gap: 10px;
}

.search {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.12);
  outline: none;
  background: #ffffff;
  color: #0b1220;
}
.search::placeholder { color: rgba(11,18,32,0.45); }

.toggle {
  font-size: 13px;
  color: rgba(11,18,32,0.75);
}

.map-style {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: rgba(11,18,32,0.7);
}

.select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffffff;
  color: #0b1220;
  font-size: 13px;
}

.btn-ghost {
  border: 1px solid rgba(11,18,32,0.18);
  background: #ffffff;
  color: #0b1220;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.btn-ghost:hover {
  background: #f5f5f5;
}

/* =========================
   Tabs (Boats / Sites)
========================= */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 0;
}

.tab-btn {
  border: 2px solid #d7d7d7;
  background: #ffffff;
  color: rgba(11,18,32,0.65);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
}

.tab-btn.active {
  border-color: #a9a9a9;
  color: #0b1220;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* =========================
   Lists
========================= */
.boat-list {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px 110px; /* extra bottom so footer doesn't cover last items */
  display: grid;
  gap: 8px;
}

.list-section-header {
  padding: 12px 8px 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(11,18,32,0.50);
}

/* =========================
   Boat / site buttons
========================= */
.boat-btn {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: 18px;
  border: 2px solid #d7d7d7;
  background: #ffffff;
  color: #0b1220;
  cursor: pointer;
  text-align: left;
  box-shadow: none;
}

.boat-btn:hover {
  border-color: #c6c6c6;
  background: #ffffff;
}

.boat-btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: transparent;
  border: 0;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.boat-btn-name {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.25px;
  line-height: 1.1;
  text-transform: uppercase;
}

.boat-btn-meta {
  font-size: 11px;
  color: rgba(11,18,32,0.68);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.right-meta {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding-left: 10px;
  white-space: nowrap;
}

.right-meta .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #58c16b;
}

.right-meta .status-text {
  font-weight: 700;
  font-size: 14px;
  color: rgba(11,18,32,0.70);
}

.boat-btn.is-selected {
  border-color: #a9a9a9;
  box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

/* =========================
   Site list buttons (custom)
========================= */
.site-btn {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(31,120,255,0.35);
  background: rgba(31,120,255,0.05);
  color: #0b1220;
  cursor: pointer;
  text-align: left;
}

.site-btn:hover {
  background: rgba(31,120,255,0.10);
  border-color: rgba(31,120,255,0.55);
}

.site-btn--smolt {
  border-color: rgba(34,197,94,0.35);
  background: rgba(34,197,94,0.08);
}

.site-btn--smolt:hover {
  background: rgba(34,197,94,0.14);
  border-color: rgba(34,197,94,0.55);
}

.site-btn--smolt .site-btn-icon {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
}

.site-btn-icon {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #1f78ff;
  box-shadow: 0 0 0 3px rgba(31,120,255,0.15);
}

.site-btn-name {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.1;
}

.site-btn-meta {
  font-size: 12px;
  color: rgba(11,18,32,0.60);
  margin-top: 2px;
}

.site-btn-body {
  min-width: 0;
}

/* =========================
   Site variants
========================= */
.site-item .boat-btn-icon {
  border-radius: 999px;
  background: #1f78ff;
  border: 1px solid rgba(31,120,255,0.25);
  box-shadow: 0 0 0 3px rgba(31,120,255,0.12);
  background-image: none;
}

.site-overlay-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.site-marker {
  display: block;
  width: 10px;
  height: 10px;
  background: #1f78ff;
  border-radius: 50%;
  border: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.9);
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 2;
  margin: 0;
  padding: 0;
  line-height: 0;
  font-size: 0;
  pointer-events: auto;
  touch-action: manipulation;
}

.mapboxgl-marker {
  transform: translate3d(0, 0, 0);
}

.site-marker--smolt {
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.9), 0 0 0 3px rgba(34,197,94,0.18);
}

.site-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  max-width: 220px;
  font-size: 10px;
  font-weight: 800;
  color: rgba(0,0,0,0.8);
  white-space: nowrap;
  padding: 1px 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.6);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  position: absolute;
  z-index: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  touch-action: manipulation;
}

/* =========================
   Boat marker
========================= */
.boat-root {
  --boat-scale: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  text-shadow: none;
}

/* Boat name label on map */
.boat-label {
  margin-top: calc(-20px * var(--boat-scale));
  padding: calc(4px * var(--boat-scale)) calc(8px * var(--boat-scale));
  background: #ffffff;
  color: #0b1220;
  border-radius: 8px;
  font-size: calc(12px * var(--boat-scale));
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  border: 1px solid rgba(0,0,0,0.12);
  pointer-events: none;
}

.boat-icon {
  width: calc(100px * var(--boat-scale));
  height: calc(100px * var(--boat-scale));
  display: block;

  /* If boat icon is an <img> */
  object-fit: contain;

  /* If boat icon is a <div> with background-image */
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

/* =========================
   Popup (AIS)
========================= */
/* Site popup image (shown under title) */
.site-popup-img {
  width: 100%;
  margin: 10px 0 8px;
  border-radius: 14px;
  object-fit: cover;
  aspect-ratio: 4 / 3;
  max-height: 220px;
  display: block;
}
.ais-popup .mapboxgl-popup-content {
  background: #ffffff;
  color: #0b1220;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.20);
}

.mapboxgl-popup {
  z-index: 10;
}

.ais-card {
  min-width: 260px;
}

.ais-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-card .ais-header {
  justify-content: space-between;
  gap: 12px;
}

.ais-header-text {
  flex: 1;
  min-width: 0;
}

.ais-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ais-avatar-img {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
}

.ais-name {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.4px;
}

.ais-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.4px;
}

.site-card {
  min-width: 280px;
  position: relative;
}

.site-title {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.6px;
  color: rgba(0,0,0,0.75);
}

.asc-header {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.asc-pill {
  width: 34px;
  height: 34px;
  object-fit: contain;
  justify-self: end;
}

.site-card .ais-divider {
  margin: 12px 0 14px;
}

.site-card .ais-rows {
  gap: 0;
  border-top: 1px dotted rgba(11,18,32,0.2);
}

.site-card .ais-row {
  grid-template-columns: 110px 1fr;
  padding: 5px 10px;
  border-bottom: 1px dotted rgba(11,18,32,0.2);
}

.site-card .ais-row:nth-child(odd) {
  background: #f7f7f7;
}

.site-card .ais-row:nth-child(even) {
  background: #ffffff;
}

.site-card .ais-row-key {
  color: #0b1220;
}

.site-card .ais-row-val {
  color: rgba(11,18,32,0.75);
}

.site-link {
  color: #64748b;
  text-decoration: underline;
}

.ais-divider {
  height: 1px;
  background: rgba(11,18,32,0.08);
  margin: 10px 0 12px;
}

.ais-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.ais-stat {
  display: grid;
  justify-items: center;
  text-align: center;
}

.ais-stat-label {
  font-size: 15px;
  font-weight: 700;
  color: #0b1220;
}

.ais-stat-val {
  font-size: 32px;
  font-weight: 800;
  color: rgba(11,18,32,0.35);
  line-height: 1.1;
  margin-top: 2px;
}

.ais-rows {
  display: grid;
  gap: 6px;
}

.ais-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 14px;
}

.ais-row-key {
  font-weight: 700;
}

.ais-row-val {
  color: rgba(11,18,32,0.75);
}

.ais-muted {
  color: rgba(11,18,32,0.55);
  font-size: 12px;
  margin-top: 2px;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

.status-dot-green {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.18);
}

/* =========================
   Mobile
========================= */
.fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.12);
  background: #ffffff;
  color: #0b1220;
  font-size: 22px;
  z-index: 20;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
}

@media (max-width: 420px) {
  .site-popup-img {
    max-height: 120px;
  }
}

/* =========================
   AIS freshness dot colors
========================= */
.dot.fresh-green { background: #58c16b; }
.dot.stale-orange { background: #f59e0b; }
.dot.stale-red { background: #ef4444; }
