/* ===================================================================
   App Shell — split-screen container below the fixed header
   =================================================================== */

#app-shell {
    position: fixed;
    top: 4rem;
    /* Height of #site-header */
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    /* Mobile: stack vertically */
    z-index: 0;
}

@media (min-width: 768px) {
    #app-shell {
        flex-direction: row;
        /* Desktop: sidebar left, map right */
    }
}

/* ===================================================================
   Sidebar Panel (#listings-list)
   =================================================================== */

#listings-list {
    flex: 0 0 400px;
    /* Fixed width on desktop */
    max-width: 100%;
    order: 2;
    /* Mobile: list below map */
    display: flex;
    flex-direction: column;
    background-color: #f4f7f8;
    /* JustJoin.it style background */
    border-right: 1px solid #e1e8eb;
    overflow: hidden;
}

@media (min-width: 768px) {
    #listings-list {
        order: 1;
        /* Desktop: list on left */
    }
}

#listings-header {
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid #e1e8eb;
    flex-shrink: 0;
}

#listings-count {
    font-size: 13px;
    font-weight: 600;
    color: #303b44;
}

/* District Filter Pills */
#listings-filter-pills {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: #fff;
    border-bottom: 1px solid #e1e8eb;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
    /* Hide scrollbar Firefox */
}

#listings-filter-pills::-webkit-scrollbar {
    display: none;
    /* Hide scrollbar Chrome/Safari */
}

.pill {
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #d0dae0;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: #4a5568;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pill:hover {
    border-color: #dc2626;
    color: #dc2626;
}

.pill.pill--active {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

/* Results container */
#listings-cards {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* ===================================================================
   Listing Cards
   =================================================================== */

.listing-card {
    display: flex;
    align-items: center;
    background: #fff;
    padding: 14px 16px;
    border-bottom: 1px solid #e1e8eb;
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 12px;
}

.listing-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-left-color: #dc2626;
    position: relative;
    z-index: 1;
}

.listing-card.is-active {
    background: #fff8f8;
    border-left-color: #dc2626;
}

/* Card Logo / Thumb */
.card-logo {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    border: 1px solid #e1e8eb;
    background: #f0f4f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

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

.card-logo-placeholder {
    font-size: 20px;
    font-weight: 700;
    color: #303b44;
    text-transform: uppercase;
}

/* Card Information */
.card-info {
    flex: 1;
    min-width: 0;
    /* Allow title truncation */
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: #303b44;
    margin: 0 0 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-location {
    font-size: 12px;
    color: #7b8e97;
    margin-bottom: 4px;
}

.card-meta {
    font-size: 12px;
    color: #7b8e97;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Card Right Side (Price & Type) */
.card-right {
    text-align: right;
    flex-shrink: 0;
}

.card-price {
    font-size: 14px;
    font-weight: 700;
    color: #303b44;
    margin: 0;
}

.card-price-currency {
    font-size: 11px;
    font-weight: 400;
    color: #7b8e97;
}

.card-tag {
    display: inline-block;
    padding: 2px 8px;
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-top: 4px;
}

.card-tag--sale {
    background: #fff3e0;
    color: #e65100;
}

/* Empty State */
#listings-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #b0bec5;
    text-align: center;
}

#listings-empty svg {
    margin-bottom: 12px;
}

/* ===================================================================
   Map Controls Override
   =================================================================== */

/* These will be handled via JS init options, but we can add minor UI tweaks here */
.gm-style-mtc,
.gm-svpc,
.gm-fullscreen-control {
    display: none !important;
}

/* Google Maps InfoWindow (replaces Leaflet popup) */
.gm-style .gm-style-iw-c {
    background: #ffffff !important;
    border: 1.5px solid #dc2626 !important;
    border-radius: 0.625rem !important;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12) !important;
    padding: 0 !important;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    padding: 0.75rem 1rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    line-height: 1.5;
}

/* Hide the default InfoWindow close button arrow / tail */
.gm-style .gm-style-iw-tc::after {
    background: #ffffff;
}

/* Zoom controls: Google Maps default is fine; push them from the edge */
.gmnoprint {
    margin-bottom: 1.5rem !important;
}

/* Top header bar — full-width fixed, 4rem tall */
#site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 4rem;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.25s ease;
}

#site-header:hover {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.10);
}

/* Logo */
#site-header .site-logo {
    font-family: 'Montserrat', 'Inter', system-ui, sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #1f2937;
    text-decoration: none;
    line-height: 1;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0;
    /* Header bar provides spacing via padding */
}

/* Red brand dot */
#site-header .site-logo::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #dc2626;
    flex-shrink: 0;
}

#site-header .site-logo span {
    color: #1f2937;
}


/* ===================================================================
   Pulse marker — CSS-animated overlay rendered into Google Maps
   The JS creates a div with .mapka-marker as a custom OverlayView.
   =================================================================== */

@keyframes mapka-pulse {
    0% {
        transform: scale(1);
        opacity: 0.7;
    }

    60% {
        transform: scale(2.6);
        opacity: 0;
    }

    100% {
        transform: scale(2.6);
        opacity: 0;
    }
}

.mapka-marker {
    position: absolute;
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%);
    /* Centre on lat/lng point */
    pointer-events: none;
    /* Let map receive clicks through the halo */
}

.mapka-marker__pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(220, 38, 38, 0.45);
    animation: mapka-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    pointer-events: none;
}

.mapka-marker__dot {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #dc2626;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.5);
}

/* Skip-to-content accessibility link */
.skip-link {
    position: absolute;
    top: -9999px;
    left: 1rem;
    z-index: 9999;
    padding: 0.5rem 1rem;
    background: #dc2626;
    color: #fff;
    font-size: 0.875rem;
    border-radius: 0 0 0.25rem 0.25rem;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

/* Filter toggle — standalone red pill button in the header bar */
#mapka-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: #dc2626;
    color: #ffffff;
    border: none;
    border-radius: 2rem;
    padding: 0.45rem 1rem 0.45rem 0.75rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease;
}

#mapka-filter-toggle:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

#mapka-filter-toggle[aria-expanded="true"] {
    background: #1f2937;
}

#mapka-filter-toggle svg {
    flex-shrink: 0;
}


/* ===================================================================
   Backdrop — darkens the map when filter panel is open
   =================================================================== */

#mapka-filter-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1500;
    /* Between header (1000) and sidebar (2000) */
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

#mapka-filter-backdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
}

/* ===================================================================
   Filter sidebar panel
   =================================================================== */

#mapka-filter-panel {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 2000;
    /* Above header (1000) so it slides fully over */
    width: 320px;
    max-width: calc(100vw - 3rem);
    background: #ffffff;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.18);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#mapka-filter-panel.is-open {
    transform: translateX(0);
}

.filter-panel__inner {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Panel header */
.filter-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.25rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.filter-panel__title {
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

#mapka-filter-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background: #f3f4f6;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #4b5563;
    transition: background 0.15s ease, color 0.15s ease;
}

#mapka-filter-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

/* Scrollable body */
.filter-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}

/* Individual filter group */
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-label {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #6b7280;
}

.filter-select,
.filter-input {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    color: #1f2937;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 0.5rem;
    outline: none;
    appearance: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    box-sizing: border-box;
}

.filter-select:focus,
.filter-input:focus {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

/* Price range row */
.filter-range-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-range-row .filter-input {
    flex: 1;
}

.filter-range-sep {
    font-weight: 600;
    color: #9ca3af;
    flex-shrink: 0;
}

/* Panel footer buttons */
.filter-panel__footer {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.filter-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.filter-btn:active {
    transform: scale(0.97);
}

.filter-btn--primary {
    background: #dc2626;
    color: #ffffff;
}

.filter-btn--primary:hover {
    background: #b91c1c;
}

.filter-btn--ghost {
    background: #f3f4f6;
    color: #374151;
}

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

/* ===================================================================
   Results count badge
   =================================================================== */

#mapka-results-badge {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(31, 41, 55, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #ffffff;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

#mapka-results-badge.is-visible {
    opacity: 1;
}

/* ===================================================================
   Bottom Sheet — slides up from bottom on marker click
   =================================================================== */

#mapka-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 3000;
    /* Above everything */
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.30);
    border-radius: 1.25rem 1.25rem 0 0;
    box-shadow:
        0 -8px 40px rgba(0, 0, 0, 0.16),
        0 -2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(100%);
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    padding-bottom: env(safe-area-inset-bottom, 0);
    /* iPhone notch */
}

#mapka-bottom-sheet.is-open {
    transform: translateY(0);
}

/* Drag handle pill */
.bs-handle {
    width: 2.5rem;
    height: 4px;
    background: rgba(31, 41, 55, 0.18);
    border-radius: 2px;
    margin: 0.75rem auto 0;
}

/* Inner layout */
.bs-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 1.25rem 1.1rem;
}

/* Text area */
.bs-content {
    flex: 1;
    min-width: 0;
}

.bs-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 0.2rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bs-meta {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: #6b7280;
    margin: 0;
}

/* Action buttons */
.bs-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.bs-btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 0.9rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    border-radius: 2rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.1s ease;
}

.bs-btn:active {
    transform: scale(0.96);
}

.bs-btn--primary {
    background: #dc2626;
    color: #ffffff;
}

.bs-btn--primary:hover {
    background: #b91c1c;
}

.bs-btn--ghost {
    background: rgba(31, 41, 55, 0.08);
    color: #374151;
}

.bs-btn--ghost:hover {
    background: rgba(31, 41, 55, 0.14);
}

/* ===================================================================
   Reduced-motion accessibility
   =================================================================== */

@media (prefers-reduced-motion: reduce) {

    #mapka-filter-panel,
    #mapka-filter-backdrop,
    #mapka-results-badge,
    #mapka-filter-toggle {
        transition: none;
    }
}

/* ===================================================================
   App Shell — split-screen container below the fixed header
   =================================================================== */

#app-shell {
    position: fixed;
    top: 4rem;
    /* Height of #site-header */
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    /* Mobile: stack vertically */
    z-index: 0;
}

@media (min-width: 768px) {
    #app-shell {
        flex-direction: row;
        /* Desktop: side by side */
    }
}

/* ===================================================================
   Listings Panel
   =================================================================== */

#listings-list {
    flex: 0 0 60%;
    /* Mobile: 60% of column height */
    order: 2;
    /* Mobile: below the map */
    overflow-y: auto;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
    #listings-list {
        flex: 0 0 40%;
        /* Desktop: 40% of row width */
        order: 1;
        /* Desktop: left panel */
    }
}

/* ─── Panel header ─────────────────────────────── */

#listings-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.75rem 1rem 0.6rem;
    background: rgba(249, 250, 251, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

#listings-count {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #9ca3af;
}

/* ─── Cards container ──────────────────────────── */

#listings-cards {
    padding: 0.75rem 0.75rem 1.5rem;
    flex: 1;
}

/* ─── Empty state ──────────────────────────────── */

#listings-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem 1.5rem;
    color: #9ca3af;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.82rem;
    text-align: center;
}

#listings-empty p {
    margin: 0;
}

/* ===================================================================
   Listing Card
   =================================================================== */

.listing-card {
    display: flex;
    align-items: stretch;
    background: #ffffff;
    border-radius: 0.875rem;
    border: 1px solid #f3f4f6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    margin-bottom: 0.65rem;
    overflow: hidden;
    cursor: pointer;
    transition:
        box-shadow 0.18s ease,
        border-color 0.18s ease,
        transform 0.12s ease;
    outline: none;
}

.listing-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.10);
    border-color: #e5e7eb;
    transform: translateY(-1px);
}

.listing-card:focus-visible {
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.30);
    border-color: #dc2626;
}

/* Active = marker selected on map */
.listing-card.is-active {
    border-color: #dc2626;
    box-shadow:
        0 0 0 1px #dc2626,
        0 4px 20px rgba(220, 38, 38, 0.12);
    transform: translateY(-1px);
}

/* ─── Thumbnail ────────────────────────────────── */

.card-thumb {
    flex-shrink: 0;
    width: 80px;
    background: #f3f4f6;
    overflow: hidden;
}

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

.card-thumb-placeholder {
    width: 100%;
    height: 100%;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.card-thumb-placeholder span {
    font-family: 'Montserrat', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    color: #dc2626;
    opacity: 0.6;
}

/* ─── Body ─────────────────────────────────────── */

.card-body {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.8rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.2rem;
}

.card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.15rem;
}

.card-badge {
    display: inline-block;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #dc2626;
    background: #fef2f2;
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
}

.card-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.82rem;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-price {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.88rem;
    font-weight: 800;
    color: #dc2626;
    margin: 0;
}

.card-currency {
    font-size: 0.72rem;
    font-weight: 600;
    color: #ef4444;
}

.card-meta {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.7rem;
    color: #9ca3af;
    margin: 0;
}