/* ============================================================
   Pool Captains — Operations Portal
   Built to the official Brand Guidelines & Standards V1.0
   Primary:  red #C60C30 · blue #4B92DB · navy #002244 · cream #FBF5DA
   Secondary: gold #FFB612 · green #222B20 · soft blue #B6CFE1 · mid blue #254375
   Type: Trade Gothic (primary) · Monosten (mono/labels) · Damion (script)
   ============================================================ */
@font-face {
  font-family: "Trade Gothic";
  src: url("/assets/TradeGothic.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Trade Gothic Cond";
  src: url("/assets/TradeGothic-BoldCondensed.otf") format("opentype");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Monosten";
  src: url("/assets/Monosten.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Damion";
  src: url("/assets/Damion.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}

:root {
  /* Primary palette */
  --navy: #002244;
  --red: #C60C30;
  --blue: #4B92DB;
  --cream: #FBF5DA;
  /* Secondary palette */
  --gold: #FFB612;
  --green: #222B20;
  --blue-soft: #B6CFE1;
  --blue-mid: #254375;

  /* Roles */
  --bg: var(--cream);
  --card: #FFFFFF;
  --ink: var(--navy);
  --ink-soft: #5a6b7d;
  --line: #e7e0c4;          /* warm hairline that reads on cream + white */
  --line-card: #eef1f5;
  --navy-deep: #001a36;
  --shadow: 0 1px 2px rgba(0, 34, 68, .06), 0 10px 28px rgba(0, 34, 68, .10);
  --mono: "Monosten", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Trade Gothic", Arial, system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--card);
  color: var(--navy);
  display: flex;
  flex-direction: column;
  padding: 30px 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
}
.sidebar__brand { padding: 6px 8px 30px; }
.sidebar__logo { width: 176px; height: auto; display: block; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav__label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--blue-mid);
  opacity: .7;
  margin: 8px 12px 12px;
}
.nav__item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-radius: 9px;
  color: var(--navy);
  text-decoration: none;
  font-size: 15px;
  transition: background .15s ease, color .15s ease;
}
.nav__item:hover { background: rgba(0, 34, 68, .06); }
.nav__item--active { background: var(--navy); color: var(--cream); font-weight: 700; }
.nav__item--soon { color: #97a6b4; cursor: default; }
.nav__item--soon:hover { background: transparent; color: #97a6b4; }
.nav__dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: rgba(0, 34, 68, .16);
  flex-shrink: 0;
}
.nav__item--active .nav__dot {
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(198, 12, 48, .25);
}
.nav__badge {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 34, 68, .06);
  color: var(--blue-mid);
}

.sidebar__footer { border-top: 1px solid var(--line); padding-top: 18px; }
.sidebar__website {
  font-family: var(--mono);
  color: var(--navy); text-decoration: none; font-size: 12px; letter-spacing: .06em;
  display: inline-block; opacity: .8;
}
.sidebar__website:hover { opacity: 1; text-decoration: underline; }
.sidebar__tag {
  margin: 10px 0 0;
  font-family: "Damion", cursive;
  font-size: 26px;
  line-height: 1;
  color: var(--red);
}

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  flex-wrap: wrap;
  padding: 22px 38px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.topbar__title {
  margin: 0;
  font-family: "Trade Gothic Cond", "Trade Gothic", sans-serif;
  font-size: 32px;
  letter-spacing: .01em;
  text-transform: uppercase;
  color: var(--navy);
}
.topbar__sub {
  margin: 5px 0 0;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.topbar__left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }

/* Hamburger — hidden on desktop, shown on mobile */
.menu-toggle {
  display: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
  border-radius: 9px;
  width: 40px; height: 40px;
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.menu-toggle:active { transform: translateY(1px); }
.sidebar-overlay { display: none; }

.btn {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 400;
  padding: 11px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--navy); color: var(--cream); }
.btn--primary:hover { background: var(--navy-deep); box-shadow: var(--shadow); }
.btn--ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn--ghost:hover { background: var(--cream); }

.content { padding: 38px; }

/* ---------- Metric grid ---------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  align-items: start;
}

.metric-card {
  background: var(--card);
  border: 1px solid var(--line-card);
  border-radius: 16px;
  padding: 28px 30px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.metric-card--hero { grid-column: span 2; }
@media (max-width: 760px) { .metric-card--hero { grid-column: span 1; } }

/* Signature red accent bar — echoes the red "POOL" pill */
.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 6px;
  background: var(--red);
}

.metric-card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.metric-card__label {
  font-family: var(--mono);
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--blue-mid); margin: 0;
}
.metric-card__icon {
  width: 42px; height: 42px; border-radius: 10px;
  background: rgba(0, 34, 68, .06);
  display: grid; place-items: center; font-size: 20px;
}
.metric-card__value {
  font-family: "Trade Gothic Cond", "Trade Gothic", sans-serif;
  font-size: 76px;
  line-height: 1;
  color: var(--navy);
  margin: 6px 0 2px;
  letter-spacing: -.01em;
}
.metric-card--hero .metric-card__value { font-size: 96px; }
.metric-card__unit { font-size: 22px; color: var(--ink-soft); font-weight: 400; }
.metric-card__context { margin: 12px 0 0; font-size: 15px; color: var(--ink-soft); }
.metric-card__source {
  margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line-card);
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .04em; color: var(--ink-soft);
  display: flex; align-items: center; gap: 8px;
}
.metric-card__live {
  width: 7px; height: 7px; border-radius: 50%; background: #2fbf71;
  box-shadow: 0 0 0 3px rgba(47, 191, 113, .18);
}

/* loading skeleton */
.metric-card--loading { min-height: 200px; }
.metric-card__skeleton {
  height: 100%; min-height: 150px; border-radius: 10px;
  background: linear-gradient(90deg, #f1ecd6 25%, #fbf7e6 37%, #f1ecd6 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.metric-card--error::before { background: var(--gold); }
.metric-card--error .metric-card__value { font-size: 22px; color: var(--red); }

.status {
  margin: 24px 2px 0; font-family: var(--mono);
  font-size: 11px; letter-spacing: .04em; color: var(--ink-soft);
}
/* Arrow/refresh glyphs that aren't in Monosten render in a system font. */
.gly { font-family: system-ui, -apple-system, "Segoe UI Symbol", sans-serif; }
.spin { display: inline-block; animation: rot .8s linear infinite; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */
.login-body { background: var(--cream); }
.login {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 18px;
}
.login__card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line-card);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 40px 36px 34px;
  text-align: center;
}
.login__logo { width: 210px; height: auto; margin: 0 auto 6px; display: block; }
.login__eyebrow {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--blue-mid); margin: 0 0 28px;
}
.login__form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field__label {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.field input {
  font-family: "Trade Gothic", Arial, sans-serif;
  font-size: 16px;
  color: var(--ink);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(75, 146, 219, .18);
}
.login__error {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--red);
  background: rgba(198, 12, 48, .07);
  border: 1px solid rgba(198, 12, 48, .2);
  border-radius: 9px;
  padding: 10px 12px;
}
.login__submit { justify-content: center; margin-top: 4px; padding: 13px; }
.login__submit:disabled { opacity: .65; cursor: default; }
.login__tag {
  font-family: "Damion", cursive;
  font-size: 28px; color: var(--red); margin: 0;
}

/* ---------- Signed-in user chip ---------- */
.user-chip {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-soft);
}
.user-chip__avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--navy); color: var(--cream);
  display: grid; place-items: center;
  font-size: 12px; letter-spacing: 0; font-weight: 700;
}
.user-chip__name { color: var(--navy); }
.btn--logout { padding: 9px 14px; }

/* ---------- Fleet ---------- */
.content.content--fleet { padding: 0; flex: 1; display: flex; min-height: 0; }

/* Vehicle list panel */
.fleet-list {
  width: 300px; flex-shrink: 0;
  background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-height: 0;
}
.fleet-list__head { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.fleet-list__summary {
  font-family: var(--mono); font-size: 11px; letter-spacing: .04em; color: var(--navy);
  display: flex; align-items: center; gap: 8px;
}
.fleet-list__items { list-style: none; margin: 0; padding: 6px; overflow-y: auto; flex: 1; }
.veh {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 11px 12px; border-radius: 10px; cursor: pointer;
  transition: background .12s ease;
}
.veh:hover { background: var(--cream); }
.veh--active { background: rgba(0, 34, 68, .07); }
.veh--empty { color: var(--ink-soft); cursor: default; font-size: 14px; }
.veh--empty:hover { background: transparent; }
.veh__status {
  width: 9px; height: 9px; border-radius: 50%; margin-top: 5px; flex-shrink: 0;
  background: #97a6b4;
}
.veh__status--moving { background: #2fbf71; box-shadow: 0 0 0 3px rgba(47, 191, 113, .18); }
.veh__main { min-width: 0; }
.veh__name { font-weight: 700; color: var(--navy); font-size: 15px; }
.veh__driver { color: var(--red); font-weight: 700; font-size: 13px; margin-left: 5px; }
.veh__meta { font-family: var(--mono); font-size: 11px; color: var(--ink-soft); margin-top: 2px; }
.veh__addr {
  font-size: 12px; color: var(--ink-soft); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Map */
.map-wrap { position: relative; flex: 1; min-width: 0; min-height: 320px; }
#map { position: absolute; inset: 0; background: var(--blue-soft); }
.map-status__live {
  width: 7px; height: 7px; border-radius: 50%; background: #2fbf71;
  box-shadow: 0 0 0 3px rgba(47, 191, 113, .18); display: inline-block; flex-shrink: 0;
}
.map-message {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  font-family: var(--mono); font-size: 13px; color: var(--ink-soft); padding: 24px; line-height: 1.8;
}

/* Vehicle markers (MapLibre custom element) */
.veh-pin {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 11px; font-weight: 700; line-height: 1; color: #fff;
  background: var(--navy); border: 1.5px solid #fff; border-radius: 999px;
  padding: 2px 8px; white-space: nowrap; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 34, 68, .38);
}
.veh-pin--moving { background: var(--red); }
.veh-pin__driver {
  font-weight: 400;
  padding-left: 4px;
  border-left: 1px solid rgba(255, 255, 255, .4);
}

.veh-popup { font-family: "Trade Gothic", Arial, sans-serif; min-width: 150px; }
.veh-popup strong { font-size: 16px; color: var(--navy); }
.veh-popup__row { font-size: 13px; color: var(--ink); margin-top: 3px; }
.veh-popup__driver { color: var(--red); font-weight: 700; }
.veh-popup__muted { color: var(--ink-soft); font-family: var(--mono); font-size: 11px; }
.maplibregl-popup-content { border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
  .menu-toggle { display: inline-flex; }

  /* Sidebar becomes an off-canvas slide-in drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100vh;
    width: 252px;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .25s ease;
    box-shadow: 0 0 40px rgba(0, 34, 68, .25);
  }
  .app.menu-open .sidebar { transform: translateX(0); }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 34, 68, .45);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .app.menu-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

  .main { width: 100%; }
  .topbar { padding: 16px 18px; }
  .topbar__title { font-size: 24px; }
  .content { padding: 22px 18px; }

  .metric-grid { gap: 16px; }
  .metric-card { padding: 22px 22px; border-radius: 14px; }
  .metric-card__value { font-size: 58px; }
  .metric-card--hero .metric-card__value { font-size: 64px; }

  /* Fleet: fill exactly one screen — map on top, scrollable list fills the rest */
  .app { min-height: 100dvh; }
  .main { height: 100dvh; overflow-y: auto; min-height: 0; }
  .content.content--fleet { flex-direction: column; min-height: 0; }
  .map-wrap { order: -1; flex: 0 0 40vh; min-height: 0; }
  .fleet-list {
    width: 100%; flex: 1 1 auto; min-height: 0; max-height: none;
    border-right: none; border-top: 1px solid var(--line);
  }
}

/* Small phones */
@media (max-width: 380px) {
  .metric-card__value,
  .metric-card--hero .metric-card__value { font-size: 52px; }
  .topbar__title { font-size: 21px; }
}
