/* =====================================================================
 * LOKALIZE'M IMMOBILIER : styles (préfixe imo-, comme mkp- pour le Marketplace)
 * Utilise les variables du thème de l'app (--primary, --side, --border, --text)
 * avec des valeurs de secours.
 * ===================================================================== */

#immobilier-section {
    --imo-bleu: #00209F;
    --imo-rouge: #CE1126;
    --imo-vert: #25D366;
}

/* ---------- Barre de navigation du module ---------- */
.imo-nav {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    padding: 12px 15px;
    background: var(--side, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 12px;
    margin-bottom: 15px;
}
.imo-nav h3 { font-size: 1.2rem; color: var(--imo-bleu); white-space: nowrap; }

.imo-search {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid var(--border, #ddd);
    border-radius: 8px;
    background: var(--bg, #f8f9fa);
}
.imo-search input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text, #222);
}
.imo-nav-actions { display: flex; gap: 8px; }

@media (max-width: 576px) {
    .imo-nav-txt { display: none; }
}

/* ---------- Boutons ---------- */
.imo-btn-primary,
.imo-btn-secondary,
.imo-btn-danger,
.imo-btn-whatsapp {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: opacity .15s;
}
.imo-btn-primary   { background: var(--imo-bleu); color: #fff; }
.imo-btn-secondary { background: transparent; color: var(--imo-bleu); border: 1px solid var(--imo-bleu); }
.imo-btn-danger    { background: var(--imo-rouge); color: #fff; }
.imo-btn-whatsapp  { background: var(--imo-vert); color: #fff; }
.imo-btn-primary:hover, .imo-btn-secondary:hover,
.imo-btn-danger:hover, .imo-btn-whatsapp:hover { opacity: .85; color: inherit; }
.imo-btn-primary:hover, .imo-btn-danger:hover, .imo-btn-whatsapp:hover { color: #fff; }
.imo-auto { width: auto; }

/* ---------- Conteneur et filtres ---------- */
.imo-container { padding: 0 5px 30px; color: var(--text, #222); }

.imo-filtres {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 10px;
    align-items: center;
    padding: 12px;
    background: var(--side, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 12px;
}
.imo-devise { max-width: 90px; }

/* ---------- Grille de cartes ---------- */
.imo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
}
.imo-card {
    background: var(--side, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s;
}
.imo-card:hover { transform: translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,.15); }
.imo-card-img { width: 100%; height: 160px; object-fit: cover; display: block; background: #e9ecef; }
.imo-card-body { padding: 12px; }
.imo-price { font-weight: 700; color: var(--imo-bleu); font-size: 1.05rem; }
.imo-lieu { margin-top: 6px; font-size: 13px; color: var(--text, #222); opacity: .85; }

/* ---------- Carte Leaflet ---------- */
.imo-map       { height: 62vh; min-height: 380px; border-radius: 12px; border: 1px solid var(--border, #ddd); }
.imo-pick-map  { height: 340px; border-radius: 10px; border: 1px solid var(--border, #ddd); }
.imo-mini-map  { height: 200px; border-radius: 10px; border: 1px solid var(--border, #ddd); margin-top: 12px; }

.imo-pin {
    position: absolute;
    left: 0; top: 0;
    transform: translate(-50%, -100%);
    background: var(--imo-bleu);
    color: #fff;
    font: bold 12px Arial, sans-serif;
    padding: 4px 8px;
    border-radius: 12px;
    white-space: nowrap;
    border: 2px solid #fff;
    box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
.imo-pin::after {
    content: "";
    position: absolute;
    left: 50%; bottom: -8px;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--imo-bleu);
}

.imo-popup { width: 200px; }
.imo-popup img { width: 100%; height: 110px; object-fit: cover; border-radius: 6px; }

/* ---------- Fiche détaillée ---------- */
.imo-detail-layout {
    display: grid;
    grid-template-columns: 1.2fr 1fr 280px;
    gap: 24px;
    align-items: start;
}
.imo-gallery { max-width: 100%; overflow: hidden; }
.imo-main-img { width: 100%; max-height: 420px; object-fit: cover; border-radius: 12px; background: #e9ecef; }
.imo-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; }
.imo-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; cursor: pointer; border: 2px solid transparent; }
.imo-thumb:hover { border-color: var(--imo-bleu); }

.imo-contact {
    background: var(--side, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 12px;
    padding: 18px;
    position: sticky;
    top: 10px;
}
.imo-alerte-arnaque {
    margin-top: 14px;
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 8px;
    background: rgba(255, 193, 7, .15);
    border: 1px solid rgba(255, 193, 7, .5);
}

@media (max-width: 992px) {
    .imo-detail-layout { grid-template-columns: 1fr; }
    .imo-contact { position: static; }
}

/* ---------- Formulaire de publication ---------- */
.imo-form-wrap { max-width: 760px; margin: 0 auto; }
.imo-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.imo-preview { position: relative; width: 80px; height: 80px; }
.imo-preview img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.imo-preview button {
    position: absolute; top: -6px; right: -6px;
    width: 22px; height: 22px;
    border: none; border-radius: 50%;
    background: var(--imo-rouge); color: #fff;
    font-size: 14px; line-height: 1; cursor: pointer;
}

/* ---------- Mes annonces ---------- */
.imo-ligne {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--side, #fff);
    border: 1px solid var(--border, #ddd);
    border-radius: 12px;
}
.imo-ligne-img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: #e9ecef; }
.imo-ligne-actions { display: flex; gap: 6px; flex-wrap: wrap; }


/* =====================================================================
 * CARTE AVANCÉE : recherche de zones, boutons, regroupement
 * ===================================================================== */
.imo-map-wrap { position: relative; }
.imo-map-wrap [hidden] { display: none !important; }

/* Barre de recherche flottante (à droite des boutons +/- de Leaflet) */
.imo-map-search {
    position: absolute;
    top: 10px; left: 54px; right: 56px;
    max-width: 460px;
    z-index: 1000;
}
.imo-map-searchbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px 4px 12px;
    background: var(--side, #fff);
    color: var(--text, #222);
    border: 1px solid var(--border, #ccc);
    border-radius: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.imo-map-searchbar input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: inherit;
    font-size: 14px;
    padding: 6px 0;
}
.imo-map-searchbar button {
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
}
.imo-map-searchbar .imo-map-go { background: var(--imo-bleu); color: #fff; font-size: 13px; }

/* Liste de suggestions */
.imo-sugg-list {
    margin-top: 6px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--side, #fff);
    color: var(--text, #222);
    border: 1px solid var(--border, #ccc);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.imo-sugg {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border, #eee);
}
.imo-sugg:last-child { border-bottom: none; }
.imo-sugg:hover { background: rgba(0, 32, 159, .08); }
.imo-sugg i { margin-top: 3px; color: var(--imo-bleu); width: 16px; text-align: center; }
.imo-sugg b { display: block; font-size: 14px; }
.imo-sugg small { display: block; font-size: 12px; opacity: .75; }
.imo-sugg-etat { padding: 9px 12px; font-size: 13px; opacity: .8; }

/* Boutons à droite (ma position, tout voir) */
.imo-map-tools {
    position: absolute;
    right: 10px; bottom: 34px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.imo-map-tools button {
    width: 38px; height: 38px;
    border: none;
    border-radius: 8px;
    background: var(--side, #fff);
    color: var(--imo-bleu);
    font-size: 17px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.imo-map-tools button:hover { background: var(--imo-bleu); color: #fff; }

/* Bouton "Chercher dans cette zone" */
.imo-zone-bar {
    position: absolute;
    top: 62px; left: 50%;
    transform: translateX(-50%);
    z-index: 900;
}
.imo-zone-bar .imo-btn-primary { box-shadow: 0 2px 8px rgba(0,0,0,.4); border-radius: 20px; }

/* Case "actualiser en déplaçant la carte" + compteur */
.imo-auto-toggle {
    position: absolute;
    left: 10px; bottom: 34px;
    z-index: 900;
    margin: 0;
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 14px;
    background: var(--side, #fff);
    color: var(--text, #222);
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
    cursor: pointer;
}
.imo-map-count {
    position: absolute;
    left: 50%; bottom: 34px;
    transform: translateX(-50%);
    z-index: 900;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 14px;
    background: var(--imo-bleu);
    color: #fff;
    white-space: nowrap;
    pointer-events: none;
}
.imo-map-count:empty { display: none; }

/* Sur petit écran : on libère de la place */
@media (max-width: 576px) {
    .imo-map-search { right: 54px; }
    .imo-auto-toggle { bottom: 80px; }
    .imo-map-count { bottom: 80px; }
}

/* Regroupements (clusters) aux couleurs de Lokalize'm */
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background-color: rgba(0, 32, 159, .25); }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div {
    background-color: rgba(0, 32, 159, .85);
    color: #fff;
    font-weight: bold;
}
