/* ============================================================================
Fleet Baron (Demo) — style.css
Matches the provided index.html + game.js (markers, panels, modals, tutorial).
Vanilla CSS, responsive for desktop + mobile.
============================================================================ */

/* =========================
   RESET / BASE
========================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: #0f1116;
  color: #e9eef7;
}

button, input, select {
  font: inherit;
}

img { max-width: 100%; display: block; }

hr {
  border: 0;
  border-top: 1px solid rgba(255,255,255,0.10);
  margin: 10px 0;
}

/* =========================
   TOP NAV
========================= */
#topNav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #141824;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

#appTitle {
  font-weight: 800;
  letter-spacing: 0.2px;
  font-size: 16px;
  white-space: nowrap;
}

.navGroup {
  display: flex;
  gap: 8px;
  align-items: center;
}

.navGroup.hud {
  gap: 12px;
  justify-content: center;
  flex: 1;
}

.navGroup.right {
  justify-content: flex-end;
}

.hudItem {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  color: rgba(233,238,247,0.95);
  white-space: nowrap;
}

/* =========================
   LAYOUT
========================= */
#layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 12px;
  padding: 12px;
  min-height: calc(100vh - 120px);
}

#mainView {
  min-width: 0;
}

#rightSidebar {
  min-width: 0;
  background: #141824;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* =========================
   MAP VIEW
========================= */
.mapView {
  background: #141824;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  overflow: hidden;
  height: calc(100vh - 160px);
  min-height: 420px;
}

.mapFrame {
  position: relative;
  width: 100%;
  height: 100%;
  background: #0c0f17;
}

.mapImg {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
  pointer-events: none;
  filter: saturate(0.95) contrast(1.02);
}

.markerLayer {
  position: absolute;
  inset: 0;
}

/* =========================
   MARKERS
========================= */
.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid;
  grid-template-columns: 12px auto;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(16, 20, 30, 0.86);
  border: 1px solid rgba(255,255,255,0.14);
  cursor: pointer;
  user-select: none;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}

.marker:hover {
  border-color: rgba(255,255,255,0.22);
  background: rgba(18, 24, 40, 0.92);
}

.markerDot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(0,0,0,0.25);
}

.markerLabel {
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  color: rgba(233,238,247,0.95);
}

.marker.hq .markerDot {
  background: #7ee787;
}

.cityMarker .markerDot { background: #8fb3ff; }
.buildingMarker .markerDot { background: #ffd37e; }
.plotMarker .markerDot { background: #b9b9c6; }

/* Active mission badge */
.missionBadge {
  position: absolute;
  transform: translate(-50%, -50%);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 999px;
  padding: 3px 7px;
  cursor: pointer;
  user-select: none;
}
.missionBadge:hover { border-color: rgba(255,255,255,0.26); }
.missionBadgeText { font-size: 14px; }

/* =========================
   TABS / PANELS
========================= */
#tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
}

.tabBtn {
  padding: 10px 8px;
  border: 0;
  background: transparent;
  color: rgba(233,238,247,0.85);
  cursor: pointer;
  font-weight: 650;
  font-size: 12px;
}

.tabBtn:hover {
  background: rgba(255,255,255,0.05);
}

.tabBtn.active {
  background: rgba(255,255,255,0.08);
  color: rgba(233,238,247,1);
}

#tabPanels {
  padding: 10px;
  overflow: auto;
  flex: 1;
}

.tabPanel {
  min-height: 200px;
}

/* =========================
   COMMON UI BLOCKS
========================= */
.panelLead {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.panelTitleBig {
  font-size: 18px;
  font-weight: 850;
  letter-spacing: 0.2px;
}

.muted {
  color: rgba(233,238,247,0.70);
  font-size: 12px;
  line-height: 1.35;
}

.panelSection {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
}

.sectionTitle {
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(233,238,247,0.85);
  margin-bottom: 8px;
}

/* =========================
   BUTTONS
========================= */
.btn {
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.06);
  color: rgba(233,238,247,0.95);
  padding: 8px 10px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  transition: transform 0.05s ease, background 0.12s ease, border 0.12s ease;
}

.btn:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.22);
}

.btn:active {
  transform: translateY(1px);
}

.btn.active {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.26);
}

.btn.primary {
  background: rgba(143,179,255,0.18);
  border-color: rgba(143,179,255,0.45);
}

.btn.primary:hover {
  background: rgba(143,179,255,0.24);
  border-color: rgba(143,179,255,0.55);
}

.btn.danger {
  background: rgba(255,120,120,0.12);
  border-color: rgba(255,120,120,0.30);
}

.btn.danger:hover {
  background: rgba(255,120,120,0.18);
  border-color: rgba(255,120,120,0.38);
}

.btn.small {
  padding: 6px 9px;
  border-radius: 10px;
  font-size: 12px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

/* Inline action groups */
.cardActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* =========================
   LIST ITEMS / CARDS
========================= */
.listItem {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(233,238,247,0.95);
  border-radius: 14px;
  padding: 10px;
  margin: 8px 0;
  cursor: pointer;
}

.listItem:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.20);
}

.listItem.highlight {
  outline: 2px solid rgba(126,231,135,0.55);
  box-shadow: 0 0 0 6px rgba(126,231,135,0.08);
}

.liTitle {
  font-weight: 850;
  font-size: 13px;
}

.liSub {
  color: rgba(233,238,247,0.72);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.3;
}

.liMeta {
  color: rgba(233,238,247,0.64);
  font-size: 11px;
  margin-top: 6px;
}

/* Cards used in many panels */
.card {
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 10px;
  margin: 8px 0;
}

.cardTitle {
  font-weight: 850;
  margin-bottom: 6px;
}

.cardLine {
  color: rgba(233,238,247,0.78);
  font-size: 12px;
  line-height: 1.35;
  margin: 3px 0;
}

/* =========================
   LOG
========================= */
.logList {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.logRow {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  border-radius: 14px;
  padding: 8px 10px;
  display: grid;
  gap: 6px;
}

.logTime {
  font-size: 11px;
  color: rgba(233,238,247,0.60);
  font-weight: 750;
}

.logText {
  font-size: 12px;
  color: rgba(233,238,247,0.90);
  white-space: pre-wrap;
  line-height: 1.35;
}

.logEmpty {
  color: rgba(233,238,247,0.70);
  font-size: 12px;
  padding: 10px;
  border: 1px dashed rgba(255,255,255,0.16);
  border-radius: 14px;
}

.logRow.good { border-color: rgba(126,231,135,0.22); }
.logRow.warn { border-color: rgba(255,211,126,0.22); }
.logRow.bad  { border-color: rgba(255,120,120,0.20); }

/* =========================
   PLANNER UI HELPERS
========================= */
.transportList {
  display: grid;
  gap: 10px;
}

.transportCard {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: rgba(233,238,247,0.95);
  border-radius: 14px;
  padding: 10px;
  cursor: pointer;
}

.transportCard:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.20);
}

.transportCard.locked {
  opacity: 0.65;
}

.transportCard.selected {
  outline: 2px solid rgba(143,179,255,0.55);
  box-shadow: 0 0 0 6px rgba(143,179,255,0.10);
}

.routeChoices {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.servicesList,
.staffPick {
  display: grid;
  gap: 8px;
}

.checkRow {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
}

.checkRow:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.18);
}

.checkRow input {
  width: 16px;
  height: 16px;
}

.checkLabel {
  font-size: 12px;
  color: rgba(233,238,247,0.90);
}

.breakdown {
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.16);
  border-radius: 14px;
  padding: 10px;
  margin-top: 8px;
}

.breakLine {
  font-size: 12px;
  color: rgba(233,238,247,0.85);
  margin: 4px 0;
}

.breakHr {
  border-top: 1px solid rgba(255,255,255,0.10);
  margin: 10px 0;
}

.good { color: rgba(126,231,135,0.95); }
.bad  { color: rgba(255,120,120,0.95); }

.confirmRow {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* Code block used in active mission report */
.codeBlock {
  margin: 0;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.20);
  color: rgba(233,238,247,0.92);
  font-size: 12px;
  white-space: pre-wrap;
  line-height: 1.35;
}

/* =========================
   BOTTOM BAR
========================= */
#bottomBar {
  position: sticky;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: #141824;
  border-top: 1px solid rgba(255,255,255,0.10);
}

#moneyDisplay {
  font-weight: 850;
  white-space: nowrap;
}

#incomeDisplay {
  color: rgba(233,238,247,0.72);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#alertsDisplay {
  text-align: right;
  font-weight: 800;
  font-size: 12px;
  color: rgba(233,238,247,0.95);
  min-width: 120px;
}

/* flash animation */
#alertsDisplay.flash {
  animation: alertFlash 0.7s ease;
}
@keyframes alertFlash {
  0% { transform: translateY(0); opacity: 0.8; }
  20% { transform: translateY(-2px); opacity: 1; }
  100% { transform: translateY(0); opacity: 0.9; }
}

/* =========================
   MODALS
========================= */
#modalRoot {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}

#modalRoot.open {
  pointer-events: auto;
}

.modalOverlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid;
  place-items: center;
  padding: 14px;
}

.modal {
  width: min(820px, 100%);
  max-height: min(86vh, 900px);
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #141824;
  box-shadow: 0 20px 70px rgba(0,0,0,0.55);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.modalHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
}

.modalTitle {
  font-weight: 900;
  font-size: 14px;
}

.modalBody {
  padding: 12px;
  overflow: auto;
}

.modalFooter {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.10);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(255,255,255,0.03);
}

/* =========================
   TUTORIAL OVERLAY
========================= */
#tutorialOverlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0,0,0,0.62);
  display: grid;
  place-items: center;
  padding: 14px;
}

#tutorialOverlay.hidden {
  display: none;
}

.tutorialBox {
  width: min(560px, 100%);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: #141824;
  box-shadow: 0 20px 70px rgba(0,0,0,0.55);
  padding: 14px;
}

.tutorialTitle {
  font-weight: 950;
  font-size: 18px;
  margin-bottom: 8px;
}

.tutorialBody p {
  margin: 0 0 10px 0;
  color: rgba(233,238,247,0.85);
  font-size: 13px;
  line-height: 1.45;
}

.tutorialActions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 980px) {
  #layout {
    grid-template-columns: 1fr;
  }

  #rightSidebar {
    order: 2;
  }

  .mapView {
    height: 56vh;
    min-height: 340px;
  }

  #bottomBar {
    grid-template-columns: 1fr;
    text-align: left;
  }

  #alertsDisplay {
    text-align: left;
    min-width: 0;
  }

  .navGroup.hud {
    display: none; /* keep top bar tidy on mobile */
  }
}

@media (max-width: 520px) {
  #topNav {
    flex-wrap: wrap;
    gap: 8px;
  }

  #appTitle {
    width: 100%;
  }

  .navGroup.right {
    width: 100%;
    justify-content: flex-start;
  }

  .marker {
    padding: 5px 8px;
    gap: 6px;
  }

  .markerLabel {
    font-size: 11px;
  }

  .modal {
    max-height: 88vh;
  }
}
