/* =============================================================================
   FYSH — Property map page
   CR: fysh-map-2026-06-23
   listings-map.php. Loaded alongside base.css, components.css.
   Uses CSS custom properties from tokens.css (--navy, --gold, --blue, --border).
============================================================================= */

/* ── Page layout: fills viewport below sticky header (68px) ─────────────── */
.map-page {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: calc(100vh - 68px);
    overflow: hidden;
}

/* ── Left panel: filters + results list ─────────────────────────────────── */
.map-panel {
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border, #E2E8F0);
    background: #fff;
    overflow: hidden;
}

/* Filter bar */
.map-filters {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border, #E2E8F0);
    flex-shrink: 0;
}

.map-filters__row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.map-filters__row--full { grid-template-columns: 1fr; }

.map-filter-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border, #E2E8F0);
    border-radius: 7px;
    font-size: 13px;
    font-family: inherit;
    color: #0F2340;
    background: #fff;
    appearance: none;
    -webkit-appearance: none;
}

.map-filter-input:focus {
    outline: 2px solid var(--blue, #1E5BA8);
    outline-offset: 0;
    border-color: transparent;
}

/* ── Location search field with embedded info icon ────────────────────────── */
.map-search-wrap {
    position: relative;
    width: 100%;
}

/* Extra right padding so text doesn't run under the icon */
.map-filter-input--has-icon {
    padding-right: 30px;
}

.map-search-info {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 2px;
    cursor: pointer;
    color: #9DAFC4;
    font-size: 15px;
    line-height: 1;
    display: flex;
    align-items: center;
    border-radius: 3px;
    transition: color 0.15s;
}
.map-search-info:hover,
.map-search-info:focus-visible { color: var(--blue, #1E5BA8); outline: none; }

/* Premium tooltip — appears on hover/focus of the icon button */
.map-search-info__tooltip {
    position: absolute;
    right: -8px;
    top: calc(100% + 10px);
    width: 248px;
    background: var(--navy, #0F2340);
    color: rgba(255, 255, 255, 0.90);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.6;
    text-align: left;
    padding: 10px 13px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(15, 35, 64, 0.30);
    pointer-events: none;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity 0.18s ease, transform 0.18s ease;
    z-index: 2000;
    white-space: normal;
}

/* Caret pointing up to the icon */
.map-search-info__tooltip::before {
    content: '';
    position: absolute;
    right: 14px;
    top: -5px;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 5px solid var(--navy, #0F2340);
}

.map-search-info:hover .map-search-info__tooltip,
.map-search-info:focus-visible .map-search-info__tooltip {
    opacity: 1;
    transform: translateY(0);
}

.map-filters__actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.map-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 14px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.map-btn--primary { background: var(--navy, #0F2340); color: #fff; }
.map-btn--primary:hover { background: #1a3a5c; }
.map-btn--ghost { background: #f0f2f5; color: var(--navy, #0F2340); }
.map-btn--ghost:hover { background: #e2e8f0; }
.map-btn--sm { padding: 5px 10px; font-size: 12px; }
.map-btn--full { width: 100%; }

/* Results list */
.map-results {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.map-results__header {
    padding: 10px 16px;
    font-size: 12px;
    color: #6B7A8D;
    border-bottom: 1px solid var(--border, #E2E8F0);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-results__count { font-weight: 600; color: var(--navy, #0F2340); font-size: 13px; }

.map-card {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border, #E2E8F0);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: background 0.12s;
}

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

.map-card__img {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    background: #f0f2f5;
    flex-shrink: 0;
}

.map-card__img--placeholder {
    width: 80px;
    height: 60px;
    border-radius: 6px;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #CBD5E0;
    font-size: 20px;
    flex-shrink: 0;
}

.map-card__body { min-width: 0; }

.map-card__price {
    font-size: 14px;
    font-weight: 700;
    color: var(--navy, #0F2340);
    margin: 0 0 2px;
}

.map-card__title {
    font-size: 12px;
    color: #374151;
    margin: 0 0 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-card__meta {
    font-size: 11px;
    color: #9BA8B4;
    display: flex;
    gap: 8px;
}

.map-results__empty {
    padding: 32px 16px;
    text-align: center;
    color: #6B7A8D;
    font-size: 13px;
}

/* ── Map container ───────────────────────────────────────────────────────── */
.map-container {
    position: relative;
    background: #f0f2f5;
}

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

/* Search this area button */
.map-search-area {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--border, #E2E8F0);
    border-radius: 20px;
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(15,35,64,0.12);
    display: none;
    align-items: center;
    gap: 6px;
    color: var(--navy, #0F2340);
    transition: background 0.15s;
}

.map-search-area:hover { background: #f0f5ff; }
.map-search-area.is-visible { display: flex; }

/* Back to list link (mobile) */
.map-back-list {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 1000;
    background: #fff;
    border: 1px solid var(--border, #E2E8F0);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 12px;
    text-decoration: none;
    color: var(--navy, #0F2340);
    box-shadow: 0 2px 6px rgba(15,35,64,0.1);
    display: none;
}

/* ── Custom Leaflet marker ───────────────────────────────────────────────── */
.map-marker-wrap {
    background: none !important;
    border: none !important;
}

.map-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.map-marker__pill {
    background: var(--navy, #0F2340);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    font-family: Inter, -apple-system, sans-serif;
    padding: 4px 10px;
    border-radius: 20px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(15,35,64,0.30);
    transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
    pointer-events: auto;
}

.map-marker__stem {
    width: 2px;
    height: 6px;
    background: var(--navy, #0F2340);
    border-radius: 0 0 2px 2px;
    transition: background 0.15s;
}

.map-marker__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--navy, #0F2340);
    margin-top: -1px;
    transition: background 0.15s;
}

/* Hover / active state — gold highlight */
.map-marker--active .map-marker__pill,
.map-marker-wrap:hover .map-marker__pill {
    background: var(--gold, #C9A84C);
    color: #0F2340;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(201,168,76,0.40);
    z-index: 1000 !important;
}

.map-marker--active .map-marker__stem,
.map-marker-wrap:hover .map-marker__stem,
.map-marker--active .map-marker__dot,
.map-marker-wrap:hover .map-marker__dot {
    background: var(--gold, #C9A84C);
}

/* ── Custom Leaflet popup ────────────────────────────────────────────────── */
.leaflet-popup-content-wrapper {
    border-radius: 10px !important;
    box-shadow: 0 8px 24px rgba(15,35,64,0.16) !important;
    padding: 0 !important;
    overflow: hidden;
}

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

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

.map-popup { width: 240px; }

.map-popup__img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    display: block;
    background: #f0f2f5;
}

.map-popup__img--placeholder {
    width: 100%;
    height: 130px;
    background: #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #CBD5E0;
    font-size: 28px;
}

.map-popup__body { padding: 12px 14px; }

.map-popup__price {
    font-size: 16px;
    font-weight: 700;
    color: var(--navy, #0F2340);
    margin: 0 0 3px;
}

.map-popup__title {
    font-size: 12px;
    color: #374151;
    margin: 0 0 5px;
    line-height: 1.4;
}

.map-popup__meta {
    font-size: 11px;
    color: #9BA8B4;
    margin: 0 0 10px;
    display: flex;
    gap: 8px;
}

.map-popup__cta {
    display: block;
    text-align: center;
    padding: 7px 14px;
    background: var(--navy, #0F2340);
    color: #fff;
    text-decoration: none;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    transition: background 0.15s;
}

.map-popup__cta:hover { background: #1a3a5c; }

/* ── Mobile responsive ───────────────────────────────────────────────────── */
@media (max-width: 720px) {
    .map-page {
        grid-template-columns: 1fr;
        grid-template-rows: auto 300px 1fr;
        height: auto;
        overflow: visible;
    }

    .map-panel {
        overflow: visible;
        border-right: none;
        border-bottom: 1px solid var(--border, #E2E8F0);
        order: 1;
    }

    .map-container {
        height: 300px;
        order: 2;
    }

    #map { height: 300px; }

    .map-results {
        overflow: visible;
        order: 3;
    }

    .map-back-list { display: flex; }
}

/* ── Featured marker (highlighted from listing.php CTA) ─────────────────── */
.map-marker--featured .map-marker__pill {
    background: var(--gold, #C9A84C);
    color: #0F2340;
    padding: 5px 13px;
    box-shadow: 0 4px 16px rgba(201,168,76,0.50);
    transform: scale(1.18);
}

.map-marker--featured .map-marker__stem,
.map-marker--featured .map-marker__dot {
    background: var(--gold, #C9A84C);
}

/* Hover on featured keeps gold, brightens */
.map-marker--featured.map-marker-wrap:hover .map-marker__pill {
    background: #b8922f;
    color: #fff;
}

/* ── Favourites toggle button ────────────────────────────────────────────── */
.map-btn--fav {
    background: #fdf6e7;
    color: #92400E;
    border: 1px solid #f0d080;
    font-size: 12px;
}

.map-btn--fav:hover { background: #fbeecf; }

.map-btn--fav-active {
    background: var(--gold, #C9A84C);
    color: #0F2340;
    border-color: var(--gold, #C9A84C);
}

.map-btn--fav-active:hover { background: #b8922f; color: #fff; }

/* ── Radius search ───────────────────────────────────────────────────────── */
.map-radius-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border, #E2E8F0);
}

.map-btn--radius { font-size: 12px; }

.map-btn--radius-active {
    background: #EBF2FF;
    color: var(--blue, #1E5BA8);
    border: 1px solid #bfdbfe;
}

.radius-controls {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8faff;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
}

.radius-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.radius-label {
    font-size: 12px;
    font-weight: 500;
    color: #0F2340;
    white-space: nowrap;
    flex-shrink: 0;
}

.radius-select { flex: 1; font-size: 12px; padding: 5px 8px; }

.radius-clear {
    flex-shrink: 0;
    padding: 5px 8px;
    font-size: 12px;
    color: #6B7A8D;
}

.radius-hint {
    margin: 6px 0 0;
    font-size: 11px;
    color: #6B7A8D;
    text-align: center;
    line-height: 1.4;
}

/* Crosshair cursor while dropping a pin */
#map.map--radius-mode,
#map.map--radius-mode .leaflet-interactive {
    cursor: crosshair !important;
}

/* ── Radius centre pin ───────────────────────────────────────────────────── */
.radius-pin-wrap { background: none !important; border: none !important; }

.radius-pin {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 42px;
    filter: drop-shadow(0 2px 6px rgba(30,91,168,0.40));
}

.radius-pin .ti {
    font-size: 32px;
    color: var(--blue, #1E5BA8);
    line-height: 1;
}

/* ── Privacy pill badge (no stem/dot) ────────────────────────────────────── */
.map-marker--privacy {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.map-marker--privacy .map-marker__pill {
    box-shadow: 0 2px 10px rgba(15,35,64,0.35);
}

/* ── Dimmed marker (non-active when another is selected) ─────────────────── */
.map-marker-wrap--dimmed {
    opacity: 0.22;
    transition: opacity 0.2s ease;
}

/* ── FYSH cluster badge ───────────────────────────────────────────────────── */
.fysh-cluster {
    width: 40px;
    height: 40px;
    background: var(--navy, #0F2340);
    border: 2.5px solid rgba(255,255,255,0.85);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(15,35,64,0.35);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
}
.fysh-cluster:hover {
    transform: scale(1.12);
    box-shadow: 0 4px 14px rgba(15,35,64,0.40);
}
.fysh-cluster__count {
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    font-family: Inter, -apple-system, sans-serif;
    line-height: 1;
}
/* Suppress the default markercluster CSS for our elements */
.leaflet-cluster-anim .leaflet-marker-icon,
.leaflet-cluster-anim .leaflet-marker-shadow {
    transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}
