/*
  FINDAR.MA — Composant Carte Immobilière
  ================================================
  Préfixe BEM : fdm__
  Bleu Findar : #0b2c8f
  Police : système uniquement
  Icônes : SVG inline (aucune lib)
  Leaflet : CSS local uniquement
  Attribution CARTO/OSM : conservée discrète
*/

.fdm {
  position: relative;
  width: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: #1a1a2e;
  background: #f4f5f7;
  -webkit-font-smoothing: antialiased;
}

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

.fdm button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.fdm a {
  text-decoration: none;
  color: inherit;
}

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

.fdm {
  --blue: #0b2c8f;
  --blue-hover: #0e3ab5;
  --blue-bg: #eaf0fc;
  --blue-ghost: rgba(11, 44, 143, 0.08);
  --white: #ffffff;
  --g50: #f8f9fb;
  --g100: #f1f2f5;
  --g200: #e4e6eb;
  --g400: #a0a4b0;
  --g600: #5c6170;
  --g800: #2a2d3a;
  --wa: #25d366;
  --wa-hover: #1da851;
  --r: 8px;
  --r-lg: 12px;
  --sh-sm: 0 1px 3px rgba(0,0,0,0.06);
  --sh-md: 0 4px 16px rgba(0,0,0,0.08);
  --sh-lg: 0 8px 30px rgba(0,0,0,0.12);
  --sh-xl: 0 16px 48px rgba(0,0,0,0.16);
  --ease: 0.2s ease;
}

/* Barre */
.fdm__bar {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 400;
  pointer-events: none;
}

.fdm__bar-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.fdm__search {
  flex: 1;
  max-width: 420px;
  position: relative;
}

.fdm__ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--g400);
  pointer-events: none;
}

.fdm__search-input {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--g200);
  border-radius: var(--r);
  font-family: inherit;
  font-size: 13px;
  color: var(--g800);
  background: var(--white);
  box-shadow: var(--sh-md);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease);
}

.fdm__search-input::placeholder { color: var(--g400); }

.fdm__search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-ghost), var(--sh-md);
}

.fdm__suggestions {
  position: absolute;
  top: 48px;
  left: 0;
  right: 0;
  background: var(--white);
  border-radius: 0 0 var(--r) var(--r);
  box-shadow: var(--sh-lg);
  border: 1px solid var(--g200);
  border-top: 1px solid var(--g100);
  display: none;
  max-height: 240px;
  overflow-y: auto;
}

.fdm__suggestions--open { display: block; animation: fdmSlide 0.15s ease-out; }

@keyframes fdmSlide {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fdm__sug {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--g800);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.1s;
}

.fdm__sug:hover { background: var(--g50); }
.fdm__sug small { color: var(--g400); font-size: 11px; margin-left: auto; }

.fdm__filters { display: flex; gap: 6px; }

.fdm__fbtn {
  height: 40px;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--g200);
  border-radius: var(--r);
  background: var(--white);
  box-shadow: var(--sh-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--g600);
  transition: all var(--ease);
  white-space: nowrap;
}

.fdm__fbtn:hover { border-color: var(--blue); color: var(--blue); }
.fdm__fbtn--active { border-color: var(--blue); background: var(--blue-bg); color: var(--blue); }
.fdm__fbtn svg { flex-shrink: 0; }

.fdm__count {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--g600);
  background: var(--white);
  padding: 6px 14px;
  border-radius: 50px;
  box-shadow: var(--sh-sm);
  white-space: nowrap;
}

/* Dropdowns */
.fdm__dropdown {
  position: absolute;
  z-index: 450;
  background: var(--white);
  border-radius: var(--r);
  box-shadow: var(--sh-lg);
  border: 1px solid var(--g200);
  padding: 6px;
  min-width: 200px;
  display: none;
  max-height: 260px;
  overflow-y: auto;
}

.fdm__dropdown--open { display: block; animation: fdmSlide 0.15s ease-out; }

.fdm__opt {
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--g800);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.1s;
}

.fdm__opt:hover { background: var(--g50); }
.fdm__opt--active { background: var(--blue-bg); color: var(--blue); font-weight: 600; }

/* Carte */
.fdm__map {
  width: 100%;
  height: 100vh;
  background: var(--g100);
  position: relative;
}

/* Contrôles Leaflet natifs : zoom masqué (on a les nôtres),
   attribution conservée discrète comme requis par la licence OSM/CARTO */
.fdm__map .leaflet-control-zoom {
  display: none !important;
}

.fdm__map .leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(255, 255, 255, 0.55) !important;
  padding: 1px 5px !important;
  border-radius: 3px !important;
  color: #888 !important;
}

/* Marqueurs */
.fdm__marker {
  position: relative;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fdm__marker-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--blue);
  border: 2.5px solid var(--white);
  box-shadow: 0 2px 8px rgba(11, 44, 143, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  position: relative;
  z-index: 2;
}

.fdm__marker:hover .fdm__marker-dot,
.fdm__marker--active .fdm__marker-dot {
  transform: scale(1.2);
  box-shadow: 0 4px 18px rgba(11, 44, 143, 0.5);
  background: var(--blue-hover);
  z-index: 3;
}

.fdm__marker-dot span {
  font-size: 8px;
  font-weight: 800;
  color: var(--white);
  text-align: center;
  line-height: 1.15;
  pointer-events: none;
}

.fdm__marker--premium .fdm__marker-dot {
  border-color: #e8b930;
  box-shadow: 0 2px 8px rgba(11, 44, 143, 0.35), 0 0 0 2px rgba(232, 185, 48, 0.25);
}

/* Mini-card */
.fdm__card {
  position: absolute;
  top: 72px;
  right: 12px;
  width: 340px;
  z-index: 500;
  background: var(--white);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xl);
  overflow: hidden;
  opacity: 0;
  transform: translateX(360px);
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}

.fdm__card--open { opacity: 1; transform: translateX(0); pointer-events: auto; }

.fdm__card-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background var(--ease);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.fdm__card-close:hover { background: rgba(0, 0, 0, 0.55); }

.fdm__card-img {
  width: 100%;
  height: 180px;
  background: var(--g100);
  background-size: cover;
  background-position: center;
  position: relative;
}

.fdm__card-img::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.25), transparent);
}

.fdm__card-body { padding: 14px 16px 16px; }

.fdm__card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.fdm__card-price { font-size: 20px; font-weight: 800; color: var(--blue); line-height: 1.2; }

.fdm__card-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 50px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.fdm__card-badge--verified { background: #e8f5e9; color: #2e7d32; }
.fdm__card-badge--premium { background: #fff8e1; color: #e65100; }

.fdm__card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--g800);
  line-height: 1.35;
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fdm__card-loc { font-size: 12px; color: var(--g400); margin-bottom: 10px; }

.fdm__card-specs {
  display: flex;
  border: 1px solid var(--g200);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 10px;
}

.fdm__card-spec {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  font-size: 10.5px;
  color: var(--g600);
  border-right: 1px solid var(--g200);
  line-height: 1.3;
}

.fdm__card-spec:last-child { border-right: none; }
.fdm__card-spec strong { display: block; font-size: 13px; font-weight: 700; color: var(--g800); }
.fdm__card-meta { font-size: 11px; color: var(--g400); margin-bottom: 12px; }

.fdm__card-actions { display: flex; gap: 8px; }

.fdm__card-btn {
  flex: 1;
  height: 38px;
  border-radius: var(--r);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--ease);
}

.fdm__card-btn--wa { background: var(--wa); color: var(--white); }
.fdm__card-btn--wa:hover { background: var(--wa-hover); }
.fdm__card-btn--link { background: var(--white); border: 1.5px solid var(--g200); color: var(--g800); }
.fdm__card-btn--link:hover { border-color: var(--blue); color: var(--blue); }

/* Contrôles */
.fdm__ctrls {
  position: absolute;
  bottom: 24px;
  right: 12px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  border: 1px solid var(--g200);
  overflow: hidden;
}

.fdm__cbtn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--g600);
  transition: all var(--ease);
}

.fdm__cbtn:hover { background: var(--g50); color: var(--blue); }
.fdm__cdiv { height: 1px; background: var(--g200); margin: 0 6px; }

/* Toggle update */
.fdm__update {
  position: absolute;
  bottom: 24px;
  left: 12px;
  z-index: 400;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  padding: 8px 12px;
  border-radius: var(--r);
  box-shadow: var(--sh-sm);
  border: 1px solid var(--g200);
  cursor: pointer;
  user-select: none;
}

.fdm__update input { display: none; }

.fdm__update-track {
  width: 32px;
  height: 18px;
  border-radius: 9px;
  background: var(--g200);
  position: relative;
  transition: background var(--ease);
  flex-shrink: 0;
}

.fdm__update input:checked + .fdm__update-track { background: var(--blue); }

.fdm__update-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  transition: transform var(--ease);
}

.fdm__update input:checked + .fdm__update-track .fdm__update-thumb { transform: translateX(14px); }
.fdm__update-label { font-size: 11px; font-weight: 500; color: var(--g600); white-space: nowrap; }

/* Mobile toggle */
.fdm__mob-toggle {
  display: none;
  position: absolute;
  bottom: 24px;
  left: 12px;
  right: 12px;
  z-index: 400;
  background: var(--white);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  border: 1px solid var(--g200);
  overflow: hidden;
}

.fdm__mob-btn {
  flex: 1;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--g400);
  transition: all var(--ease);
}

.fdm__mob-btn--active { color: var(--blue); background: var(--blue-bg); }

/* Liste mobile */
.fdm__list {
  display: none;
  background: var(--g50);
  padding: 8px 12px 24px;
  max-height: 45vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.fdm__list--open { display: block; }

.fdm__list-card {
  display: flex;
  gap: 12px;
  background: var(--white);
  border-radius: var(--r);
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid var(--g200);
  cursor: pointer;
  transition: border-color var(--ease);
}

.fdm__list-card:hover { border-color: var(--blue); }

.fdm__list-card-img {
  width: 90px;
  height: 72px;
  border-radius: 6px;
  background: var(--g100);
  background-size: cover;
  background-position: center;
  flex-shrink: 0;
}

.fdm__list-card-body { flex: 1; min-width: 0; }
.fdm__list-card-price { font-size: 15px; font-weight: 800; color: var(--blue); }

.fdm__list-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--g800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.fdm__list-card-loc { font-size: 11px; color: var(--g400); }

.fdm__list-card-specs {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--g600);
}

/* Bottom sheet */
.fdm__sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.fdm__sheet-overlay--open { opacity: 1; pointer-events: auto; }

.fdm__sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 910;
  background: var(--white);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  max-height: 75vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.fdm__sheet--open { transform: translateY(0); }

.fdm__sheet-handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--g200);
  margin: 10px auto 0;
}

.fdm__sheet-body { padding: 16px; }
.fdm__sheet-body .fdm__card-img { height: 200px; border-radius: var(--r); margin-bottom: 14px; }
.fdm__sheet-body .fdm__card-price { font-size: 22px; }
.fdm__sheet-body .fdm__card-title { font-size: 14px; }
.fdm__sheet-body .fdm__card-actions { margin-top: 14px; }

/* Fallback statique */
.fdm__map--static {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  padding: 72px 12px 12px;
  height: auto;
  min-height: 400px;
  align-content: start;
}

.fdm__static-card {
  background: var(--white);
  border-radius: var(--r);
  border: 1px solid var(--g200);
  overflow: hidden;
  transition: border-color var(--ease), box-shadow var(--ease);
  cursor: pointer;
}

.fdm__static-card:hover { border-color: var(--blue); box-shadow: var(--sh-md); }

.fdm__static-card-img {
  width: 100%;
  height: 160px;
  background: var(--g100);
  background-size: cover;
  background-position: center;
}

.fdm__static-card-body { padding: 12px; }
.fdm__static-card-price { font-size: 17px; font-weight: 800; color: var(--blue); margin-bottom: 4px; }

.fdm__static-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--g800);
  margin-bottom: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.fdm__static-card-loc { font-size: 11px; color: var(--g400); margin-bottom: 8px; }

.fdm__static-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fdm__static-card-specs { display: flex; gap: 10px; font-size: 11px; color: var(--g600); }
.fdm__static-card-link { font-size: 12px; font-weight: 600; color: var(--blue); }

/* Responsive */
@media (max-width: 768px) {
  .fdm__card { display: none; }
  .fdm__mob-toggle { display: flex; }
  .fdm__update { display: none; }
  .fdm__filters .fdm__fbtn span { display: none; }
  .fdm__filters .fdm__fbtn { padding: 0 10px; }
  .fdm__count { display: none; }
  .fdm__map { height: 55vh; }
  .fdm__map--static { height: auto; padding-top: 64px; }

  .fdm--list-view .fdm__map { height: 0; overflow: hidden; }

  .fdm--list-view .fdm__list {
    display: block;
    max-height: none;
    padding-top: 64px;
  }

  .fdm--list-view .fdm__mob-toggle,
  .fdm--list-view .fdm__ctrls { display: none; }
}

@media (min-width: 769px) {
  .fdm__mob-toggle { display: none !important; }
  .fdm__list { display: none !important; }
  .fdm__sheet, .fdm__sheet-overlay { display: none !important; }
}


/* V4.5.10.82 — FIX: afficher les biens du site sur la carte desktop */
@media (min-width: 769px) {
  .fdm__marker-dot {
    width: auto;
    min-width: 56px;
    max-width: 96px;
    height: 34px;
    padding: 0 10px;
    border-radius: 999px;
  }

  .fdm__marker-dot span {
    display: block;
    max-width: 76px;
    overflow: hidden;
    font-size: 10px;
    line-height: 1.05;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .fdm__list {
    display: block !important;
    position: absolute;
    top: 72px;
    right: 12px;
    bottom: 16px;
    z-index: 430;
    width: min(392px, calc(100% - 32px));
    max-height: none;
    padding: 58px 12px 14px;
    overflow-y: auto;
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 18px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 20px 56px rgba(15, 23, 42, .18);
    -webkit-overflow-scrolling: touch;
  }

  .fdm__list::before {
    content: "Biens affichés";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 46px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid #eef2f7;
    border-radius: 18px 18px 0 0;
    background: #fff;
    color: #0f172a;
    font-size: 15px;
    font-weight: 950;
  }

  .fdm__list-card {
    min-height: 96px;
    border-radius: 14px;
    box-shadow: 0 1px 0 rgba(15,23,42,.02);
  }

  .fdm__list-card-img {
    width: 112px;
    height: 86px;
  }

  .fdm__list-card-price {
    font-size: 16px;
    line-height: 1.2;
  }

  .fdm__list-card-title {
    margin-top: 3px;
    font-size: 13px;
  }

  .fdm__list-card-loc,
  .fdm__list-card-specs {
    font-size: 11.5px;
  }

  .fdm__card {
    right: 420px;
  }

  .fdm__ctrls {
    right: 420px;
  }
}

@media (min-width: 769px) and (max-width: 1180px) {
  .fdm__list {
    width: 330px;
  }
  .fdm__card {
    right: 350px;
    width: 318px;
  }
  .fdm__ctrls {
    right: 350px;
  }
}

/* V4.5.10.84 — real marker/card click hardening */
.fdm__marker,
.fdm__marker-dot,
.fdm__marker-dot span {
  pointer-events: auto;
}
.fdm__marker { touch-action: manipulation; }
.fdm__card--open { visibility: visible; }
.fdm__card-btn { pointer-events: auto; }
