/* ────────────────────────────────────────────────────────────────────────
 * Dayfast Tracking — page web publique de suivi de course en temps réel.
 * Design system aligné sur l'app mobile (palette sky-blue Dayfast).
 *
 * - Mobile-first (la plupart des destinataires ouvrent sur smartphone via
 *   WhatsApp).
 * - Aucune dépendance build : CSS pur, prêt à servir derrière un CDN ou
 *   le backend Express en static.
 * ──────────────────────────────────────────────────────────────────────── */

:root {
  --c-bg: #F8FAFC;
  --c-text: #0F172A;
  --c-sub: #64748B;
  --c-line: rgba(15, 23, 42, 0.08);
  --c-card: #FFFFFF;
  --c-primary: #004AAD;
  --c-primary-soft: rgba(0, 74, 173, 0.10);
  --c-sky: #2E5FA8;
  --c-green: #16A34A;
  --c-amber: #D97706;
  --c-red: #DC2626;
  --c-red-soft: rgba(220, 38, 38, 0.10);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.12);
  --radius-md: 14px;
  --radius-lg: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ─────────────────────────── HEADER BRANDING ─────────────────────────── */
.brand-bar {
  position: relative;
  z-index: 1000;
  background: linear-gradient(135deg, #004AAD 0%, #2E5FA8 100%);
  color: #FFFFFF;
  padding: env(safe-area-inset-top, 0px) 0 0 0;
  box-shadow: 0 2px 6px rgba(0, 74, 173, 0.25);
}

.brand-bar__inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.brand-logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  flex-shrink: 0;
}

.brand-text { flex: 1; min-width: 0; }

.brand-title {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.2px;
}

.brand-sub {
  font-size: 11.5px;
  font-weight: 500;
  opacity: 0.85;
  margin-top: 1px;
}

.live-pulse {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.15);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.7); }
  70%  { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); }
  100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

/* ─────────────────────────── MAP ─────────────────────────── */
.map-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  position: absolute;
  inset: 0;
  background: #E5E7EB;
}

/* Reset des marges Leaflet par défaut + style des contrôles */
.leaflet-control-attribution {
  font-size: 9.5px !important;
  background: rgba(255, 255, 255, 0.75) !important;
}

.leaflet-control-zoom {
  border: none !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12) !important;
}

/* Marqueur chauffeur — image voiture vue de dessus (style Uber/Bolt) avec
   halo pulsant pour signaler la position en direct. L'image est tournée selon
   le cap de déplacement directement via inline style. */
.driver-marker {
  width: 56px;
  height: 56px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.driver-marker__img {
  width: 52px;
  height: 52px;
  object-fit: contain;
  display: block;
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 3px 6px rgba(15, 23, 42, 0.35));
  transition: transform 0.6s ease-out;
}

.driver-marker__halo {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: rgba(0, 74, 173, 0.30);
  z-index: 1;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0%   { transform: scale(0.85); opacity: 0.7; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* Marqueur pickup (vert) et destination (rouge) */
.point-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.point-marker--pickup { background: #16A34A; }
.point-marker--dest   { background: #DC2626; }

/* État vide / erreur */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 252, 0.94);
  z-index: 500;
  padding: 24px;
}

.empty-state__card {
  background: var(--c-card);
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  text-align: center;
  max-width: 320px;
  box-shadow: var(--shadow-md);
}

.empty-state__icon { font-size: 38px; margin-bottom: 8px; }
.empty-state h2    { margin: 4px 0 6px; font-size: 17px; }
.empty-state p     { margin: 0; color: var(--c-sub); font-size: 13.5px; line-height: 1.45; }

/* ─────────────────────────── PANNEAU INFOS BAS ─────────────────────────── */
.info-sheet {
  position: relative;
  z-index: 900;
  background: var(--c-card);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.10);
  padding: 8px 16px calc(16px + var(--safe-bottom));
  max-height: 56vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.info-sheet__handle {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.18);
  margin: 4px auto 12px;
}

/* Bandeau ETA */
.eta-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(135deg, #EFF6FF 0%, #DBEAFE 100%);
  border: 1px solid rgba(0, 74, 173, 0.18);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.eta-card__icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--c-primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.eta-card__text  { flex: 1; min-width: 0; }
.eta-card__label { font-size: 11.5px; font-weight: 600; color: var(--c-sky); margin-bottom: 2px; }
.eta-card__time  { font-size: 22px; font-weight: 800; color: var(--c-text); letter-spacing: -0.5px; }
.eta-card__unit  { font-size: 12px; font-weight: 700; color: var(--c-sub); margin-left: 2px; }
.eta-card__sep   { color: var(--c-line); margin: 0 8px; font-weight: 400; }

/* Carte chauffeur */
.driver-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--c-card);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}

.driver-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #E5E7EB;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #FFFFFF;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.10);
}

.driver-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.driver-info { flex: 1; min-width: 0; }

.driver-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--c-text);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.driver-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--c-sub);
  font-weight: 500;
}

.driver-plate {
  background: rgba(15, 23, 42, 0.06);
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 800;
  color: var(--c-text);
  font-size: 11px;
  letter-spacing: 0.5px;
}

.dot-sep { opacity: 0.5; }

.driver-rating {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--c-text);
}

/* Carte route */
.route-card {
  padding: 12px 14px;
  background: var(--c-card);
  border: 1px solid var(--c-line);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.route-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.route-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.route-dot--pickup { background: #16A34A; }
.route-dot--dest   { background: #DC2626; }

.route-text { flex: 1; min-width: 0; }

.route-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--c-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 1px;
}

.route-addr {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--c-text);
  line-height: 1.35;
}

.route-divider {
  width: 1px;
  height: 14px;
  margin-left: 5px;
  background: var(--c-line);
  margin-top: 4px;
  margin-bottom: 4px;
}

/* Actions */
.action-row {
  display: flex;
  gap: 10px;
}

.action-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  border: 1px solid transparent;
  letter-spacing: -0.1px;
  transition: transform 0.12s ease;
}

.action-btn:active { transform: scale(0.97); }

.action-btn--ghost {
  background: rgba(0, 74, 173, 0.06);
  color: var(--c-primary);
  border-color: rgba(0, 74, 173, 0.18);
}

.action-btn--danger {
  background: var(--c-red);
  color: #FFFFFF;
}

.footer-note {
  margin-top: 14px;
  text-align: center;
  font-size: 11px;
  color: var(--c-sub);
  font-weight: 500;
}

/* ─────────────────────────── BANNIÈRE RÉSEAU ─────────────────────────── */
.net-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(217, 119, 6, 0.95);
  color: #FFFFFF;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.35);
}

/* ─────────────────────────── DESKTOP ADAPT ─────────────────────────── */
@media (min-width: 768px) {
  body {
    background: #E5E7EB;
  }
  .info-sheet {
    max-width: 460px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    margin-top: -22px;
    box-shadow: var(--shadow-md);
  }
}
