/* ==========================================================================
   GoEldo Riders - Pantalla completa de tracking (drawer + controles flotantes)
   ========================================================================== */
.rp-track-screen {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: #F3EFE5;
  display: grid;
  grid-template-rows: 1fr auto;
  transition: opacity .2s ease;
}
.rp-track-screen[hidden] { display: none !important; }
.rp-track-map {
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  background: #E5E0D8;
}
.rp-fab {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  z-index: 2100;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 800;
  border: 1.5px solid rgba(200,195,182,.9);
  background: rgba(255,255,255,.96);
  color: #2E331E;
  box-shadow: 0 6px 18px rgba(46,51,30,.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.rp-fab:active { transform: translateY(1px); }
.rp-fab-back { left: 12px; }
.rp-fab-center {
  left: auto;
  right: 12px;
}
.rp-instr {
  position: absolute;
  top: calc(66px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2090;
  width: calc(100% - 24px);
  max-width: 520px;
  background: rgba(46,51,30,.94);
  color: #FFFFFF;
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(46,51,30,.25);
}
.rp-instr.hidden { display: none; }
.rp-instr .cur {
  font-size: 15px;
  font-weight: 900;
  line-height: 1.2;
}
.rp-instr .nxt {
  font-size: 11.5px;
  color: rgba(255,255,255,.78);
  margin-top: 4px;
  line-height: 1.2;
}
/* bottom drawer */
.rp-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2080;
  background: #FFFFFF;
  box-shadow: 0 -10px 30px rgba(46,51,30,.12);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 6px 14px calc(14px + env(safe-area-inset-bottom));
  transform: translateY(0);
  transition: transform .25s ease;
  max-height: 62vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.rp-drawer.collapsed { transform: translateY(calc(100% - 84px)); }
.rp-drawer-handle {
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: #D6D0C4;
  margin: 8px auto 10px;
  cursor: grab;
  touch-action: pan-y;
}
.rp-drawer .rp-drawer-inner { display: flex; flex-direction: column; gap: 10px; }
.rp-drawer .head {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.rp-drawer .head .code { font-size: 15px; font-weight: 900; color: #2E331E; }
.rp-drawer .head .com { font-size: 12.5px; color: #5C673C; }
.rp-drawer .head .live { margin-left: auto; }
.rp-drawer .rp-prog { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.rp-drawer .rp-prog .bar { height: 8px; background: #EAE6D9; border-radius: 999px; overflow: hidden; }
.rp-drawer .rp-prog .bar > i { display: block; height: 100%; width: 0%; background: #8A9A5B; transition: width .3s ease; }
.rp-drawer .rp-prog .pct { font-size: 12px; font-weight: 800; color: #2E331E; }
.rp-drawer .rp-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.rp-drawer .rp-fact { display: flex; flex-direction: column; }
.rp-drawer .rp-fact b { font-size: 10px; color: #9AA08C; text-transform: uppercase; letter-spacing: .04em; }
.rp-drawer .rp-fact span { font-size: 12.5px; color: #2E331E; font-weight: 700; }
.rp-drawer .rp-acts-2 { display: flex; gap: 10px; }
.rp-drawer .rp-acts-2 .rp-btn { flex: 1; }

.rp-drawer::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  background: linear-gradient(transparent, rgba(46,51,30,.03));
  pointer-events: none;
}

.rp-alert-gps {
  position: absolute;
  top: calc(120px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  z-index: 2095;
  background: #FEF1EC; color: #9D2F2F;
  border: 1px solid #F3CFC5;
  padding: 10px 14px; border-radius: 12px;
  font-size: 12.5px; font-weight: 700;
  max-width: calc(100% - 24px);
  box-shadow: 0 6px 18px rgba(157,47,47,.12);
}

/* desktop side-by-side controls on wide screens */
@media (min-width: 760px) {
  .rp-fab-back, .rp-fab-center { top: calc(16px + env(safe-area-inset-top)); }
  .rp-instr { width: auto; left: 12px; transform: none; max-width: 360px; }
  .rp-drawer { left: auto; right: 12px; bottom: 12px; width: 360px; max-height: 70vh; border-radius: 22px; }
}

/* ensure the map canvas fills when resized */
.leaflet-container { width: 100% !important; height: 100% !important; }

body.is-tracking { overflow: hidden; }
.rp-map-box-idle { display: none; }
/* ------------------------------------------------------------------ */
/* Demos: preview + modo navegacion (flecha, banner top, status bottom) */
/* ------------------------------------------------------------------ */

.rp-top-banner {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2105;
  width: calc(100% - 24px);
  max-width: 520px;
  background: rgba(46, 51, 30, .96);
  color: #FFFFFF;
  padding: 12px 14px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(46, 51, 30, .28);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
.rp-top-banner.hidden { display: none; }
.rp-top-banner .man {
  font-size: 15px; font-weight: 900; line-height: 1.2;
  flex: 1 1 auto;
}
.rp-top-banner .dist {
  font-size: 12px;
  color: rgba(255,255,255,.78);
  white-space: nowrap;
}

.rp-demo-badge {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top));
  right: 12px;
  z-index: 2106;
  background: #FFF3CD;
  color: #8A6D00;
  border: 1px solid #F1E2A0;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.rp-demo-badge.hidden { display: none; }

/* arrow marker: do not use car icon */
.rp-pin.arrow {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none !important;
  border: none !important;
  box-shadow: none !important;
}
.rp-pin .arrow-svg {
  width: 26px;
  height: 26px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(46,51,30,.35));
  will-change: transform;
}

/* preview card (bottom) */
.rp-preview-card {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2110;
  background: #FFFFFF;
  border-top-left-radius: 22px; border-top-right-radius: 22px;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 30px rgba(46,51,30,.12);
  display: flex; flex-direction: column; gap: 10px;
}
.rp-preview-card.hidden { display: none; }
.rp-preview-card .head {
  display: flex; align-items: center; gap: 10px;
}
.rp-preview-card .icon-nav { font-size: 26px; line-height: 1; }
.rp-preview-card .title { font-size: 15px; font-weight: 900; color: #2E331E; }
.rp-preview-card .sub { font-size: 11.5px; color: #5C673C; margin-top: 2px; }
.rp-preview-card .stats {
  display: flex; gap: 16px; justify-content: center; align-items: baseline;
}
.rp-preview-card .stat { text-align: center; min-width: 60px; }
.rp-preview-card .k { font-size: 22px; font-weight: 900; color: #2E331E; line-height: 1; }
.rp-preview-card .l { font-size: 10px; color: #9AA08C; text-transform: uppercase; letter-spacing: .04em; }
.rp-preview-card .acts { display: flex; gap: 10px; }

/* bottom navigation status (thin bar) */
.rp-nav-bottom {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 2108;
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid #E4E0D6;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; gap: 8px; align-items: center;
  justify-content: space-between;
}
.rp-nav-bottom.hidden { display: none; }
.rp-nav-bottom .col { text-align: center; flex: 1 1 0; min-width: 0; }
.rp-nav-bottom .k { font-size: 15px; font-weight: 900; color: #2E331E; line-height: 1; }
.rp-nav-bottom .l { font-size: 9.5px; color: #9AA08C; text-transform: uppercase; letter-spacing: .04em; }
.rp-nav-bottom > button { flex: 0 0 auto; min-width: 46px; height: 36px; padding: 0 12px; }

/* persistent demo badge prevention + safety */
.rp-track-screen.nav-tilt .rp-track-map {
  perspective: 820px;
  transform: perspective(820px) rotateX(36deg);
  transform-origin: 50% 60%;
  transition: transform .4s ease;
}
.rp-track-screen .rp-track-map { transition: transform .4s ease; will-change: transform; }

/* mobile bottom sheet adjustments when nav is active */
@media (max-width: 480px) {
  .rp-preview-card .k { font-size: 18px; }
  .rp-nav-bottom .k { font-size: 13px; }
  .rp-top-banner .man { font-size: 13px; }
}
/* done */
/* ------------------------------------------------------------------ */
/* Plano 2D: sin inclinacion ni perspectiva (botones + panel compacto)  */
/* ------------------------------------------------------------------ */

/* 1) Sin pitch CSS: map se queda flat */
.rp-track-screen.nav-tilt .rp-track-map,
.rp-track-map {
  transform: none !important;
  perspective: none !important;
}

/* 2) Botones flotantes por encima del panel inferior */
.rp-fab-back,
.rp-fab-center {
  top: auto !important;
  bottom: calc(108px + env(safe-area-inset-bottom));
  left: 14px;
}
.rp-fab-center {
  left: auto;
  right: 14px;
}
/* fuerza siempre visibles en tracking */
.rp-fab-back,
.rp-fab-center {
  visibility: visible !important;
  opacity: 1 !important;
}

/* 3) Panel compacto (20-25% del alto aprox.) */
.rp-drawer {
  max-height: 30vh;
  padding-top: 4px;
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
}
.rp-drawer-handle { height: 4px; margin: 6px auto 6px; }
.rp-drawer .rp-drawer-inner { gap: 6px; }
.rp-drawer .rp-drawer-inner .head { gap: 6px; }
.rp-drawer .code { font-size: 13px; }
.rp-drawer .com { font-size: 11px; }
.rp-drawer .rp-prog { gap: 6px; }
.rp-drawer .bar { height: 6px; }
.rp-drawer .rp-prog .pct { font-size: 11px; }
.rp-drawer .rp-facts { grid-template-columns: 1fr 1fr 1fr; gap: 4px 8px; }
.rp-drawer .rp-fact b { font-size: 9px; }
.rp-drawer .rp-fact span { font-size: 11.5px; }
.rp-drawer .rp-acts-2 { gap: 6px; }
.rp-drawer .rp-acts-2 .rp-btn { font-size: 11.5px; padding: 6px 10px; }

.rp-preview-card {
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  gap: 6px;
  max-height: 22vh;
  overflow: hidden;
}
.rp-preview-card .head { gap: 6px; margin-bottom: 2px; }
.rp-preview-card .icon-nav { font-size: 18px; }
.rp-preview-card .title { font-size: 13px; line-height: 1.1; }
.rp-preview-card .sub { font-size: 11px; }
.rp-preview-card .k { font-size: 14px; line-height: 1; }
.rp-preview-card .l { font-size: 9px; }
.rp-preview-card .acts { margin-top: 4px; }

.rp-nav-bottom {
  padding: 6px 10px calc(8px + env(safe-area-inset-bottom));
  gap: 6px;
}
.rp-nav-bottom .k { font-size: 13px; }
.rp-nav-bottom .l { font-size: 9px; }
.rp-nav-bottom > button { min-width: 42px; height: 32px; padding: 0 10px; font-size: 11px; }

/* Las bottom píldoras no tapen la barra inferior compacta */
.rp-nav-bottom + .rp-float-controls { display: none; }
/* Relación dinámica: botones siempre por encima del panel inferior compacto (~22-25% alto) */
.rp-fab-back,
.rp-fab-center {
  bottom: calc(22vh + 14px + env(safe-area-inset-bottom)) !important;
}
/* ------------------------------------------------------------------ */
/* Compactacion extra de la barra inferior + botones pegados encima      */
/* ------------------------------------------------------------------ */

.rp-nav-bottom {
  min-height: 38px;
  padding: 4px 8px calc(4px + env(safe-area-inset-bottom));
  gap: 4px;
}
.rp-nav-bottom .k { font-size: 11.5px; line-height: 1.05; }
.rp-nav-bottom .l { font-size: 8.5px; }
.rp-nav-bottom > button {
  min-width: 40px;
  height: 30px;
  padding: 0 8px;
  font-size: 10.5px;
  border-radius: 8px;
}

/* botones flotantes justo por encima de esa barra */
.rp-fab-back,
.rp-fab-center {
  bottom: calc(40px + env(safe-area-inset-bottom)) !important;
}
.rp-fab-back { left: 10px; }
.rp-fab-center { right: 10px; }
/* ------------------------------------------------------------------ */
/* Volver + Centrar lado a lado y un poco mas arriba del footer         */
/* ------------------------------------------------------------------ */

.rp-fab-back,
.rp-fab-center {
  bottom: calc(54px + env(safe-area-inset-bottom)) !important;
}

/* lado a lado: Centrar se apoya a la derecha de Volver */
.rp-fab-back {
  right: auto;
  left: 10px;
}
.rp-fab-center {
  right: auto;
  left: 10px;
  transform: translateX(calc(100% + 10px));
}

/* sombra consistente para las pildoras */
.rp-fab-back,
.rp-fab-center {
  box-shadow: 0 6px 18px rgba(46, 51, 30, .2);
}
/* ------------------------------------------------------------------ */
/* Volver + Centrar juntos (pildoras) por encima de la barra inferior  */
/* ------------------------------------------------------------------ */
.rp-float-controls {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(50px + env(safe-area-inset-bottom));
  z-index: 2115;
  display: flex;
  align-items: center;
  gap: 10px;
}

.rp-float-controls .rp-fab,
.rp-float-controls .rp-fab-back,
.rp-float-controls .rp-fab-center {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  transform: none;
  margin: 0;
}

.rp-float-controls .rp-fab:active {
  transform: translateY(1px);
}

/* Theming del boton Prominente (Centrar cuando se explora) */
.rp-fab-center.prominente {
  background: #2E331E;
  color: #FFFFFF;
  border-color: #2E331E;
  box-shadow: 0 6px 18px rgba(46,51,30,.25);
  font-weight: 900;
}
/* ------------------------------------------------------------------ */
/* Drawer mas intuitivo: tap target grande + estado por defecto abierto  */
/* ------------------------------------------------------------------ */
.rp-drawer-handle {
  width: 48px;
  height: 16px;
  padding: 0;
  border-radius: 8px;
  margin: 8px auto 6px;
  cursor: grab;
  position: relative;
  touch-action: none;
}

/* área táctil generosa encima del handle */
.rp-drawer-handle::before {
  content: '';
  position: absolute;
  top: -12px; left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 36px;
  z-index: 2;
  cursor: grab;
}

.rp-drawer-handle:active::before {
  cursor: grabbing;
}

.rp-drawer-handle span.grip {
  display: block;
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: #C8C2B2;
  margin: 0 auto;
}

.rp-drawer.expanded {
  transform: translateY(0) !important;
}

.rp-drawer.collapsed {
  transform: translateY(calc(100% - 44px)) !important;
}

/* prioridad al texto legible */
.rp-drawer {
  max-height: 38vh;
  transition: transform .25s cubic-bezier(.2,.8,.2,1);
  -webkit-transition: transform .25s cubic-bezier(.2,.8,.2,1);
}

/* ---------- Touch target mínimo 44px (WCAG / Apple HIG) ---------- */
.rp-fab,
.rp-drawer-handle,
.rp-drawer-handle::before,
#rpShareTrack,
#rpBtnLlegue,
#rpBtnSalgo,
#rpBtnEntregado,
#rpBottomCenter {
  min-height: 44px !important;
  min-width: 44px !important;
}

/* Asegurar que el handle del drawer tenga área táctil grande */
.rp-drawer-handle::before {
  min-height: 36px;
  min-width: 120px;
}
