/* ==========================================================================
   Newo — Module de géolocalisation par lien
   Nécessite tokens.css chargé avant ce fichier.
   ========================================================================== */

.geo-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 5vw, 48px);
  background:
    radial-gradient(circle at 15% 10%, rgba(56, 225, 198, 0.08), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(255, 176, 32, 0.10), transparent 50%),
    var(--navy-950);
}

.geo-card {
  width: 100%;
  max-width: 440px;
  background: var(--navy-900);
  border: 1px solid var(--navy-700);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 4vw, 34px);
  box-shadow: var(--shadow-card);
}

.geo-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 26px;
}

.geo-brand .brand-mark { width: 32px; height: 32px; flex-shrink: 0; }

.geo-brand .brand-name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
}

.geo-brand .brand-name span { color: var(--amber); }

/* ---------------------------------------------------------------------- */
/* Page de consentement client (locate.php)                                */
/* ---------------------------------------------------------------------- */

.geo-icon-badge {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  display: grid;
  place-content: center;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, rgba(255, 176, 32, 0.16), rgba(56, 225, 198, 0.12));
  border: 1px solid var(--navy-600);
  position: relative;
}

.geo-icon-badge svg { width: 28px; height: 28px; color: var(--amber); }

.geo-icon-badge::before {
  content: "";
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(56, 225, 198, 0.3);
  animation: geo-pulse 2.4s ease-out infinite;
}

@keyframes geo-pulse {
  0%   { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

.geo-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  text-align: center;
  margin: 0 0 10px;
  font-weight: 600;
}

.geo-desc {
  color: var(--fog);
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.6;
  margin: 0 0 26px;
}

.geo-desc strong { color: var(--white); }

.btn-share-location {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.97rem;
  color: var(--on-accent);
  background: linear-gradient(90deg, var(--amber-soft), var(--amber));
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  transition: filter 0.12s ease, transform 0.12s ease;
}

.btn-share-location svg { width: 18px; height: 18px; }
.btn-share-location:hover { filter: brightness(1.05); }
.btn-share-location:active { transform: scale(0.99); }
.btn-share-location:disabled { opacity: 0.6; cursor: default; }

.geo-privacy-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 18px;
  color: var(--fog-dim);
  font-size: 0.78rem;
  line-height: 1.5;
}

.geo-privacy-note svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

/* États dynamiques (gérés en JS) */
.geo-state { display: none; }
.geo-state.active { display: block; }

.geo-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(10, 15, 28, 0.35);
  border-top-color: var(--on-accent);
  animation: geo-spin 0.7s linear infinite;
}

@keyframes geo-spin { to { transform: rotate(360deg); } }

.geo-success {
  text-align: center;
}

.geo-success .geo-icon-badge {
  background: linear-gradient(135deg, rgba(56, 225, 198, 0.2), rgba(56, 225, 198, 0.08));
}

.geo-success .geo-icon-badge::before { display: none; }
.geo-success .geo-icon-badge svg { color: var(--cyan); }

.geo-error-box {
  background: var(--danger-bg);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: #ffb3b3;
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.85rem;
  line-height: 1.55;
  margin-top: 16px;
}

#recalibrate-box {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--navy-700);
}

#follow-driver-section {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--navy-700);
}

.follow-map-wrap {
  position: relative;
  height: 240px;
  margin-top: 14px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--navy-700);
  background: var(--navy-900);
}

.follow-map-wrap #follow-map { width: 100%; height: 100%; }

/* ---------------------------------------------------------------------- */
/* Page de création de demande (request-location.php)                      */
/* ---------------------------------------------------------------------- */

.geo-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fog-dim);
  margin: 0 0 6px;
}

.geo-heading {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 8px;
  font-weight: 600;
}

.geo-subtext {
  color: var(--fog);
  font-size: 0.9rem;
  margin: 0 0 24px;
  line-height: 1.55;
}

.geo-field { margin-bottom: 16px; }

.geo-field label {
  display: block;
  font-size: 0.83rem;
  color: var(--fog);
  margin-bottom: 7px;
}

.geo-field input {
  width: 100%;
  background: var(--navy-950);
  border: 1px solid var(--navy-700);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
}

.geo-field input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 3px rgba(56, 225, 198, 0.15);
}

.geo-field-hint {
  font-size: 0.76rem;
  color: var(--fog-dim);
  margin-top: 6px;
}

.btn-primary-block {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--on-accent);
  background: linear-gradient(90deg, var(--amber-soft), var(--amber));
  cursor: pointer;
}

.btn-primary-block:hover { filter: brightness(1.05); }

.geo-link-box {
  margin-top: 22px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--navy-950);
  border: 1px solid var(--navy-700);
}

.geo-link-box .label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fog-dim);
  margin-bottom: 8px;
  display: block;
}

.geo-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.geo-link-row input {
  flex: 1;
  min-width: 0;
  background: var(--navy-900);
  border: 1px solid var(--navy-700);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
}

.btn-copy {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--navy-700);
  background: var(--navy-900);
  color: var(--fog);
  display: grid;
  place-content: center;
  cursor: pointer;
}

.btn-copy svg { width: 16px; height: 16px; }
.btn-copy:hover { color: var(--white); border-color: var(--cyan); }
.btn-copy.copied { color: var(--cyan); border-color: var(--cyan); }

.geo-share-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.geo-share-btn {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--navy-700);
  background: var(--navy-900);
  color: var(--white);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
}

.geo-share-btn svg { width: 17px; height: 17px; color: var(--cyan); }
.geo-share-btn:hover { border-color: var(--cyan); }

.geo-track-link {
  display: block;
  text-align: center;
  margin-top: 18px;
  color: var(--cyan);
  font-size: 0.86rem;
  text-decoration: none;
}

.geo-track-link:hover { text-decoration: underline; }

/* ---------------------------------------------------------------------- */
/* Page de suivi (track.php)                                               */
/* ---------------------------------------------------------------------- */

.track-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.track-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px clamp(16px, 3vw, 32px);
  background: var(--navy-900);
  border-bottom: 1px solid var(--navy-700);
  flex-wrap: wrap;
}

.track-header .geo-brand { margin-bottom: 0; }

.track-client {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.track-client-info { display: flex; flex-direction: column; gap: 2px; }

.track-client-name {
  font-size: 0.88rem;
  color: var(--white);
}

.track-client-phone {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--fog-dim);
}

.track-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 500;
  white-space: nowrap;
}

.track-status.pending {
  color: var(--amber);
  background: rgba(255, 176, 32, 0.1);
  border: 1px solid rgba(255, 176, 32, 0.3);
}

.track-status.shared {
  color: var(--cyan);
  background: rgba(56, 225, 198, 0.1);
  border: 1px solid rgba(56, 225, 198, 0.3);
}

.track-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.track-map-wrap {
  position: relative;
  flex: 1 1 auto;
  height: 60vh;
  min-height: 320px;
  background: var(--navy-900);
}

#track-map {
  width: 100%;
  height: 100%;
  min-height: 320px;
}

.track-waiting {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(10, 15, 28, 0.72);
  backdrop-filter: blur(3px);
  text-align: center;
  padding: 20px;
  z-index: 500;
}

.track-waiting .geo-spinner {
  border-color: rgba(244, 246, 251, 0.2);
  border-top-color: var(--cyan);
  width: 26px;
  height: 26px;
}

.track-waiting p {
  color: var(--fog);
  font-size: 0.92rem;
  max-width: 30ch;
  margin: 0;
}

.track-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px clamp(16px, 3vw, 32px);
  background: var(--navy-900);
  border-top: 1px solid var(--navy-700);
  flex-wrap: wrap;
}

.track-coords {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
}

.track-coords .stat { display: flex; flex-direction: column; gap: 2px; }

.track-coords .stat-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fog-dim);
}

.track-coords .stat-value {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--white);
}

.track-footer .geo-share-btn { flex: none; min-width: 0; }

.track-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.finish-trip-btn {
  border-style: solid;
  color: var(--cyan);
  border-color: rgba(56, 225, 198, 0.35);
}

.finish-trip-btn:hover { border-color: var(--cyan); background: rgba(56, 225, 198, 0.08); }
.finish-trip-btn svg { color: var(--cyan); }

/* Fenêtre de confirmation avant de terminer la course */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 15, 28, 0.72);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.confirm-box {
  width: 100%;
  max-width: 380px;
  background: var(--navy-900);
  border: 1px solid var(--navy-700);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-card);
}

.confirm-box h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 8px;
  font-weight: 600;
}

.confirm-box p {
  color: var(--fog);
  font-size: 0.87rem;
  line-height: 1.55;
  margin: 0 0 20px;
}

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

.btn-ghost-block {
  flex: 1;
  border: 1px solid var(--navy-600);
  background: transparent;
  color: var(--white);
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
}

.btn-ghost-block:hover { border-color: var(--cyan); background: var(--navy-800); }
.confirm-actions .btn-primary-block { flex: 1; }

/* Marqueur personnalisé sur la carte */
.track-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cyan);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 6px rgba(56, 225, 198, 0.25);
}

.track-marker-driver {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--amber);
  border: 3px solid var(--white);
  box-shadow: 0 0 0 6px rgba(255, 176, 32, 0.25);
}

/* Avatar moto-livreur : badge circulaire, tourne selon le cap de déplacement */
.moto-marker {
  width: 54px;
  height: 54px;
  transition: transform 0.4s ease;
  transform-origin: center center;
}

.moto-marker-badge {
  width: 51px;
  height: 51px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--amber-soft), var(--amber));
  border: 3px solid var(--white);
  box-shadow: 0 0 0 6px rgba(255, 176, 32, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.moto-marker-badge svg { width: 27px; height: 27px; }

/* Bouton flottant : activer la position du livreur pour l'itinéraire */
.btn-enable-driver {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--navy-600);
  background: rgba(15, 22, 38, 0.9);
  backdrop-filter: blur(6px);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}

.btn-enable-driver svg { width: 16px; height: 16px; color: var(--amber); flex-shrink: 0; }
.btn-enable-driver:hover { border-color: var(--amber); }

.btn-enable-driver.active {
  color: var(--on-accent);
  background: linear-gradient(90deg, var(--amber-soft), var(--amber));
  border-color: transparent;
}

.btn-enable-driver.active svg { color: var(--on-accent); }

/* Résumé d'itinéraire (distance / ETA) */
.route-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px clamp(16px, 3vw, 32px);
  background: var(--navy-900);
  border-top: 1px solid var(--navy-700);
  flex-wrap: wrap;
}

.route-summary-stats {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.route-summary-stats .stat { display: flex; flex-direction: column; gap: 2px; }

.route-summary-stats .stat-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fog-dim);
}

.route-summary-stats .stat-value {
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.route-summary-stats .stat-value.accent { color: var(--amber); }

.route-steps-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--navy-700);
  border-radius: var(--radius-sm);
  color: var(--fog);
  font-size: 0.82rem;
  padding: 7px 12px;
  cursor: pointer;
}

.route-steps-toggle svg { width: 14px; height: 14px; transition: transform 0.15s ease; }
.route-steps-toggle:hover { color: var(--white); border-color: var(--cyan); }
.route-steps-toggle.open svg { transform: rotate(180deg); }

/* Liste d'étapes (guidage turn-by-turn), masquée par défaut */
.route-steps-list {
  display: none;
  list-style: none;
  margin: 0;
  padding: 4px clamp(16px, 3vw, 32px) 16px;
  background: var(--navy-900);
  border-top: 1px solid var(--navy-800);
  max-height: 220px;
  overflow-y: auto;
}

.route-steps-list.open { display: block; }

.route-steps-list li {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--navy-800);
  font-size: 0.85rem;
  color: var(--white);
}

.route-steps-list li:last-child { border-bottom: none; }

.route-steps-list .step-distance {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--fog-dim);
  min-width: 4.2em;
  text-align: right;
}

/* La bibliothèque Leaflet Routing Machine affiche par défaut son propre
   panneau d'itinéraire non stylé : on le masque, on construit le nôtre
   à partir de ses données (voir geoloc-track.js). */
.leaflet-routing-container { display: none !important; }

/* ---------------------------------------------------------------------- */
/* Responsive                                                               */
/* ---------------------------------------------------------------------- */

@media (max-width: 480px) {
  .geo-card { padding: 22px 18px; }
  .geo-share-actions { flex-direction: column; }
  .geo-share-btn { min-width: 0; }
}

@media (max-width: 640px) {
  .track-client { margin-left: 0; width: 100%; justify-content: space-between; }
  .track-header { flex-direction: column; align-items: flex-start; }
  .track-footer { flex-direction: column; align-items: stretch; }
  .track-coords { justify-content: space-between; }
  .btn-enable-driver span { display: none; }
  .btn-enable-driver { padding: 10px; }
  .route-summary { flex-direction: column; align-items: stretch; }
  .track-footer-actions { flex-direction: column; align-items: stretch; width: 100%; }
  .track-footer-actions .geo-share-btn { justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  .geo-icon-badge::before { animation: none; }
  .geo-spinner { animation-duration: 1.4s; }
}
