/* =====================================================================
   MapGEST - Feuille de style de l'administration
   Design system B2B SaaS : dense, clair, professionnel. Mode clair.
   ===================================================================== */

/* ---- 1. Tokens ----------------------------------------------------- */
:root {
  /* Couleurs de marque (palette ui-ux-pro-max : navy + CTA bleu) */
  --brand-50:  #f0f9ff;
  --brand-100: #e0f2fe;
  --brand-200: #bae6fd;
  --brand-500: #0ea5e9;
  --brand-600: #0369a1;
  --brand-700: #075985;
  --brand-800: #0c4a6e;

  /* Neutres */
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Sémantique */
  --bg:            var(--gray-50);
  --surface:       #ffffff;
  --surface-alt:   var(--gray-50);
  --border:        var(--gray-200);
  --text:          var(--gray-900);
  --text-soft:     var(--gray-600);
  --text-muted:    var(--gray-400);
  --primary:       var(--brand-600);
  --primary-hover: var(--brand-700);

  /* États */
  --success:   #16a34a;  --success-bg: #dcfce7;
  --warning:   #d97706;  --warning-bg: #fef3c7;
  --danger:    #dc2626;  --danger-bg:  #fee2e2;
  --info:      #0891b2;  --info-bg:    #cffafe;

  /* Statuts de prospect */
  --st-nouveau:       #64748b;
  --st-a_visiter:     #d97706;
  --st-visite:        #0891b2;
  --st-interesse:     #7c3aed;
  --st-client:        #16a34a;
  --st-pas_interesse: #dc2626;
  --st-injoignable:   #94a3b8;

  /* Rayons */
  --r-sm: 6px;  --r-md: 8px;  --r-lg: 12px;  --r-xl: 16px;

  /* Ombres */
  --sh-sm: 0 1px 2px rgba(15,23,42,.06);
  --sh-md: 0 2px 8px rgba(15,23,42,.08);
  --sh-lg: 0 8px 24px rgba(15,23,42,.12);

  /* Espacement (échelle 4 px) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px;

  --sidebar-w: 248px;
  --header-h: 60px;
}

/* ---- 2. Base ------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1,h2,h3,h4 { font-weight: 600; line-height: 1.3; color: var(--text); }
h1 { font-size: 20px; } h2 { font-size: 17px; } h3 { font-size: 15px; }

img { max-width: 100%; display: block; }

::selection { background: var(--brand-200); }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }

.tabular { font-variant-numeric: tabular-nums; }

/* ---- 3. Mise en page ---------------------------------------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: var(--gray-300);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
}
.sidebar__brand {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: 0 var(--s5);
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .2px;
}
.sidebar__brand .logo {
  width: 30px; height: 30px;
  background: var(--brand-600);
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.sidebar__nav { padding: var(--s4) var(--s3); flex: 1; overflow-y: auto; }
.sidebar__section {
  font-size: 11px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--gray-500); padding: var(--s4) var(--s3) var(--s2);
}
.nav-link {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s3); border-radius: var(--r-sm);
  color: var(--gray-300); font-weight: 500;
  text-decoration: none; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.is-active { background: var(--brand-600); color: #fff; }
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar__foot {
  padding: var(--s4); border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px; color: var(--gray-500);
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
}

.topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 var(--s6); gap: var(--s4);
  position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-size: 16px; font-weight: 600; }
.topbar__spacer { flex: 1; }
.topbar__user {
  display: flex; align-items: center; gap: var(--s3);
  font-size: 13px;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-100); color: var(--brand-700);
  display: grid; place-items: center; font-weight: 600;
}

.content { padding: var(--s6); flex: 1; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: var(--s4); margin-bottom: var(--s6);
}
.page-head p { color: var(--text-soft); font-size: 13px; margin-top: 2px; }

/* ---- 4. Burger / responsive -------------------------------------- */
.burger {
  display: none; background: none; border: none;
  cursor: pointer; padding: var(--s2);
}
.scrim {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.5); z-index: 35;
}

/* ---- 5. Cartes ---------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card__head {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s4);
}
.card__head h3 { font-size: 14px; }
.card__body { padding: var(--s5); }

/* ---- 6. Grille de KPI -------------------------------------------- */
.grid { display: grid; gap: var(--s4); }
.grid--kpi { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s5);
  box-shadow: var(--sh-sm);
}
.kpi__top { display: flex; align-items: center; justify-content: space-between; }
.kpi__label { font-size: 12.5px; color: var(--text-soft); font-weight: 500; }
.kpi__icon {
  width: 38px; height: 38px; border-radius: var(--r-md);
  display: grid; place-items: center;
  background: var(--brand-50); color: var(--brand-600);
}
.kpi__value { font-size: 28px; font-weight: 700; margin-top: var(--s3); letter-spacing: -.5px; }
.kpi__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kpi--green .kpi__icon  { background: var(--success-bg); color: var(--success); }
.kpi--amber .kpi__icon  { background: var(--warning-bg); color: var(--warning); }
.kpi--purple .kpi__icon { background: #ede9fe; color: #7c3aed; }

/* ---- 7. Boutons --------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  font-size: 13.5px; font-weight: 600; font-family: inherit;
  padding: 9px 16px; min-height: 40px;
  border-radius: var(--r-md); border: 1px solid transparent;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn--ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn--ghost:hover { background: var(--gray-50); text-decoration: none; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #b91c1c; text-decoration: none; }
.btn--sm { min-height: 32px; padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn--block { width: 100%; }

/* ---- 8. Tableaux -------------------------------------------------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data thead th {
  background: var(--surface-alt);
  text-align: left; font-weight: 600; color: var(--text-soft);
  padding: 10px var(--s4); border-bottom: 1px solid var(--border);
  white-space: nowrap; font-size: 12px;
  text-transform: uppercase; letter-spacing: .3px;
}
table.data tbody td {
  padding: 11px var(--s4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:hover { background: var(--brand-50); }
table.data tbody tr:last-child td { border-bottom: none; }
.t-actions { display: flex; gap: var(--s2); }
.t-strong { font-weight: 600; }

/* ---- 9. Badges ---------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 600;
  padding: 3px 9px; border-radius: 999px;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--nouveau       { background: #f1f5f9; color: var(--st-nouveau); }
.badge--a_visiter     { background: var(--warning-bg); color: var(--st-a_visiter); }
.badge--visite        { background: var(--info-bg); color: var(--st-visite); }
.badge--interesse     { background: #ede9fe; color: var(--st-interesse); }
.badge--client        { background: var(--success-bg); color: var(--st-client); }
.badge--pas_interesse { background: var(--danger-bg); color: var(--st-pas_interesse); }
.badge--injoignable   { background: #f1f5f9; color: var(--st-injoignable); }
.badge--role-admin      { background: var(--brand-100); color: var(--brand-700); }
.badge--role-commercial { background: var(--gray-100); color: var(--gray-600); }
.badge--ok  { background: var(--success-bg); color: var(--success); }
.badge--off { background: var(--danger-bg); color: var(--danger); }

/* ---- 10. Formulaires --------------------------------------------- */
.field { margin-bottom: var(--s4); }
.field > label {
  display: block; font-size: 13px; font-weight: 600;
  margin-bottom: 6px; color: var(--text);
}
.field .req { color: var(--danger); }
.field .hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }
.field .err  { font-size: 12px; color: var(--danger); margin-top: 5px; }

.input, .select, textarea.input {
  width: 100%; font-family: inherit; font-size: 14px;
  padding: 9px 12px; min-height: 40px;
  border: 1px solid var(--gray-300); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--brand-500);
  box-shadow: 0 0 0 3px var(--brand-100);
}
textarea.input { min-height: 84px; resize: vertical; padding-top: 9px; }
.field.has-error .input, .field.has-error .select { border-color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: var(--s3);
  align-items: center; margin-bottom: var(--s4);
}
.toolbar .input, .toolbar .select { min-height: 38px; width: auto; }
.toolbar .grow { flex: 1; min-width: 180px; }

/* ---- 11. Zone de dépôt de fichier -------------------------------- */
.dropzone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--r-lg);
  background: var(--surface-alt);
  padding: var(--s10) var(--s6);
  text-align: center; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--brand-500); background: var(--brand-50);
}
.dropzone__icon {
  width: 52px; height: 52px; margin: 0 auto var(--s3);
  background: var(--brand-100); color: var(--brand-600);
  border-radius: var(--r-lg); display: grid; place-items: center;
}
.dropzone strong { color: var(--primary); }
.dropzone__file {
  margin-top: var(--s4); font-size: 13px; font-weight: 600;
  color: var(--success);
}

/* ---- 12. Modale --------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0; background: rgba(15,23,42,.55);
  display: none; align-items: flex-start; justify-content: center;
  padding: var(--s8) var(--s4); z-index: 100; overflow-y: auto;
}
.modal-scrim.is-open { display: flex; }
.modal {
  background: var(--surface); border-radius: var(--r-xl);
  box-shadow: var(--sh-lg); width: 100%; max-width: 540px;
  animation: modal-in .18s ease-out;
}
.modal--lg { max-width: 760px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
.modal__head {
  padding: var(--s5); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal__body { padding: var(--s5); }
.modal__foot {
  padding: var(--s4) var(--s5); border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--s3);
}
.modal__close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 4px; border-radius: var(--r-sm);
}
.modal__close:hover { background: var(--gray-100); color: var(--text); }

/* ---- 13. Alertes / flash ----------------------------------------- */
.alert {
  display: flex; gap: var(--s3); align-items: flex-start;
  padding: var(--s3) var(--s4); border-radius: var(--r-md);
  font-size: 13px; margin-bottom: var(--s4);
  border: 1px solid transparent;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert--success { background: var(--success-bg); color: #15803d; border-color: #bbf7d0; }
.alert--danger  { background: var(--danger-bg);  color: #b91c1c; border-color: #fecaca; }
.alert--warning { background: var(--warning-bg); color: #b45309; border-color: #fde68a; }
.alert--info    { background: var(--info-bg);    color: #0e7490; border-color: #a5f3fc; }

/* ---- 14. Carte (Leaflet) ----------------------------------------- */
#map, .map-panel {
  height: 560px; border-radius: var(--r-lg);
  border: 1px solid var(--border); overflow: hidden;
  z-index: 1;
}
.leaflet-popup-content { font-family: inherit; font-size: 13px; }
.map-legend {
  display: flex; flex-wrap: wrap; gap: var(--s3);
  padding: var(--s3) var(--s4); font-size: 12px;
}
.map-legend span { display: flex; align-items: center; gap: 6px; }
.map-legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }

/* ---- 15. État vide & pagination ---------------------------------- */
.empty {
  text-align: center; padding: var(--s10) var(--s6); color: var(--text-soft);
}
.empty__icon {
  width: 56px; height: 56px; margin: 0 auto var(--s4);
  background: var(--gray-100); color: var(--gray-400);
  border-radius: var(--r-xl); display: grid; place-items: center;
}
.pagination {
  display: flex; gap: var(--s2); align-items: center;
  justify-content: flex-end; padding: var(--s4) 0; flex-wrap: wrap;
}
.pagination .pg-info { color: var(--text-soft); font-size: 13px; margin-right: auto; }
.pagination a, .pagination span {
  min-width: 34px; height: 34px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface); font-size: 13px; color: var(--text);
}
.pagination a:hover { background: var(--gray-50); text-decoration: none; }
.pagination .is-current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .is-disabled { opacity: .4; pointer-events: none; }

/* ---- 16. Login ---------------------------------------------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--gray-900);
  padding: var(--s4);
}
.login-card {
  background: var(--surface); width: 100%; max-width: 400px;
  border-radius: var(--r-xl); box-shadow: var(--sh-lg);
  padding: var(--s8);
}
.login-card .brand {
  display: flex; align-items: center; gap: var(--s3);
  font-weight: 700; font-size: 20px; margin-bottom: var(--s2);
}
.login-card .brand .logo {
  width: 38px; height: 38px; background: var(--brand-600);
  border-radius: var(--r-md); display: grid; place-items: center;
}
.login-card .sub { color: var(--text-soft); font-size: 13px; margin-bottom: var(--s6); }

/* ---- 17. Divers --------------------------------------------------- */
.muted { color: var(--text-muted); }
.soft  { color: var(--text-soft); }
.mt-4 { margin-top: var(--s4); } .mt-6 { margin-top: var(--s6); }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; } .gap-3 { gap: var(--s3); }
.between { justify-content: space-between; } .items-center { align-items: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.chart-box { position: relative; height: 280px; }

/* ---- 18. Responsive ---------------------------------------------- */
@media (max-width: 1024px) {
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; }
  .sidebar.is-open { transform: translateX(0); }
  .main { margin-left: 0; }
  .burger { display: inline-flex; }
  .scrim.is-open { display: block; }
  .content { padding: var(--s4); }
  .kpi__value { font-size: 24px; }
}
