/* ─── Map Page ─────────────────────────────────────────────────────────────── */

/* Full-height split layout — override main padding */
body:has(.map-page) main {
    padding: 0;
}

.map-page {
    display: flex;
    height: calc(100vh - 70px);
    /* 70px = hauteur header */
    overflow: hidden;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────────── */

.map-sidebar {
    width: 380px;
    min-width: 380px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    z-index: 10;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1.25rem 1.25rem 0;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-title-row {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.sidebar-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #1a1a2e;
    margin: 0;
}

.sidebar-count {
    font-size: 0.8rem;
    color: #8b6914;
    font-weight: 600;
}

/* Filtres */
.sidebar-filters {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-bottom: 1rem;
}

.map-select {
    width: 100%;
    padding: 0.55rem 0.85rem;
    background: #f8f9fa;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #1a1a2e;
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23666' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.map-select:focus {
    outline: none;
    border-color: #8b6914;
    box-shadow: 0 0 0 2px rgba(139, 105, 20, 0.1);
}

.map-select option {
    background: #fff;
    color: #1a1a2e;
}

/* ─── Property list ────────────────────────────────────────────────────────── */

.sidebar-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.sidebar-list::-webkit-scrollbar {
    width: 5px;
}

.sidebar-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* Loading spinner */
.map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1rem;
    color: #9ca3af;
    font-size: 0.9rem;
}

.spinner {
    width: 22px;
    height: 22px;
    border: 2px solid #e5e7eb;
    border-top-color: #8b6914;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty state */
.map-empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #9ca3af;
}

.map-empty i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
    color: #d1d5db;
}

/* Property card in sidebar */
.map-card {
    display: flex;
    gap: 0.85rem;
    padding: 1rem 1.2rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    position: relative;
}

.map-card:hover,
.map-card.is-active {
    background: #f8f9fa;
}

.map-card.is-active {
    border-left: 3px solid #8b6914;
}

.map-card-thumb {
    width: 72px;
    min-width: 72px;
    height: 58px;
    border-radius: 5px;
    overflow: hidden;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.map-card-thumb i {
    font-size: 1.2rem;
    color: #d1d5db;
}

.map-card-info {
    flex: 1;
    min-width: 0;
}

.map-card-price {
    font-weight: 700;
    font-size: 0.95rem;
    color: #8b6914;
    margin-bottom: 0.1rem;
    font-family: 'Montserrat', sans-serif;
}

.map-card-price.sold-price {
    color: #9ca3af;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.map-card-address {
    font-size: 0.8rem;
    color: #1a1a2e;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.1rem;
}

.map-card-city {
    font-size: 0.75rem;
    color: #6b7280;
    margin-bottom: 0.3rem;
}

.map-card-meta {
    display: flex;
    gap: 0.6rem;
    font-size: 0.72rem;
    color: #9ca3af;
}

.map-card-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Badge statut */
.map-badge {
    position: absolute;
    top: 0.55rem;
    right: 0.75rem;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 3px;
}

.map-badge.for-sale {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.map-badge.sold {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
}

.map-badge.pending {
    background: rgba(251, 191, 36, 0.1);
    color: #d97706;
}

/* ─── Carte ────────────────────────────────────────────────────────────────── */

.map-container {
    flex: 1;
    position: relative;
    z-index: 1;
    overflow: visible;
}

#map {
    width: 100%;
    height: 100%;
}

/* Leaflet controls stay visible (not under header) */
.leaflet-control-layers {
    z-index: 1000;
}

.leaflet-top.leaflet-right {
    z-index: 1000;
    top: 80px;
}

.leaflet-top.leaflet-left {
    top: 80px;
}

/* Markers Leaflet personnalisés */
.marker-for-sale {
    background: #22c55e;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.marker-sold {
    background: #ef4444;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 10px;
    height: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    opacity: 0.75;
}

.marker-pending {
    background: #f59e0b;
    border: 2px solid #fff;
    border-radius: 50%;
    width: 11px;
    height: 11px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Prix bubble marker */
.price-marker {
    background: #fff;
    border: 2px solid #8b6914;
    border-radius: 20px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 700;
    color: #8b6914;
    font-family: 'Montserrat', sans-serif;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.15s;
}

.price-marker:hover,
.price-marker.is-active {
    transform: scale(1.15);
    border-color: #1a1a2e;
    color: #1a1a2e;
    z-index: 1000 !important;
}

.price-marker.sold-marker {
    border-color: #d1d5db;
    background: #f3f4f6;
    color: #9ca3af;
    font-size: 10px;
    font-weight: 600;
}

.price-marker.psd-marker {
    border-color: rgba(139, 105, 20, 0.3);
    background: #fffbeb;
    color: rgba(139, 105, 20, 0.7);
    font-size: 10px;
    font-weight: 600;
    font-style: italic;
}

/* Leaflet popup — light */
.leaflet-popup-content-wrapper {
    background: #fff;
    color: #1a1a2e;
    border: none;
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18), 0 2px 8px rgba(0,0,0,0.08);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-tip-container {
    display: none;
}

.leaflet-popup-content {
    margin: 0;
    width: 320px !important;
}

.map-popup-img {
    width: 100%;
    height: 170px;
    object-fit: cover;
    display: block;
}

.map-popup-no-img {
    width: 100%;
    height: 100px;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d1d5db;
    font-size: 1.5rem;
}

.map-popup-body {
    padding: 0.85rem 1rem 1rem;
}

.map-popup-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: #8b6914;
    font-family: 'Montserrat', sans-serif;
    margin-bottom: 0.2rem;
}

.map-popup-price.sold-popup-price {
    font-size: 0.85rem;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.map-popup-address {
    font-size: 0.82rem;
    color: #374151;
    margin-bottom: 0.15rem;
}

.map-popup-city {
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.6rem;
}

.map-popup-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: #9ca3af;
    margin-bottom: 0.75rem;
}

.map-popup-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.map-popup-btn {
    display: block;
    width: 100%;
    padding: 0.5rem;
    background: #8b6914;
    color: #fff;
    font-weight: 700;
    font-size: 0.8rem;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    transition: background 0.2s;
}

.map-popup-btn:hover {
    background: #a37d1a;
}

/* Toggle sidebar mobile */
.sidebar-toggle {
    display: none;
}

/* ─── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .map-page {
        flex-direction: column-reverse;
        height: calc(100vh - 64px);
    }

    .map-sidebar {
        width: 100%;
        min-width: unset;
        height: 50%;
        border-right: none;
        border-top: 1px solid #e5e7eb;
        transform: translateY(0);
        transition: height 0.3s ease;
    }

    .map-sidebar.collapsed {
        height: 54px;
    }

    .map-container {
        height: 50%;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.4rem;
        width: 100%;
        padding: 0.75rem;
        background: #f8f9fa;
        border: none;
        border-top: 1px solid #e5e7eb;
        color: #6b7280;
        font-size: 0.8rem;
        cursor: pointer;
        order: -1;
    }
}