* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

:root {
  --mbgmx-navy: #0d1117;
  --mbgmx-navy-panel: #151b26;
  --mbgmx-blue: #2f6fed;
  --mbgmx-cyan: #4fd8f0;
  --mbgmx-glow: rgba(79, 216, 240, 0.55);
}

body {
  background: #f4f5f7;
  color: #1c1c1e;
}

header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 1rem 1.5rem;
  background: var(--mbgmx-navy);
  color: #fff;
  border-bottom: 1px solid rgba(79, 216, 240, 0.25);
}

.header-logo-link {
  flex: 0 0 auto;
  display: flex;
  line-height: 0;
}

.header-logo {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  box-shadow: 0 0 10px var(--mbgmx-glow);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.header-logo-link:hover .header-logo {
  box-shadow: 0 0 16px var(--mbgmx-glow);
  transform: scale(1.03);
}

.header-texte {
  flex: 1;
  min-width: 0;
}

header h1 {
  font-size: 1.15rem;
  background: linear-gradient(90deg, #fff, var(--mbgmx-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.statut {
  margin-top: 0.3rem;
  font-size: 0.85rem;
  color: #9aa3b2;
}
.statut.ok { color: #4ade80; }
.statut.erreur { color: #f87171; }

.aide-api {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: #6b7280;
}
.aide-api code {
  background: #2d3344;
  color: #cbd5e1;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
}

.panneau-controle {
  flex: 1 1 340px;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.bloc {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.bloc h2 {
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.ligne-boutons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.btn-mode {
  flex: 1;
  padding: 0.6rem;
  background: #eaf3ff;
  color: var(--mbgmx-navy);
  border: 1px solid #bcd8ff;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.btn-mode.actif {
  background: var(--mbgmx-blue);
  color: #fff;
  border-color: var(--mbgmx-blue);
}

.panneau-controle label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: #444;
  margin-bottom: 0.4rem;
}

.ligne-recherche {
  display: flex;
  gap: 0.4rem;
}

.ligne-recherche input {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.9rem;
}

.ligne-recherche button {
  padding: 0.5rem 0.8rem;
  background: var(--mbgmx-blue);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.info-recherche {
  margin-top: 0.4rem;
  font-size: 0.78rem;
  color: #6b7280;
  min-height: 1em;
}
.info-recherche.erreur { color: #b91c1c; }

#liste-points-tournee {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#liste-points-tournee li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #f8f9fb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  font-size: 0.82rem;
}

#liste-points-tournee .badge {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--mbgmx-blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
}

#liste-points-tournee .details {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#liste-points-tournee .adresse {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#liste-points-tournee .coord {
  font-size: 0.72rem;
  color: #888;
}

#liste-points-tournee .btn-suppr {
  flex: 0 0 auto;
  background: #fee2e2;
  color: #b91c1c;
  border: none;
  border-radius: 6px;
  padding: 0.3rem 0.5rem;
  cursor: pointer;
}

.aide {
  font-size: 0.78rem;
  color: #888;
  margin-top: 0.5rem;
}

.btn-principal {
  width: 100%;
  padding: 0.65rem;
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  margin-top: 0.4rem;
}
.btn-principal:hover { background: #15803d; }
.btn-principal:disabled { background: #9ca3af; cursor: not-allowed; }

.btn-secondaire {
  width: 100%;
  padding: 0.55rem;
  background: #f3f4f6;
  color: #444;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

#resultat {
  background: #fff;
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.88rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

#resultat .erreur { color: #b91c1c; }
#resultat ol { margin-top: 0.5rem; padding-left: 1.2rem; }

.panneau-carte {
  flex: 2 1 500px;
  min-height: 560px;
}

#map {
  height: 100%;
  min-height: 560px;
  border-radius: 10px;
  overflow: hidden;
  cursor: default;
}

#map.mode-clic {
  cursor: crosshair;
}

/* ===== Surcouche point utilisateur localisé ===== */

.statut-position {
  font-size: 0.8rem;
  color: #444;
  margin-top: 0.4rem;
}

.statut-cible {
  font-size: 0.8rem;
  color: #b91c1c;
  font-weight: 500;
  margin-top: 0.2rem;
  min-height: 1em;
}

.marqueur-depot {
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.35));
}

.ligne-depot {
  background: #eaf3ff;
  border-left: 3px solid var(--mbgmx-navy);
  font-weight: 600;
  justify-content: flex-start;
}

.marqueur-position-utilisateur .point-gps {
  width: 16px;
  height: 16px;
  background: #2563eb;
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 rgba(37, 99, 235, 0.5);
  animation: pulse-gps 2s infinite;
}

@keyframes pulse-gps {
  0%   { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); }
  70%  { box-shadow: 0 0 0 12px rgba(37, 99, 235, 0); }
  100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
}

.ligne-etape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.ligne-etape .texte-etape {
  flex: 1;
}

.btn-atteint {
  flex: 0 0 auto;
  font-size: 0.72rem;
  padding: 0.25rem 0.5rem;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 5px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-atteint:hover { background: #d1fae5; }

.point-atteint {
  opacity: 0.55;
  text-decoration: line-through;
}
.point-atteint .btn-atteint {
  background: #e5e7eb;
  color: #6b7280;
  border-color: #d1d5db;
}

.point-cible {
  background: #fef2f2;
  border-left: 3px solid #dc2626;
  font-weight: 600;
}

/* ===== Mode plein écran carte ===== */

.btn-flottant {
  display: none;
  position: absolute;
  top: 12px;
  z-index: 1300;
  background: var(--mbgmx-navy);
  color: #fff;
  border: 1px solid rgba(79, 216, 240, 0.4);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  font-size: 0.82rem;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}
.btn-flottant-gauche { left: 12px; }
.btn-flottant-droite { right: 12px; }

body.mode-plein-ecran header { display: none; }

body.mode-plein-ecran main {
  padding: 0;
  gap: 0;
  height: 100vh;
}

body.mode-plein-ecran .panneau-carte {
  flex: 1 1 100%;
  min-height: 100vh;
  position: relative;
}

body.mode-plein-ecran #map {
  min-height: 100vh;
  border-radius: 0;
}

body.mode-plein-ecran .btn-flottant {
  display: block;
}

body.mode-plein-ecran .panneau-controle {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(360px, 88vw);
  z-index: 1200;
  background: #fff;
  overflow-y: auto;
  padding: 1rem;
  box-shadow: 4px 0 18px rgba(0, 0, 0, 0.3);
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

body.mode-plein-ecran .panneau-controle.ouvert {
  transform: translateX(0);
}