/* Customer-facing pages. Tokens from the Stitch "Precision Logistics" design system. */
:root {
  --canvas: #f8fafc; --card: #ffffff; --line: #e2e8f0;
  --text: #0f172a; --text-2: #64748b; --text-3: #94a3b8;
  --red: #ff0000; --red-ink: #d70000; --red-soft: #fef2f2;
  --green: #10b981; --green-ink: #065f46; --green-soft: #ecfdf5;
  --amber: #f59e0b; --amber-ink: #92400e; --amber-soft: #fffbeb;
  --wa: #25d366;
  --shadow-1: 0 1px 3px rgba(15,23,42,.04), 0 1px 2px -1px rgba(15,23,42,.04);
  --shadow-2: 0 10px 25px -5px rgba(15,23,42,.10), 0 8px 10px -6px rgba(15,23,42,.05);
  --topbar: 68px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
[hidden] { display: none !important; }  /* keep the hidden attribute winning over display:flex rules */
body {
  font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text); background: var(--canvas);
  -webkit-font-smoothing: antialiased; font-feature-settings: "tnum" 1;
}
a { color: inherit; }
.ic { flex: none; display: block; }

/* ---------- top bar: logo | CNK LOJISTIK OTOMOTIV ---------- */
.topbar {
  height: var(--topbar); padding: 0 20px; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; position: relative; z-index: 2;
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; min-width: 0; }
.brand img { height: 40px; width: auto; display: block; }
.brand-sep { width: 1px; height: 34px; background: #cbd5e1; flex: none; }
.brand-word {
  font-size: 15px; font-weight: 600; letter-spacing: .16em; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 420px) {
  .topbar { padding: 0 14px; }
  .brand { gap: 10px; }
  .brand img { height: 34px; }
  .brand-word { font-size: 12px; letter-spacing: .1em; }
}

/* ---------- share page: vehicle | map | representative ---------- */
.stage { display: grid; gap: 12px; padding: 12px 12px calc(16px + env(safe-area-inset-bottom)); }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-1); padding: 18px;
}
.map-wrap { position: relative; }
#map {
  height: 50vh; height: 50svh; min-height: 280px; background: #e5e7eb;
  border-radius: 20px; border: 1px solid var(--line); box-shadow: var(--shadow-1);
  overflow: hidden; z-index: 0; isolation: isolate;
}
.map-status {
  position: absolute; top: 12px; right: 12px; z-index: 1; max-width: calc(100% - 24px);
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: rgba(255,255,255,.96); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  backdrop-filter: blur(6px);
}
@media (max-width: 600px) {
  /* narrow screens: let the status wrap instead of truncating the timestamp */
  .map-status { height: auto; padding: 7px 12px; white-space: normal; line-height: 1.3; align-items: flex-start; }
  .map-status .dot { margin-top: 4px; }
}
.map-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); position: relative; flex: none; }
.map-status.live { color: var(--green-ink); }
.map-status.live .dot { background: var(--green); }
.map-status.live .dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  background: var(--green); opacity: .35; animation: pulse 1.8s ease-out infinite;
}
.map-status.stale { color: var(--amber-ink); }
.map-status.stale .dot { background: var(--amber); }
.map-status.wait { color: #334155; }
@keyframes pulse { 0% { transform: scale(.6); opacity: .45; } 100% { transform: scale(2.2); opacity: 0; } }

@media (max-width: 1023px) {
  .map-wrap { order: 1; }  /* mobile only: map goes below the vehicle and representative cards (user request) */
}

@media (min-width: 1024px) {
  body.share-page { height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
  .stage {
    flex: 1; min-height: 0; width: 100%; max-width: 1600px; margin: 0 auto;
    grid-template-columns: 320px minmax(0, 1fr) 320px; gap: 20px; padding: 20px;
  }
  .map-wrap { min-height: 0; }
  #map { height: 100%; min-height: 0; border-radius: 24px; box-shadow: var(--shadow-2); }
  .map-status { top: 16px; right: 16px; }
  /* side cards keep their natural height instead of stretching to the bottom (user request) */
  .panel { align-self: start; max-height: 100%; overflow-y: auto; border-radius: 24px; padding: 22px; box-shadow: var(--shadow-2); }
  .side { gap: 20px; max-height: 100%; overflow-y: auto; }
  .side .panel { max-height: none; overflow: visible; }
}

/* ---------- vehicle panel ---------- */
.vehicle-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.vehicle-title { font-size: 13px; color: var(--text-2); margin: 8px 0 0; }
/* plate: plain bold text, no frame (user request) */
.plate { font-size: 26px; font-weight: 800; letter-spacing: .06em; line-height: 1.2; white-space: nowrap; }
.driver { display: flex; align-items: center; gap: 8px; margin: 6px 0 0; font-size: 15px; font-weight: 500; color: var(--text-2); }
.driver .ic { color: var(--text-3); }
/* movement indicator: icon only, green when moving, gray when stopped */
.motion {
  width: 36px; height: 36px; border-radius: 12px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: #f1f5f9; color: var(--text-3);
}
.motion.on { background: var(--green-soft); color: var(--green); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border-radius: 10px; background: #f1f5f9; color: #334155; font-size: 13px; font-weight: 600;
  white-space: nowrap;
}
.chip.on { background: var(--green-soft); color: var(--green-ink); }
.chip.off { background: #f1f5f9; color: var(--text-2); }
.addr {
  display: flex; gap: 12px; align-items: center; margin-top: 14px; padding: 14px;
  border: 1px solid var(--line); border-radius: 16px; background: var(--canvas);
}
.addr-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--red-soft); color: var(--red-ink);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.addr-text { font-weight: 600; line-height: 1.35; }

/* ---------- representative: name + phone ---------- */
.eyebrow { margin: 0 0 10px; font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-2); }
.rep-name { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.rep-phone {
  display: flex; align-items: center; gap: 8px; margin: 6px 0 0;
  font-size: 15px; font-weight: 600; letter-spacing: .03em; color: var(--text);
}
.rep-note { margin: 10px 0 0; font-size: 13px; color: var(--text-2); }
/* right column: representative card + certificate card stacked */
.side { display: grid; gap: 12px; align-content: start; min-height: 0; }
/* sapling certificate card */
.cert { text-align: left; }
.cert-icon {
  width: 40px; height: 40px; border-radius: 12px; background: var(--green-soft); color: var(--green);
  display: inline-flex; align-items: center; justify-content: center;
}
.cert-title { margin: 12px 0 0; font-size: 15px; font-weight: 800; letter-spacing: .06em; line-height: 1.35; }
.cert-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; margin: 10px 0 0; }
.cert-host { font-size: 12px; color: var(--text-3); }  /* muted source domain, derived from the link */
.cert-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 15px; font-weight: 600; color: var(--green-ink); text-decoration: none;
  border-bottom: 1px solid #a7f3d0;
}
.cert-link:hover { color: var(--green); border-bottom-color: var(--green); }
/* "Did you know?" block right below the representative card */
.dyk {
  display: flex; gap: 12px; align-items: flex-start; margin-top: 18px; padding: 14px;
  border-radius: 16px; background: var(--green-soft); border: 1px solid #a7f3d0;
}
.dyk-icon {
  width: 36px; height: 36px; border-radius: 12px; flex: none; background: #fff; color: var(--green);
  display: inline-flex; align-items: center; justify-content: center;
}
.dyk-title { margin: 0; font-size: 14px; font-weight: 700; color: var(--green-ink); }
.dyk-text { margin: 2px 0 0; font-size: 13px; line-height: 1.45; color: var(--green-ink); }
.wa-badge {
  width: 22px; height: 22px; border-radius: 50%; background: var(--wa); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.foot { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3); }

/* ---------- map marker & controls ---------- */
.truck-marker { position: relative; width: 52px; height: 52px; }
.truck-marker .ring {
  position: absolute; inset: 0; border-radius: 50%; background: rgba(255,0,0,.18);
  animation: ring 2s ease-out infinite;
}
.truck-marker .core {
  position: absolute; inset: 7px; border-radius: 50%; background: var(--red); color: #fff;
  border: 3px solid #fff; box-shadow: 0 4px 12px rgba(255,0,0,.35);
  display: flex; align-items: center; justify-content: center;
}
@keyframes ring { 0% { transform: scale(.7); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.maplibregl-ctrl-group { border-radius: 14px !important; box-shadow: var(--shadow-2) !important; overflow: hidden; }
.maplibregl-ctrl-group button { width: 40px !important; height: 40px !important; }
.map-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; background: #fff; color: var(--text);
  box-shadow: var(--shadow-2); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.map-btn:hover { color: var(--red-ink); }
.maplibregl-ctrl-attrib { font-size: 10px; }

/* ---------- simple centered pages (inactive / home) ---------- */
.center-wrap { max-width: 480px; margin: 0 auto; padding: 32px 16px calc(32px + env(safe-area-inset-bottom)); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: var(--shadow-1); }
.card + .card { margin-top: 16px; }
.card h1 { font-size: 22px; line-height: 1.3; letter-spacing: -.015em; margin: 0 0 8px; }
.card p { margin: 0; color: var(--text-2); }
.card .rep-name { color: var(--text); }
.state-icon {
  width: 48px; height: 48px; border-radius: 14px; background: var(--amber-soft); color: var(--amber-ink);
  display: flex; align-items: center; justify-content: center; margin-bottom: 16px;
}
.steps { margin: 16px 0 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.steps li { display: flex; gap: 10px; color: var(--text-2); font-size: 14px; }
.steps li::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--red); margin-top: 8px; flex: none; }

@media (prefers-reduced-motion: reduce) {
  .map-status.live .dot::after, .truck-marker .ring { animation: none; }
}
