/**
 * Property Map — screenshot-matched layout (meta top-left, filters top-right)
 */

.ps-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.ps-map-section {
    margin: 28px auto 24px;
    max-width: 100%;
}

.ps-map-header {
    text-align: center;
    margin-bottom: 14px;
    padding: 0 12px;
}

.ps-map-header .map-section-subtitle {
    font-size: 1rem;
    color: #5a6c7d;
    max-width: 720px;
    margin: 0 auto;
    line-height: 1.5;
    font-weight: 400;
}

.ps-map-module {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
    overflow: visible;
}

.ps-map-body .map-container {
    position: relative;
    border-radius: 0 0 12px 12px;
    overflow: visible;
}

.ps-map-body #property-map {
    width: 100%;
    height: 560px;
    background: #e8eef4;
    z-index: 1;
    border-radius: 0 0 12px 12px;
    overflow: hidden;
}

/* Hide Leaflet / OSM attribution watermark on map */
.ps-map-body .leaflet-control-attribution,
#property-map .leaflet-control-attribution {
    display: none !important;
}

/* ── Bottom-left status bar (property count + coordinates) — clear of zoom top-left ── */
.ps-map-meta-strip {
    position: absolute;
    bottom: 16px;
    left: 14px;
    top: auto;
    z-index: 1000;
    max-width: min(420px, calc(100% - 28px));
    padding: 0;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(15, 23, 42, 0.14);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ps-map-meta-strip > * {
    pointer-events: auto;
}

.ps-map-meta-line {
    margin: 0;
    padding: 10px 14px;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: #64748b;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.ps-map-meta-line + .ps-map-meta-line {
    border-top: 1px solid #eef2f7;
    padding-top: 9px;
    padding-bottom: 9px;
}

.ps-map-meta-coords {
    font-size: 0.75rem;
    color: #64748b;
    justify-content: space-between;
    gap: 10px;
}

#mapResultsCount {
    font-weight: 700;
    color: #1a2a44;
    font-size: 0.875rem;
}

.ps-ov-dot {
    color: #cbd5e1;
    padding: 0 2px;
    user-select: none;
}

#mapResultsFilterHint {
    color: #64748b;
    font-weight: 400;
    font-size: 0.8125rem;
}

.ps-map-meta-coords.is-ready {
    color: #475569;
}

.ps-map-meta-coords.is-ready #psCoordsText {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    letter-spacing: -0.01em;
    flex: 1;
    min-width: 0;
    word-break: break-all;
}

.ps-map-meta-coords.is-precise #psCoordsText,
#psCoordsText.ps-coords-precise {
    color: #059669;
    font-weight: 600;
}

#mapCurrentLocationBtn.is-precise {
    border-color: #059669;
    color: #059669;
}

.ps-ov-coords-copy {
    flex-shrink: 0;
    margin-left: auto;
    padding: 5px 12px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    background: #f8fafc;
    color: #374151;
    font-size: 0.6875rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    display: none;
}

.ps-map-meta-coords.is-ready .ps-ov-coords-copy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ps-ov-coords-copy:hover {
    background: #fff;
    border-color: #94a3b8;
}

.ps-ov-coords-copy.copied {
    background: #ecfdf5;
    border-color: #059669;
    color: #059669;
}

/* Leaflet zoom — top-left, styled, never overlaps meta (meta is bottom-left on desktop) */
.ps-map-body .leaflet-top.leaflet-left {
    top: 12px;
    left: 12px;
    z-index: 998;
}

.ps-map-body .leaflet-control-zoom {
    border: none !important;
    border-radius: 10px !important;
    overflow: hidden;
    box-shadow: 0 2px 14px rgba(15, 23, 42, 0.14) !important;
}

.ps-map-body .leaflet-control-zoom a {
    width: 38px !important;
    height: 38px !important;
    line-height: 38px !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #1e293b !important;
    background: #fff !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

.ps-map-body .leaflet-control-zoom a:last-child {
    border-bottom: none !important;
}

.ps-map-body .leaflet-control-zoom a:hover {
    background: #f8fafc !important;
    color: #0f172a !important;
}

.ps-map-search-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    padding: 0 !important;
    margin: -1px !important;
}

/* ── Top-right filter bar (screenshot style) ── */
.ps-map-body .map-filters-container,
.ps-map-filter-bar {
    position: absolute !important;
    top: 14px !important;
    right: 14px !important;
    left: auto !important;
    z-index: 1001 !important;
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 10px !important;
    margin: 0 !important;
    background: #ffffff !important;
    border: 1.5px solid #d4af37 !important;
    border-radius: 10px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1) !important;
    overflow: visible !important;
    max-width: calc(100% - 28px);
}

.ps-map-body .map-current-location-btn {
    background: #111827 !important;
    border: 1.5px solid #111827 !important;
    border-radius: 8px !important;
    padding: 0 14px !important;
    height: 42px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #ffffff !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: none !important;
}

.ps-map-body .map-current-location-btn i {
    color: #fbbf24 !important;
    font-size: 1rem !important;
}

.ps-map-body .map-current-location-btn span {
    color: #ffffff !important;
}

.ps-map-body .distance-dropdown-btn,
.ps-map-body .category-dropdown-btn {
    background: #fffdf5 !important;
    border: 1.5px solid #d4af37 !important;
    border-radius: 8px !important;
    padding: 0 12px !important;
    height: 42px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: #1f2937 !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: none !important;
    min-width: auto !important;
}

.ps-map-body .distance-dropdown-btn > i:first-child,
.ps-map-body .category-dropdown-btn > i:first-child {
    color: #d4af37 !important;
    font-size: 1rem !important;
}

.ps-map-body .distance-dropdown-btn > i:last-child,
.ps-map-body .category-dropdown-btn > i:last-child {
    color: #9ca3af !important;
    font-size: 0.65rem !important;
    margin-left: 2px;
}

#selectedDistanceLabel,
#selectedMapCategory {
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-distance-dropdown,
.map-category-dropdown {
    position: relative;
    flex-shrink: 0;
    overflow: visible !important;
}

.ps-map-module .distance-menu,
.ps-map-module .category-menu {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
    padding: 0;
    margin: 0;
    list-style: none;
    border: 1.5px solid #d4af37;
    background: #fff;
    z-index: 1100 !important;
}

.ps-map-module .distance-menu.show,
.ps-map-module .category-menu.show {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    visibility: visible !important;
    transform: none !important;
}

.ps-sheet-handle {
    display: none;
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 999px;
    margin: 8px auto 4px;
    list-style: none;
}

.ps-sheet-title {
    padding: 10px 14px 4px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    list-style: none;
}

.ps-map-module .distance-option,
.ps-map-module .category-option {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px !important;
    font-size: 0.875rem !important;
    color: #334155 !important;
    text-decoration: none !important;
    border-bottom: 1px solid #f1f5f9;
    min-height: 40px;
    cursor: pointer;
}

.ps-map-module .distance-option.active,
.ps-map-module .category-option.active {
    background: linear-gradient(90deg, #d4af37 0%, #f0c14b 100%) !important;
    color: #1a2a44 !important;
    font-weight: 700;
    padding-left: 1.8rem !important;
    position: relative;
}

.ps-map-module .distance-option.active::before,
.ps-map-module .category-option.active::before {
    content: '✓';
    position: absolute;
    left: 0.65rem;
    font-weight: bold;
    font-size: 0.85rem;
}

.ps-opt-count {
    padding: 1px 7px;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.65rem;
    font-weight: 700;
}

.ps-map-error {
    position: absolute;
    bottom: 120px;
    left: 14px;
    right: 14px;
    z-index: 500;
    text-align: center;
    font-size: 0.75rem;
    color: #92400e;
    background: rgba(255, 251, 235, 0.96);
    padding: 8px 10px;
    border-radius: 10px;
}

.ps-map-body .map-location-status {
    position: absolute;
    bottom: 110px;
    left: 14px;
    right: 14px;
    z-index: 999;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.88);
    color: #fff;
    font-size: 0.7rem;
    text-align: center;
    pointer-events: none;
}

.ps-map-body .map-location-status:empty {
    display: none;
}

.ps-map-dropdown-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 10050;
}

.ps-map-dropdown-backdrop.visible {
    display: block;
}

body.ps-map-sheet-open {
    overflow: hidden;
}

.ps-map-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    z-index: 20000;
    padding: 10px 18px;
    border-radius: 10px;
    background: #0f172a;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    pointer-events: none;
}

.ps-map-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (min-width: 769px) {
    .ps-map-module .ps-map-sheet {
        position: absolute !important;
        top: calc(100% + 6px) !important;
        left: 0 !important;
        right: auto !important;
        min-width: 200px !important;
        max-height: 360px !important;
        overflow-y: auto !important;
        border-radius: 10px !important;
        box-shadow: 0 8px 28px rgba(15, 23, 42, 0.18) !important;
    }

    .ps-sheet-title {
        display: none;
    }

    /* Keep screenshot layout on desktop — override homepage inline map CSS */
    .ps-map-module .map-filters-container,
    .ps-map-module .ps-map-filter-bar {
        top: 14px !important;
        right: 14px !important;
        left: auto !important;
        bottom: auto !important;
        flex-wrap: nowrap !important;
        justify-content: flex-end !important;
        border: 1.5px solid #d4af37 !important;
    }

    .ps-map-module .map-current-location-btn span {
        display: inline !important;
    }
}

@media (max-width: 768px) {
    .ps-map-body #property-map {
        height: min(58vh, 460px) !important;
    }

    /* Mobile: meta at top (no desktop zoom); filters stay at bottom */
    .ps-map-meta-strip {
        top: 10px;
        bottom: auto;
        left: 10px;
        right: 10px;
        max-width: none;
    }

    .ps-map-meta-line {
        font-size: 0.75rem;
        padding: 8px 12px;
    }

    .ps-map-meta-coords {
        font-size: 0.6875rem;
    }

    /* Bottom toolbar: [location] [distance] [categories] — single row */
    .ps-map-body .map-filters-container,
    .ps-map-filter-bar {
        top: auto !important;
        bottom: 12px !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: none !important;
        display: grid !important;
        grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1fr) !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        padding: 8px !important;
        align-items: stretch !important;
        overflow: visible !important;
        justify-content: stretch !important;
    }

    .ps-map-body .map-current-location-btn {
        width: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        height: 44px !important;
        padding: 0 !important;
        justify-content: center !important;
    }

    .ps-map-body .map-current-location-btn span {
        display: none !important;
    }

    .ps-map-body .map-distance-dropdown,
    .ps-map-body .map-category-dropdown {
        min-width: 0 !important;
        width: 100% !important;
    }

    .ps-map-body .distance-dropdown-btn,
    .ps-map-body .category-dropdown-btn {
        width: 100% !important;
        min-width: 0 !important;
        height: 44px !important;
        padding: 0 8px !important;
        font-size: 0.72rem !important;
    }

    #selectedDistanceLabel,
    #selectedMapCategory {
        flex: 1;
        min-width: 0;
        max-width: none !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ps-map-body .distance-dropdown-btn > i:last-child,
    .ps-map-body .category-dropdown-btn > i:last-child {
        flex-shrink: 0;
        margin-left: auto;
    }

    .ps-map-module .ps-map-sheet {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-height: 50vh !important;
        border-radius: 18px 18px 0 0 !important;
        z-index: 10060 !important;
    }

    .ps-sheet-handle {
        display: block;
    }
}

.ps-map-module .mobile-current-location-coords {
    display: none !important;
}
