/* Pidomi Track - estilos. Paleta calida: base oscura teal + naranja calido. */
:root {
  --pidomi-dark: #0E3A47;       /* base oscura teal */
  --pidomi-dark-2: #0a2c36;
  --pidomi-orange: #FF7A33;     /* naranja calido (acento) */
  --pidomi-orange-soft: #ffd9c2;
  --pidomi-cream: #FFF6EF;
  --pidomi-text: #0E3A47;
  --pidomi-muted: #6b7d83;
  --pidomi-line: #e7ddd4;
  --ok: #1f9d6b;
  --warn: #e0a106;
  --bad: #d24b3e;
  --radius: 18px;
  --shadow: 0 8px 30px rgba(14, 58, 71, 0.18);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--pidomi-cream);
  color: var(--pidomi-text);
}

.hidden { display: none !important; }

/* Topbar */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--pidomi-dark);
  color: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.brand-text {
  font-weight: 800;
  font-size: 22px;
  letter-spacing: 0.5px;
  color: #fff;
}

/* sin punto sobre la "i" (decoración eliminada) */
.brand-i { color: inherit; }
.brand-i::after { content: none; }

.lang-switch { display: flex; gap: 6px; }
.lang-btn {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.lang-btn.active {
  background: var(--pidomi-orange);
  color: #fff;
}

/* Layout */
.layout {
  position: relative;
  height: 100%;
  padding-top: 56px;
}

/* Mapa */
.map-wrap {
  position: absolute;
  top: 56px; left: 0; right: 0; bottom: 0;
  /* z-index bajo pero EXPLÍCITO: crea un stacking context propio para que
     los panes internos de Leaflet (z-index 200–1000) queden confinados aquí
     y NO tapen el panel (z-index 10), el message-card (30) ni la topbar (20),
     que son hermanos absolutos. Sin esto el mapa cubría TODO el panel (Mapbox
     GL era un solo canvas y no daba este problema). */
  z-index: 1;
}
.map { width: 100%; height: 100%; }
.map-fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--pidomi-dark), var(--pidomi-dark-2));
  color: var(--pidomi-orange-soft);
  text-align: center;
  padding: 24px;
}

/* Panel deslizable inferior */
.panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 10;
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 70%;
  overflow-y: auto;
}
.panel-handle {
  width: 44px; height: 5px;
  background: var(--pidomi-line);
  border-radius: 999px;
  margin: 4px auto 14px;
}

.status-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.status-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  margin-top: 6px;
  flex: 0 0 auto;
  background: var(--pidomi-orange);
  box-shadow: 0 0 0 6px rgba(255,122,51,0.18);
}
.status-dot.is-ok { background: var(--ok); box-shadow: 0 0 0 6px rgba(31,157,107,0.18); }
.status-dot.is-bad { background: var(--bad); box-shadow: 0 0 0 6px rgba(210,75,62,0.18); }
.status-dot.is-live {
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255,122,51,0.45); }
  100% { box-shadow: 0 0 0 14px rgba(255,122,51,0); }
}

.status-title {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.15;
}
.status-detail {
  margin: 4px 0 0;
  color: var(--pidomi-muted);
  font-size: 14px;
}

.eta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--pidomi-cream);
  border-radius: 14px;
  margin-bottom: 14px;
}
.eta-label { display: block; font-size: 12px; color: var(--pidomi-muted); }
.eta-value { display: block; font-size: 24px; font-weight: 800; color: var(--pidomi-dark); }
.driver-block { text-align: right; }
.driver-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--pidomi-muted);
}
.driver-status.online { color: var(--ok); }

.progress {
  height: 8px;
  background: var(--pidomi-line);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pidomi-orange), #ff9a5e);
  border-radius: 999px;
  transition: width 0.6s ease;
}

.stops {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}
.stops li {
  position: relative;
  padding: 0 0 16px 26px;
  font-size: 14px;
}
.stops li::before {
  content: "";
  position: absolute;
  left: 6px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--pidomi-orange);
}
.stops li.done::before { background: var(--pidomi-orange); }
.stops li::after {
  content: "";
  position: absolute;
  left: 10px; top: 16px; bottom: 0;
  width: 2px;
  background: var(--pidomi-line);
}
.stops li:last-child::after { display: none; }
.stop-kind { font-weight: 700; color: var(--pidomi-dark); }
.stop-name { color: var(--pidomi-muted); }

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--pidomi-line);
  padding-top: 12px;
  font-size: 12px;
  color: var(--pidomi-muted);
}
.tracking-number { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Tarjeta de mensaje (error / sin pedido) */
.message-card {
  position: absolute;
  z-index: 30;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(92%, 420px);
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  text-align: center;
}
.message-icon {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--pidomi-orange-soft);
  color: var(--pidomi-orange);
  font-size: 28px;
  font-weight: 800;
  line-height: 52px;
}
.message-card h2 { margin: 0 0 8px; font-size: 19px; }
.message-card p { margin: 0; color: var(--pidomi-muted); font-size: 14px; }

/* Marcadores del mapa */
.mk-driver, .mk-pickup, .mk-dropoff {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-size: 16px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.3);
  border: 3px solid #fff;
}
.mk-driver { background: var(--pidomi-orange); }
.mk-pickup { background: var(--pidomi-dark); color: #fff; }
.mk-dropoff { background: var(--ok); color: #fff; }

/* Escritorio: panel a la izquierda */
@media (min-width: 880px) {
  .panel {
    left: 24px;
    bottom: 24px;
    width: 380px;
    max-height: calc(100% - 48px - 56px);
    border-radius: var(--radius);
  }
  .panel-handle { display: none; }
}

/* ---- Foto de la mercancía al ser recogida (prueba anti-robo del comercio) ---- */
.pickup-proof {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--pidomi-line);
  border-radius: 14px;
  background: var(--pidomi-cream);
}
.pickup-proof.hidden { display: none; }
.pp-title { margin: 0 0 10px; font-size: 15px; font-weight: 800; color: var(--pidomi-dark); }
.pp-img {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: 12px;
  background: #000;
}
/* Varias fotos de una misma entrega: se apilan; a partir de la segunda se separan. */
.pp-imgs > .pp-img + .pp-img { margin-top: 8px; }
.pp-hint {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: #8a6400;
  background: rgba(224, 161, 6, 0.12);
  border: 1px solid rgba(224, 161, 6, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
}
.pp-note {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--pidomi-muted);
  text-align: center;
}

/* nombre de marca en chino (拼多米): píldora naranja. Oculta si vacío. */
.brand { display: inline-flex; align-items: center; }
.brand-cn {
  font-size: 12px; font-weight: 800; letter-spacing: 2px; line-height: 1.4;
  color: #fff; background: var(--pidomi-orange); padding: 2px 8px 3px; border-radius: 999px;
  white-space: nowrap; margin-left: 6px;
}
.brand-cn:empty { display: none; }
