/* ============================================
   Map Page — Leaflet + Property Markers
   ============================================ */

/* --- Layout --- */
.map-page {
    display: flex;
    height: calc(100vh - 70px);
    margin-top: 70px;
    position: relative;
    overflow: hidden;
}

/* --- Filter Sidebar --- */
.map-sidebar {
    width: 360px;
    min-width: 320px;
    background: #fff;
    border-right: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    z-index: 500;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.map-sidebar-header {
    padding: 1.25rem 1.5rem;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: #fff;
}

.map-sidebar-header h2 {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.map-sidebar-header p {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 0;
}

.map-filters {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.filter-group {
    margin-bottom: 1.25rem;
}

.filter-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #f9fafb;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.filter-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.8rem center;
    padding-right: 2rem;
}

.filter-group select:focus,
.filter-group input:focus {
    outline: none;
    border-color: #06b6d4;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.15);
}

.price-range-row {
    display: flex;
    gap: 0.6rem;
}

.price-range-row input {
    flex: 1;
    min-width: 0;
}

.filter-actions {
    display: flex;
    gap: 0.6rem;
    margin-top: 0.5rem;
}

.btn-filter {
    flex: 1;
    padding: 0.65rem 1rem;
    border: none;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.25s;
}

.btn-filter-primary {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: #fff;
}

.btn-filter-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

.btn-filter-reset {
    background: #f3f4f6;
    color: #6b7280;
}

.btn-filter-reset:hover {
    background: #e5e7eb;
}

/* --- Property List in Sidebar --- */
.map-property-list {
    border-top: 1px solid #e5e7eb;
    overflow-y: auto;
    flex: 1;
    padding: 0;
}

.map-property-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
    color: inherit;
}

.map-property-item:hover,
.map-property-item.active {
    background: #f0fdfa;
}

.map-property-item-img {
    width: 70px;
    height: 55px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

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

.map-property-item-info h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-property-item-info .price {
    font-size: 0.8rem;
    font-weight: 700;
    color: #06b6d4;
    margin: 0;
}

.map-property-item-info .loc {
    font-size: 0.75rem;
    color: #6b7280;
    margin: 0;
}

/* --- Map Container --- */
.map-container {
    flex: 1;
    position: relative;
}

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

/* --- Mobile Toggle Button --- */
.map-sidebar-toggle {
    display: none;
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 600;
    width: 42px;
    height: 42px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    font-size: 1.1rem;
    color: #374151;
    transition: all 0.2s;
    align-items: center;
    justify-content: center;
}

.map-sidebar-toggle:hover {
    background: #f0fdfa;
    border-color: #06b6d4;
    color: #06b6d4;
}

/* --- Custom Leaflet Popup --- */
.property-popup {
    min-width: 260px;
    max-width: 300px;
    font-family: 'Outfit', sans-serif;
}

.property-popup .popup-img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
    margin: -14px -20px 10px;
    width: calc(100% + 40px);
}

.property-popup .popup-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #111827;
    margin: 0 0 0.3rem;
    line-height: 1.3;
}

.property-popup .popup-price {
    font-size: 1rem;
    font-weight: 800;
    color: #06b6d4;
    margin: 0 0 0.35rem;
}

.property-popup .popup-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.property-popup .popup-meta span {
    font-size: 0.75rem;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.property-popup .popup-meta span i {
    color: #06b6d4;
    font-size: 0.7rem;
}

.property-popup .popup-btn {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    transition: all 0.2s;
}

.property-popup .popup-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(6, 182, 212, 0.3);
}

/* Clean up Leaflet's default popup chrome */
.leaflet-popup-content-wrapper {
    border-radius: 12px !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15) !important;
    padding: 0 !important;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 14px 20px !important;
    line-height: 1.5 !important;
}

.leaflet-popup-tip {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1) !important;
}

/* --- Marker Cluster Overrides --- */
.marker-cluster-small {
    background-color: rgba(6, 182, 212, 0.25) !important;
}

.marker-cluster-small div {
    background-color: #06b6d4 !important;
    color: #fff !important;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.marker-cluster-medium {
    background-color: rgba(8, 145, 178, 0.3) !important;
}

.marker-cluster-medium div {
    background-color: #0891b2 !important;
    color: #fff !important;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.marker-cluster-large {
    background-color: rgba(14, 116, 144, 0.35) !important;
}

.marker-cluster-large div {
    background-color: #0e7490 !important;
    color: #fff !important;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

/* --- Custom Marker Icons (color circles with type icon) --- */
.custom-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
    border: 3px solid #fff;
    transition: transform 0.2s;
}

.custom-marker i {
    transform: rotate(45deg);
    font-size: 14px;
    color: #fff;
}

.custom-marker:hover {
    transform: rotate(-45deg) scale(1.2);
}

.marker-flat {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.marker-villa {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.marker-plot {
    background: linear-gradient(135deg, #10b981, #059669);
}

.marker-house {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.marker-shop {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.marker-office {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.marker-studio {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.marker-default {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

/* --- Legend --- */
.map-legend {
    position: absolute;
    bottom: 2rem;
    right: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 500;
    font-size: 0.8rem;
    min-width: 150px;
}

.map-legend h4 {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #374151;
    margin: 0 0 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.legend-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.legend-item span {
    color: #4b5563;
    font-size: 0.78rem;
}

/* --- No Results --- */
.map-no-results {
    text-align: center;
    padding: 2rem 1.5rem;
    color: #9ca3af;
}

.map-no-results i {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    display: block;
    color: #d1d5db;
}

.map-no-results p {
    margin: 0;
    font-size: 0.9rem;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .map-page {
        flex-direction: column;
    }

    .map-sidebar {
        position: absolute;
        top: 0;
        left: 0;
        height: 100%;
        width: 85vw;
        max-width: 360px;
        transform: translateX(-100%);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.15);
    }

    .map-sidebar.open {
        transform: translateX(0);
    }

    .map-sidebar-toggle {
        display: flex;
    }

    .map-container {
        height: 100%;
    }

    .map-legend {
        bottom: 1rem;
        right: 0.5rem;
        font-size: 0.75rem;
        padding: 0.75rem 1rem;
    }
}

/* --- Loading Overlay --- */
.map-loading {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 550;
    transition: opacity 0.3s;
}

.map-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.map-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e5e7eb;
    border-top-color: #06b6d4;
    border-radius: 50%;
    animation: mapSpin 0.8s linear infinite;
}

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

.map-loading p {
    margin-top: 0.75rem;
    font-size: 0.9rem;
    color: #6b7280;
    font-weight: 500;
}
