/* ---------- Generic layout utilities ---------- */
/* minmax(0, 1fr) et non 1fr : sinon le min-content d'un enfant large
   (un tableau, un badge nowrap) gonfle la colonne et fait déborder la page,
   au lieu de laisser l'enfant défiler dans son propre conteneur. */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: minmax(0, 1fr); }
.grid-3 { grid-template-columns: minmax(0, 1fr); }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); } .gap-5 { gap: var(--sp-5); } .gap-6 { gap: var(--sp-6); }
.mt-2 { margin-top: var(--sp-2); } .mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); } .mb-4 { margin-bottom: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-5 { margin-bottom: var(--sp-5); } .mb-3 { margin-bottom: var(--sp-3); } .mb-6 { margin-bottom: var(--sp-6); }
.text-muted { color: var(--text-muted); }
.text-faint { color: var(--text-faint); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* Sur téléphone, un nom d'entreprise coupé (« Garage Nord A… ») ne sert à
   rien : dans une ligne de liste, le titre passe sur deux lignes au lieu
   d'être tronqué. Les lignes secondaires restent tronquées. */
@media (max-width: 720px) {
  .row-card .font-bold.truncate,
  .row-card .truncate.font-bold {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}
.flex-1 { flex: 1; min-width: 0; }
.hide-mobile { display: none; }
.hide-desktop { display: block; }
@media (min-width: 1024px) {
  .hide-mobile { display: block; }
  .hide-desktop { display: none; }
}

/* ---------- Auth / vitrine layout ---------- */
.centered-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
}
.auth-card { width: 100%; max-width: 420px; }
.auth-logo { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-lg); font-weight: 800; margin-bottom: var(--sp-8); justify-content: center; }
.auth-logo .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

/* ---------- Cart drawer (achat de zones) ---------- */
.cart-drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: 100%; max-width: 420px;
  background: var(--bg-elevated); border-left: 1px solid var(--border);
  z-index: 90; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.cart-items { flex: 1; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.cart-footer { border-top: 1px solid var(--border); padding: var(--sp-4); }
.dept-group { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.dept-group-head { padding: var(--sp-3) var(--sp-4); background: var(--bg-elevated-2); font-weight: 700; font-size: var(--fs-sm); }

/* ---------- Map ---------- */
.map-wrap { position: relative; height: 60vh; min-height: 420px; border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); isolation: isolate; }
@media (min-width: 1024px) { .map-wrap { height: calc(100vh - var(--topbar-h) - var(--sp-16)); } }
.map-legend {
  position: absolute; left: var(--sp-3); bottom: var(--sp-3); z-index: 10;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--sp-3); display: flex; flex-direction: column; gap: 6px; box-shadow: var(--shadow-md);
  /* La légende ne doit jamais dépasser de la carte : elle se limite à la
     hauteur disponible et défile, au lieu d'être coupée en bas. */
  max-height: calc(100% - var(--sp-6)); overflow-y: auto;
  max-width: calc(100% - var(--sp-6));
}
@media (max-width: 720px) {
  /* Sur téléphone la colonne mangerait la moitié de la carte : les
     statuts passent en ligne, sur deux rangs si besoin. */
  .map-legend {
    right: var(--sp-3); flex-direction: row; flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-3); max-height: 34%;
  }
}
.map-legend-item { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-xs); font-weight: 600; padding: 3px 4px; border-radius: 6px; }
.map-legend-item.off { opacity: 0.35; }
.map-legend-dot { width: 9px; height: 9px; border-radius: 50%; }

/* ---------- Dossier detail ---------- */
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); }
.action-bar { position: sticky; bottom: var(--bottom-nav-h); left: 0; right: 0; background: var(--bg-elevated); border-top: 1px solid var(--border); padding: var(--sp-3) var(--sp-4); display: flex; gap: var(--sp-3); z-index: 20; }
@media (min-width: 1024px) { .action-bar { position: static; border-top: none; background: none; padding: 0; margin-top: var(--sp-5); } }

/* ---------- France map dept grid fallback ---------- */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); }

/* ---------- Progress / pipeline bar ---------- */
.pipeline-bar { display: flex; height: 12px; border-radius: var(--radius-full); overflow: hidden; background: var(--bg-elevated-3); }
.pipeline-bar span { height: 100%; }

/* Console admin sur téléphone : les blocs qui n'ont de sens qu'en largeur
   (courbe, historiques tabulaires) sont remplacés par leur résumé. */
.hide-sm { display: none; }
.only-sm { display: block; }
@media (min-width: 720px) {
  .hide-sm { display: block; }
  .only-sm { display: none; }
}
