:root {
    --map-navy: #092f49;
    --map-deep: #061f32;
    --map-sea: #167f9f;
    --map-mint: #15918c;
    --map-green: #4f8e55;
    --map-orange: #df8542;
    --map-sand: #e8b979;
    --map-text: #183e55;
    --map-muted: #71838e;
    --map-soft: #f3f8f9;
    --map-line: rgba(9, 47, 73, 0.11);
    --map-shadow:
        0 22px 65px rgba(9, 47, 73, 0.13);
}

.map-v3-page,
.map-v3-page * {
    box-sizing: border-box;
}

.map-v3-page {
    min-height: calc(100vh - 82px);
    padding: 28px 0 45px;
    background:
        radial-gradient(
            circle at 90% 4%,
            rgba(105, 199, 213, 0.12),
            transparent 23%
        ),
        #f4f8f9;
}

.map-v3-page > .container {
    width: min(100% - 36px, 1540px);
    max-width: none;
}

/* =========================================================
   EN-TÊTE
   ========================================================= */

.map-v3-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 35px;
    margin-bottom: 20px;
}

.map-v3-heading {
    min-width: 0;
}

.map-v3-heading > span {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    color: var(--map-mint);
    font-size: 0.67rem;
    font-weight: 850;
    letter-spacing: 0.11em;
    text-transform: uppercase;
}

.map-v3-heading > span::before {
    width: 34px;
    height: 1px;
    background: var(--map-sand);
    content: "";
}

.map-v3-heading h1 {
    margin: 0;
    color: var(--map-navy);
    font-size: clamp(2.8rem, 6vw, 5.8rem);
    line-height: 0.94;
    letter-spacing: -0.06em;
}

.map-v3-heading p {
    max-width: 720px;
    margin: 13px 0 0;
    color: var(--map-muted);
    font-size: 0.82rem;
    line-height: 1.7;
}

.map-v3-booking-mode {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border: 1px solid rgba(79, 142, 85, 0.2);
    border-radius: 999px;
    background: #edf8f0;
    color: #397444;
    font-size: 0.64rem;
    font-weight: 850;
}

/* =========================================================
   RECHERCHE
   ========================================================= */

.map-v3-search {
    display: grid;
    grid-template-columns:
        minmax(180px, 1.15fr)
        minmax(145px, 0.82fr)
        minmax(145px, 0.82fr)
        minmax(105px, 0.55fr)
        auto;
    gap: 8px;
    margin-bottom: 18px;
    padding: 9px;
    border: 1px solid var(--map-line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 15px 42px rgba(9, 47, 73, 0.08);
    backdrop-filter: blur(14px);
}

.map-v3-search label {
    display: flex;
    min-width: 0;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 8px 12px;
}

.map-v3-search label > span {
    color: var(--map-navy);
    font-size: 0.59rem;
    font-weight: 850;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.map-v3-search input,
.map-v3-search select {
    width: 100%;
    min-width: 0;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #526f7e;
    font: inherit;
    font-size: 0.72rem;
    outline: none;
}

.map-v3-search button {
    display: flex;
    min-width: 180px;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 10px 12px 10px 18px;
    border: 0;
    border-radius: 14px;
    background:
        linear-gradient(
            135deg,
            var(--map-green),
            #356e43
        );
    box-shadow: 0 12px 28px rgba(53, 110, 67, 0.2);
    color: #ffffff;
    font: inherit;
    font-size: 0.7rem;
    font-weight: 850;
    cursor: pointer;
}

.map-v3-search button:hover {
    box-shadow: 0 16px 34px rgba(53, 110, 67, 0.29);
    transform: translateY(-1px);
}

/* =========================================================
   ESPACE PRINCIPAL
   ========================================================= */

.map-v3-workspace {
    display: grid;
    width: 100%;
    min-width: 0;
    grid-template-columns:
        minmax(360px, 42%)
        minmax(0, 58%);
    gap: 16px;
    align-items: stretch;
}

.map-v3-list,
.map-v3-map-panel {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--map-line);
    border-radius: 23px;
    background: #ffffff;
    box-shadow: var(--map-shadow);
}

.map-v3-list {
    display: flex;
    height: calc(100vh - 265px);
    min-height: 610px;
    flex-direction: column;
}

.map-v3-map-panel {
    position: relative;
    height: calc(100vh - 265px);
    min-height: 610px;
}

/* =========================================================
   PANNEAU LISTE
   ========================================================= */

.map-v3-list-head {
    display: flex;
    flex: 0 0 auto;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    padding: 22px 22px 17px;
    border-bottom: 1px solid var(--map-line);
    background:
        linear-gradient(
            145deg,
            #f7fbfc,
            #ffffff
        );
}

.map-v3-list-head h2 {
    margin: 0;
    color: var(--map-navy);
    font-size: 1.25rem;
    letter-spacing: -0.035em;
}

.map-v3-list-head p,
.map-v3-list-head span {
    margin: 5px 0 0;
    color: var(--map-muted);
    font-size: 0.64rem;
}

.map-v3-cards {
    display: grid;
    min-height: 0;
    flex: 1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px;
    scrollbar-width: thin;
    scrollbar-color:
        rgba(9, 47, 73, 0.22)
        transparent;
}

.map-v3-cards::-webkit-scrollbar {
    width: 7px;
}

.map-v3-cards::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(9, 47, 73, 0.2);
}

.map-v3-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid var(--map-line);
    border-radius: 17px;
    background: #ffffff;
    box-shadow: 0 8px 25px rgba(9, 47, 73, 0.06);
    transition:
        border-color 180ms ease,
        box-shadow 180ms ease,
        transform 180ms ease;
}

.map-v3-card:hover,
.map-v3-card.is-active {
    border-color: rgba(22, 127, 159, 0.3);
    box-shadow: 0 18px 38px rgba(9, 47, 73, 0.13);
    transform: translateY(-3px);
}

.map-v3-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
}

.map-v3-card-media {
    position: relative;
    display: block;
    height: 155px;
    overflow: hidden;
    background: #e7eff1;
}

.map-v3-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 420ms ease;
}

.map-v3-card:hover .map-v3-card-media img {
    transform: scale(1.04);
}

.map-v3-card-media > span {
    position: absolute;
    top: 10px;
    left: 10px;
    display: inline-flex;
    min-height: 27px;
    align-items: center;
    padding: 5px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.93);
    color: var(--map-navy);
    font-size: 0.56rem;
    font-weight: 850;
    backdrop-filter: blur(8px);
}

.map-v3-card-body {
    min-width: 0;
    padding: 13px;
}

.map-v3-card-place {
    display: flex;
    min-width: 0;
    align-items: center;
    justify-content: space-between;
    gap: 9px;
    color: var(--map-sea);
    font-size: 0.61rem;
    font-weight: 850;
}

.map-v3-card-place span,
.map-v3-card-place small {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-v3-card-place small {
    color: var(--map-muted);
    font-weight: 650;
}

.map-v3-card-body h3 {
    margin: 7px 0 9px;
    overflow: hidden;
    color: var(--map-navy);
    font-size: 0.89rem;
    line-height: 1.32;
    text-overflow: ellipsis;
}

.map-v3-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 5px 10px;
    color: var(--map-muted);
    font-size: 0.58rem;
}

.map-v3-card-bottom {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    padding-top: 11px;
    border-top: 1px solid var(--map-line);
}

.map-v3-card-price {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.map-v3-card-price small {
    color: var(--map-muted);
    font-size: 0.53rem;
}

.map-v3-card-price strong {
    color: var(--map-navy);
    font-size: 0.9rem;
}

.map-v3-card-price span {
    color: var(--map-muted);
    font-size: 0.53rem;
}

.map-v3-card-bottom > span,
.map-v3-card-bottom > i {
    display: grid;
    width: 29px;
    height: 29px;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 9px;
    background: #edf7f8;
    color: var(--map-sea);
    font-size: 0.72rem;
    font-style: normal;
}

/* =========================================================
   CARTE
   ========================================================= */

#campimmoMapV3 {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 610px;
    background: #dfeaec;
}

.map-v3-map-note {
    position: absolute;
    z-index: 8;
    top: 14px;
    left: 50%;
    max-width: calc(100% - 28px);
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.44);
    border-radius: 999px;
    background: rgba(6, 31, 50, 0.78);
    box-shadow: 0 12px 28px rgba(6, 31, 50, 0.18);
    color: #ffffff;
    font-size: 0.59rem;
    font-weight: 750;
    text-align: center;
    transform: translateX(-50%);
    backdrop-filter: blur(12px);
}

/* Marqueurs MapLibre */
.map-v3-marker,
.campimmo-map-marker {
    display: grid;
    min-width: 54px;
    min-height: 36px;
    place-items: center;
    padding: 7px 10px;
    border: 3px solid #ffffff;
    border-radius: 999px;
    background: var(--map-navy);
    box-shadow: 0 8px 22px rgba(6, 31, 50, 0.27);
    color: #ffffff;
    font-family: Manrope, sans-serif;
    font-size: 0.65rem;
    font-weight: 850;
    cursor: pointer;
    transition:
        transform 160ms ease,
        background 160ms ease,
        box-shadow 160ms ease;
}

.map-v3-marker:hover,
.map-v3-marker.is-active,
.campimmo-map-marker:hover,
.campimmo-map-marker.is-active {
    z-index: 20;
    background: var(--map-orange);
    box-shadow: 0 12px 28px rgba(223, 133, 66, 0.34);
    transform: scale(1.08);
}

/* Popups MapLibre */
.maplibregl-popup {
    max-width: 275px !important;
}

.maplibregl-popup-content {
    padding: 0 !important;
    overflow: hidden;
    border-radius: 16px !important;
    box-shadow: 0 20px 48px rgba(6, 31, 50, 0.23) !important;
}

.maplibregl-popup-close-button {
    z-index: 4;
    top: 7px !important;
    right: 7px !important;
    width: 28px;
    height: 28px;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.9) !important;
    color: var(--map-navy);
    font-size: 18px;
}

.maplibregl-ctrl-group {
    overflow: hidden;
    border-radius: 12px !important;
    box-shadow: 0 8px 24px rgba(6, 31, 50, 0.15) !important;
}

.maplibregl-ctrl-attrib {
    font-size: 9px;
}

/* =========================================================
   ÉTATS VIDES ET ERREURS
   ========================================================= */

.map-v3-empty {
    display: grid;
    min-height: 270px;
    place-content: center;
    padding: 35px;
    color: var(--map-muted);
    font-size: 0.72rem;
    text-align: center;
}

.map-v3-error {
    margin-bottom: 18px;
    border-radius: 14px;
}

.map-v3-destination {
    color: var(--map-sea);
    font-weight: 850;
}

/* =========================================================
   BASCULE MOBILE
   ========================================================= */

.map-v3-mobile-switch {
    display: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin-bottom: 12px;
    padding: 6px;
    border: 1px solid var(--map-line);
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 10px 28px rgba(9, 47, 73, 0.07);
}

.map-v3-mobile-switch button {
    min-height: 40px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--map-muted);
    font: inherit;
    font-size: 0.67rem;
    font-weight: 850;
    cursor: pointer;
}

.map-v3-mobile-switch button.is-active {
    background: var(--map-navy);
    color: #ffffff;
}

/* =========================================================
   ÉCRANS INTERMÉDIAIRES
   ========================================================= */

@media (max-width: 1350px) {
    .map-v3-workspace {
        grid-template-columns:
            minmax(330px, 38%)
            minmax(0, 62%);
    }

    .map-v3-cards {
        grid-template-columns: 1fr;
    }

    .map-v3-card {
        display: grid;
        grid-template-columns: 145px minmax(0, 1fr);
    }

    .map-v3-card-media {
        height: 100%;
        min-height: 155px;
    }
}

@media (max-width: 1050px) {
    .map-v3-search {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .map-v3-search button {
        min-height: 52px;
        grid-column: span 2;
    }

    .map-v3-workspace {
        grid-template-columns:
            minmax(310px, 42%)
            minmax(0, 58%);
    }
}

/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 850px) {
    .map-v3-page {
        min-height: 0;
        padding-top: 20px;
    }

    .map-v3-page > .container {
        width: min(100% - 22px, 1540px);
    }

    .map-v3-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 15px;
    }

    .map-v3-booking-mode {
        align-self: flex-start;
    }

    .map-v3-mobile-switch {
        display: grid;
    }

    .map-v3-workspace {
        display: block;
    }

    .map-v3-list,
    .map-v3-map-panel {
        width: 100%;
        height: calc(100vh - 315px);
        min-height: 520px;
    }

    .map-v3-map-panel {
        display: none;
    }

    .map-v3-page.is-map-view .map-v3-list,
    body.is-map-view .map-v3-list {
        display: none;
    }

    .map-v3-page.is-map-view .map-v3-map-panel,
    body.is-map-view .map-v3-map-panel {
        display: block;
    }

    #campimmoMapV3 {
        min-height: 520px;
    }

    .map-v3-cards {
        grid-template-columns: 1fr;
    }

    .map-v3-card {
        grid-template-columns: 145px minmax(0, 1fr);
    }
}

@media (max-width: 580px) {
    .map-v3-heading h1 {
        font-size: clamp(2.8rem, 14vw, 4.3rem);
    }

    .map-v3-search {
        grid-template-columns: 1fr;
    }

    .map-v3-search button {
        grid-column: auto;
    }

    .map-v3-list,
    .map-v3-map-panel {
        height: calc(100vh - 340px);
        min-height: 500px;
        border-radius: 18px;
    }

    #campimmoMapV3 {
        min-height: 500px;
    }

    .map-v3-list-head {
        padding: 18px 16px 14px;
    }

    .map-v3-cards {
        padding: 10px;
    }

    .map-v3-card {
        grid-template-columns: 118px minmax(0, 1fr);
    }

    .map-v3-card-media {
        min-height: 145px;
    }

    .map-v3-card-body {
        padding: 11px;
    }

    .map-v3-card-meta {
        display: none;
    }
}

@media (max-width: 410px) {
    .map-v3-card {
        display: block;
    }

    .map-v3-card-media {
        height: 180px;
        min-height: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .map-v3-card,
    .map-v3-card-media img,
    .map-v3-search button,
    .map-v3-marker,
    .campimmo-map-marker {
        transition: none;
    }
}
