/* Rider PWA UI shell (map-first tabs). Keep this app-like and stable. */

:root {
  --tabbar-height: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

.page-pad {
  padding: 14px;
}

/* Prevent accidental horizontal scroll on mobile (common PWA issue). */
html,
body,
.content,
.section,
.app-shell,
.app-main,
.tab-pane,
.page-pad {
  overflow-x: hidden;
}

/* Small layout helpers (mirrors KDS utility vibe). */
.u-spread {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Pairing / install */
.camera {
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--slate-200);
  background: #000;
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 12px;
}

.actions {
  display: flex;
  gap: 10px;
}

.actions .btn {
  flex: 1;
}

.btn-success {
  background: #16a34a;
  border-color: #16a34a;
  color: white;
}

.btn-success:hover {
  background: #15803d;
}

.kv {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.kv .k {
  color: var(--slate-500);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-size: 10px;
}

.footer-note {
  text-align: center;
  margin-top: 14px;
  color: var(--slate-400);
  font-size: 11px;
  font-weight: 700;
}

.status-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Route list (in sheet) */
.route-stops {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.route-stop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--slate-200);
}

.route-stop:last-child {
  border-bottom: none;
}

.route-stop-left {
  min-width: 0;
}

.route-stop-title {
  font-size: 12px;
  font-weight: 900;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-stop-sub {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-stop.delivered {
  opacity: 0.6;
}

.route-stop.active {
  background: rgba(224, 242, 254, 0.75);
  border-radius: 14px;
  padding-left: 10px;
  padding-right: 10px;
}

/* Messages tab */
#tabMessages .page-pad {
  display: flex;
  flex-direction: column;
}

#tabMessages #msgCard {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.msg-history {
  margin-top: 12px;
  display: grid;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.msg {
  padding: 10px 12px;
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  background: white;
}

.msg.kds {
  border-color: #bae6fd;
  background: #f0f9ff;
}

.msg .meta {
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--slate-600);
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.msg .text {
  font-size: 13px;
  font-weight: 700;
  color: var(--slate-900);
  white-space: pre-wrap;
}

.msg-compose {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.msg-compose input {
  flex: 1;
}

.msg-quick {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* App shell */
.app-shell {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--slate-50);
}

.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-pane {
  height: 100%;
  display: none;
}

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

/* Non-map panes scroll nicely */
.tab-pane .page-pad {
  height: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

/* Route tab: map-first */
.route-view {
  height: 100%;
  position: relative;
  overflow: hidden;
  background: var(--slate-100);
}

.route-map {
  position: absolute;
  inset: 0;
}

/* Leaflet tweaks (app-like) */
.leaflet-container {
  font-family: var(--font-stack);
  background: var(--slate-100);
}

.leaflet-control-attribution {
  display: none;
}

/* Custom route markers (cheap + clear) */
.bk-stop-icon {
  background: transparent;
  border: 0;
}

.bk-stop-bubble {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 12px;
  color: white;
  background: rgba(12, 167, 243, 0.95);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.16);
}

.bk-stop-icon.bk-stop-next .bk-stop-bubble {
  background: rgba(245, 158, 11, 0.95);
}

.bk-stop-icon.bk-stop-done .bk-stop-bubble {
  background: rgba(22, 163, 74, 0.95);
}

.bk-stop-icon.bk-stop-pickup .bk-stop-bubble {
  background: rgba(15, 23, 42, 0.92);
}

/* Route HUD */
.route-hud {
  position: absolute;
  z-index: 500;
}

.route-hud-top {
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  pointer-events: none;
}

.route-hud-left,
.route-hud-right {
  pointer-events: auto;
}

.route-hud-left {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--slate-200);
  box-shadow: var(--shadow-sm);
  border-radius: 14px;
  padding: 10px 12px;
  min-width: 0;
  max-width: 62%;
}

.route-hud-title {
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--slate-700);
}

.route-hud-sub {
  margin-top: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.route-hud-right {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  max-width: 48%;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.route-hud-right .pill {
  background: rgba(255, 255, 255, 0.92);
  height: 30px;
  padding: 5px 10px;
  font-size: 10px;
  backdrop-filter: blur(4px);
}

.route-hud-right .pill.ok {
  background: rgba(209, 250, 229, 0.95);
}

.route-hud-right .pill.off {
  background: rgba(241, 245, 249, 0.95);
}

/* Follow/overview buttons overlay */
.route-hud.route-hud-right {
  top: 70px;
  right: 10px;
  display: grid;
  gap: 8px;
}

.fab {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--slate-200);
  background: rgba(255, 255, 255, 0.92);
  font-weight: 900;
  font-size: 11px;
  color: var(--slate-800);
  box-shadow: var(--shadow-sm);
}

.fab.active {
  border-color: #7dd3fc;
  background: rgba(224, 242, 254, 0.95);
  color: #075985;
}

/* Route sheet */
.route-sheet {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(10px + var(--safe-bottom) + var(--tabbar-height));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--slate-200);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  backdrop-filter: blur(6px);
}

.route-sheet-handle {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 12px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.route-sheet-handle-left {
  min-width: 0;
}

.route-next-title {
  font-weight: 900;
  font-size: 12px;
  color: var(--slate-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-next-sub {
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--slate-600);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-sheet-chev {
  font-size: 14px;
  color: var(--slate-500);
  flex: 0 0 auto;
  transition: transform 0.12s ease;
}

.route-sheet-body {
  padding: 0 12px 12px 12px;
  max-height: 48vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.route-sheet.collapsed .route-sheet-body {
  display: none;
}

.route-sheet.collapsed .route-sheet-chev {
  transform: rotate(180deg);
}

.route-next-actions {
  margin-top: 8px;
  display: flex;
  gap: 10px;
}

.route-next-actions .btn {
  flex: 1;
}

/* Tab bar */
.tabbar {
  height: calc(var(--tabbar-height) + var(--safe-bottom));
  padding: 8px 8px calc(8px + var(--safe-bottom)) 8px;
  border-top: 1px solid var(--slate-200);
  background: rgba(255, 255, 255, 0.98);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.tabbar-btn {
  height: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 14px;
  display: grid;
  grid-template-rows: 18px 1fr;
  align-items: center;
  justify-items: center;
  gap: 4px;
  padding: 6px 0;
  color: var(--slate-600);
  font-weight: 900;
  font-size: 10px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  position: relative;
}

.tabbar-btn.active {
  background: var(--primary-subtle);
  border-color: #7dd3fc;
  color: #075985;
}

.tabbar-ic {
  font-size: 18px;
  line-height: 18px;
}

.tabbar-badge {
  position: absolute;
  top: 5px;
  right: 12px;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  padding: 0 6px;
  background: var(--danger);
  color: white;
  font-weight: 900;
  font-size: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
