/* Premium Listings Grid & Map Styles */
:root {
    --primary: #1a237e;
    --primary-light: #534bae;
    --secondary: #ff6d00;
    --bg-light: #f8fafc;
    --surface: #ffffff;
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-pill: 50px;
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

body {
    background-color: var(--bg-light);
    color: var(--text-dark);
}

.listings-premium-hero {
    background:
        radial-gradient(circle at 10% 15%, rgba(26, 35, 126, 0.2), transparent 42%),
        radial-gradient(circle at 86% 82%, rgba(255, 109, 0, 0.18), transparent 40%),
        linear-gradient(145deg, #eef2ff 0%, #fff8ed 55%, #ffffff 100%);
    border-bottom: 1px solid rgba(26, 35, 126, 0.07);
}

.hero-panel {
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(26, 35, 126, 0.1);
    border-radius: 24px;
    box-shadow: 0 12px 28px rgba(19, 26, 71, 0.08);
    padding: 1.5rem;
}

.hero-kicker {
    color: #d35400;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.78rem;
    font-weight: 700;
}

.hero-title {
    font-size: clamp(1.5rem, 2.8vw, 2.4rem);
    line-height: 1.18;
    font-weight: 800;
    color: #0f172a;
}

.hero-subtitle {
    color: #475569;
    font-size: 1rem;
    max-width: 58ch;
}

.hero-side-title {
    font-size: 1.1rem;
    font-weight: 800;
    margin-bottom: 1rem;
    color: #1f2937;
}

.hero-stat-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
}

.hero-stat-item {
    border-radius: 14px;
    background: linear-gradient(165deg, rgba(26, 35, 126, 0.06), rgba(26, 35, 126, 0.02));
    border: 1px solid rgba(26, 35, 126, 0.08);
    padding: 0.85rem;
}

.hero-stat-label {
    display: block;
    font-size: 0.75rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.2rem;
}

.hero-stat-value {
    color: #0f172a;
    font-size: 1.3rem;
    font-weight: 800;
}

.workflow-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.7rem;
}

.workflow-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    color: #334155;
    font-size: 0.95rem;
    line-height: 1.45;
}

.workflow-list li span {
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #1e40af;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    margin-top: 2px;
}

.workflow-metric-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.workflow-metric-pill {
    border-radius: 999px;
    padding: 0.32rem 0.62rem;
    background: #f8fafc;
    border: 1px solid #dbe4f0;
    color: #334155;
    font-size: 0.76rem;
    font-weight: 600;
}

.workflow-metric-pill strong {
    color: #0f172a;
}

.premium-tabs-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid #dbe4f0;
    border-radius: 999px;
    padding: 0.55rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.premium-tab-btn {
    border: 0;
    background: transparent;
    color: #334155;
    border-radius: 999px;
    padding: 0.65rem 1.2rem;
    font-weight: 700;
    font-size: 0.9rem;
    transition: all 0.25s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.premium-tab-btn:hover {
    background: rgba(26, 35, 126, 0.08);
    color: #1e3a8a;
}

.premium-tab-btn.active {
    background: linear-gradient(135deg, #1a237e, #2f45b0);
    color: #ffffff;
    box-shadow: 0 8px 16px rgba(26, 35, 126, 0.28);
}

.kenya-trust-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.35rem 0;
}

.kenya-trust-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border-radius: 999px;
    padding: 0.42rem 0.8rem;
    border: 1px solid #dbe4f0;
    background: #f8fafc;
    color: #334155;
    font-size: 0.79rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.01em;
}

.kenya-trust-pill i {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    background: rgba(26, 35, 126, 0.12);
    color: #1e3a8a;
}

.kenya-trust-pill:first-child {
    background: linear-gradient(135deg, rgba(26, 35, 126, 0.1), rgba(26, 35, 126, 0.04));
    border-color: rgba(26, 35, 126, 0.26);
    color: #0f172a;
    font-weight: 700;
}

.kenya-trust-pill:nth-child(3) {
    border-style: dashed;
}

.premium-tab-panel {
    display: none;
}

.premium-tab-panel.is-active {
    display: block;
}

.premium-secondary-card {
    border: 1px solid rgba(26, 35, 126, 0.11);
    border-radius: 20px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
    padding: 1.1rem;
    height: 100%;
}

.premium-secondary-card .badge {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
}

.premium-secondary-title {
    font-size: 1.08rem;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.45rem;
}

.premium-secondary-meta {
    font-size: 0.88rem;
    color: #64748b;
    margin-bottom: 0.8rem;
}

.premium-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.premium-chip {
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 0.76rem;
    font-weight: 600;
}

.premium-empty-state {
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    background: #ffffff;
    padding: 2rem 1.2rem;
    text-align: center;
    color: #64748b;
}

/* 1. Horizontal Filter Bar (Premium Glassmorphism) */
.filter-bar-container {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.5);
    position: sticky;
    top: 60px;
    z-index: 1020;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04);
    padding: 1.25rem 0;
    transition: all 0.3s ease;
}

.filter-scroll-wrapper {
    display: flex;
    overflow-x: auto;
    gap: 0.85rem;
    padding-bottom: 0.5rem;
    margin-bottom: -0.5rem;
    scrollbar-width: none;
    scroll-behavior: smooth;
}

.filter-scroll-wrapper::-webkit-scrollbar {
    display: none;
}

.filter-pill {
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    padding: 0.6rem 1.4rem;
    min-height: 44px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.filter-pill:hover,
.filter-pill:focus-within {
    border-color: rgba(26, 35, 126, 0.3);
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(26, 35, 126, 0.08);
}

.filter-pill.active {
    border-color: var(--primary);
    background: linear-gradient(145deg, rgba(26, 35, 126, 0.05), rgba(26, 35, 126, 0.02));
    color: var(--primary);
}

.filter-pill i {
    color: var(--text-muted);
    font-size: 1.1rem;
    transition: color 0.3s ease;
}

.filter-pill:hover i,
.filter-pill:focus-within i,
.filter-pill.active i {
    color: var(--primary);
}

/* Checkbox fixes */
.filter-pill input[type="checkbox"] {
    margin: 0 !important;
    cursor: pointer;
    width: 1.15rem;
    height: 1.15rem;
}

.filter-pill label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-bottom: 0;
}

/* Premium Filter Inputs inside Pills */
.filter-pill input,
.filter-pill select {
    color: var(--text-dark);
    font-weight: 500;
    min-height: 40px;
}

.filter-pill input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

/* Premium Search Button */
#listingsFilterSubmit {
    background: linear-gradient(135deg, var(--primary), #2a3b8f);
    border: none;
    box-shadow: 0 6px 15px rgba(26, 35, 126, 0.25);
    transition: all 0.3s ease;
    min-height: 44px;
    padding: 0.6rem 2rem !important;
}

#listingsFilterSubmit:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(26, 35, 126, 0.4);
}

/* 2. Premium Property Cards */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    padding: 1rem 0 3rem;
}

.property-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    position: relative;
    transition: all 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.property-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.property-img-wrapper {
    position: relative;
    padding-top: 66%;
    /* 3:2 Aspect Ratio */
    overflow: hidden;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.property-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.property-card:hover .property-img {
    transform: scale(1.05);
}

.property-badges {
    position: absolute;
    top: 1rem;
    left: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    z-index: 2;
}

.badge-premium {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    color: var(--text-dark);
    padding: 0.35rem 0.8rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    font-size: 0.75rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.badge-rent {
    color: var(--primary);
}

.badge-sale {
    color: #10b981;
}

.compare-checkbox-wrapper {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.95) 100%);
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.25), 0 2px 4px rgba(102, 126, 234, 0.1);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 2px solid rgba(102, 126, 234, 0.15);
    backdrop-filter: blur(8px);
}

.compare-checkbox-wrapper:hover {
    transform: scale(1.18);
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.38), 0 4px 8px rgba(102, 126, 234, 0.15);
    border-color: rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(248, 249, 254, 0.98) 100%);
}

.property-details {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.property-price {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-dark);
    margin-bottom: 0.25rem;
}

.property-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-location {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.property-features {
    display: flex;
    gap: 1.25rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.9rem;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* 3. Skeleton Loading State */
.skeleton {
    background: #e2e8f0;
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

.skeleton-card {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    height: 400px;
    background: var(--surface);
}

.skeleton-img {
    height: 210px;
    width: 100%;
}

.skeleton-body {
    padding: 1.25rem;
}

.skeleton-price {
    height: 1.8rem;
    width: 50%;
    margin-bottom: 1rem;
    border-radius: 4px;
}

.skeleton-title {
    height: 1.2rem;
    width: 80%;
    margin-bottom: 0.5rem;
    border-radius: 4px;
}

.skeleton-loc {
    height: 1rem;
    width: 60%;
    margin-bottom: 1.5rem;
    border-radius: 4px;
}

.skeleton-footer {
    height: 2rem;
    width: 100%;
    border-radius: 4px;
}

/* 4. Pinterest Masonry Layout Updates */
#all-listings-container {
    padding: 1.5rem 0 4rem;
    transition: all 0.3s ease;
}

.masonry-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .listings-premium-hero {
        margin-bottom: 0.8rem !important;
    }

    .hero-panel {
        border-radius: 18px;
        padding: 1rem;
    }

    .hero-title {
        font-size: clamp(1.25rem, 6.2vw, 1.72rem);
    }

    .hero-subtitle {
        font-size: 0.92rem;
        line-height: 1.45;
    }

    .hero-stat-grid {
        grid-template-columns: 1fr;
    }

    .premium-tabs-wrap {
        border-radius: 16px;
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        gap: 0.45rem;
        padding: 0.38rem;
    }

    .premium-tabs-wrap::-webkit-scrollbar {
        display: none;
    }

    .premium-tab-btn {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 0.48rem 0.85rem;
        font-size: 0.8rem;
    }

    .kenya-trust-strip {
        gap: 0.35rem;
        margin-top: 0.2rem !important;
    }

    .kenya-trust-pill {
        width: auto;
        max-width: 100%;
        padding: 0.34rem 0.62rem;
        font-size: 0.73rem;
        gap: 0.28rem;
    }

    .kenya-trust-pill i {
        width: 18px;
        height: 18px;
        font-size: 0.62rem;
    }

    .filter-pill {
        min-height: 46px;
        padding: 0.55rem 1rem;
        font-size: 0.9rem;
    }

    .filter-pill input,
    .filter-pill select,
    #listingsFilterSubmit {
        min-height: 46px;
    }

    .masonry-column {
        gap: 1rem;
    }

    #all-listings-container {
        padding: 1rem 0 2rem;
    }

    .filter-scroll-wrapper {
        padding-bottom: 0.8rem;
    }
}

@media (max-width: 576px) {
    .hero-panel {
        padding: 0.85rem;
    }

    .premium-tabs-wrap {
        padding: 0.34rem;
        gap: 0.35rem;
    }

    .premium-tab-btn {
        min-height: 38px;
        font-size: 0.76rem;
        padding: 0.43rem 0.72rem;
    }

    .kenya-trust-strip {
        gap: 0.28rem;
    }

    .kenya-trust-pill {
        font-size: 0.69rem;
        padding: 0.3rem 0.52rem;
    }

    .filter-bar-container {
        top: 0;
        padding: 0.85rem 0;
    }

    #listingsFilterForm {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.75rem;
    }

    .filter-scroll-wrapper {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.55rem;
    }

    .filter-pill {
        width: 100%;
        justify-content: flex-start;
        min-height: 44px;
    }

    .filter-pill input,
    .filter-pill select {
        width: 100% !important;
        min-width: 0;
    }

    #listingsFilterSubmit {
        width: 100%;
        margin-left: 0 !important;
    }

    #sortListings {
        width: 100% !important;
    }

    .container.d-flex.justify-content-between.align-items-center.mb-3 {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }

    #all-listings-container {
        display: block !important;
    }

    .masonry-column {
        width: 100% !important;
        gap: 1rem;
    }

    .listing-pin-card {
        border-radius: 16px !important;
    }

    .listing-pin-card .card-body {
        padding: 0.95rem !important;
    }

    .property-title,
    .property-location-text {
        white-space: normal !important;
        overflow: visible !important;
        text-overflow: unset !important;
    }

    .property-features {
        gap: 0.6rem;
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .feature-item,
    .feature-chip {
        min-width: calc(50% - 0.3rem);
        justify-content: center;
    }

    .compare-checkbox-wrapper {
        top: 0.75rem;
        right: 0.75rem;
        width: 40px;
        height: 40px;
    }

    .compare-toggle-text {
        display: none;
    }

    #compare-action-bar {
        width: calc(100% - 1rem) !important;
        max-width: none;
        padding: 0.8rem 1rem !important;
        border-radius: 16px !important;
    }

    #compare-action-bar .d-flex.align-items-center {
        align-items: flex-start;
    }

    #compare-action-bar .d-flex.gap-2 {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    #compare-action-bar .btn {
        flex: 1 1 48%;
    }
}

.listing-pin-card {
    background: var(--surface);
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-color) !important;
    overflow: hidden;
    position: relative;
    transition: transform 0.3s cubic-bezier(0.165, 0.84, 0.44, 1), box-shadow 0.3s ease !important;
    box-shadow: var(--shadow-sm) !important;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.listing-pin-card:hover {
    transform: translateY(-6px) !important;
    box-shadow: var(--shadow-hover) !important;
}

.listing-pin-card img.lazy {
    opacity: 0;
    transition: opacity 0.4s ease-in;
}

.listing-pin-card img:not(.lazy) {
    opacity: 1;
}

/* Hover effect for compare checkbox */
.compare-checkbox-wrapper {
    opacity: 0.95;
    transform: scale(1);
}

.listing-pin-card:hover .compare-checkbox-wrapper,
.compare-checkbox-wrapper:hover,
.compare-checkbox:checked+.compare-checkbox-wrapper {
    opacity: 1;
    transform: scale(1);
}

.compare-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(13, 110, 253, 0.22);
    border-radius: 999px;
    padding: 0.2rem 0.5rem 0.2rem 0.35rem;
    box-shadow: 0 5px 16px rgba(15, 23, 42, 0.14);
}

.compare-toggle-text {
    font-size: 0.74rem;
    font-weight: 700;
    color: #0d6efd;
    letter-spacing: 0.15px;
}

.listing-favorite-btn {
    position: absolute;
    top: 0.95rem;
    right: 0.95rem;
    z-index: 11;
}

.compare-action-bar {
    border: 1px solid rgba(13, 110, 253, 0.2) !important;
    box-shadow: 0 14px 34px rgba(13, 110, 253, 0.22) !important;
    animation: compareBarPulse 1.8s ease-in-out infinite;
}

.compare-action-bar.show {
    transform: translateX(-50%) translateY(0) !important;
    opacity: 1;
}

@keyframes compareBarPulse {
    0% {
        box-shadow: 0 10px 25px rgba(13, 110, 253, 0.16);
    }
    50% {
        box-shadow: 0 16px 38px rgba(13, 110, 253, 0.28);
    }
    100% {
        box-shadow: 0 10px 25px rgba(13, 110, 253, 0.16);
    }
}

@media (max-width: 768px) {
    .compare-checkbox-wrapper {
        opacity: 1;
        width: 42px;
        height: 42px;
        top: 0.75rem;
        right: 0.75rem;
    }

    .compare-toggle-label {
        padding: 0.22rem 0.45rem 0.22rem 0.32rem;
        gap: 0.3rem;
    }

    .compare-toggle-text {
        font-size: 0.7rem;
    }

    .listing-favorite-btn {
        top: 0.8rem;
        right: 0.8rem;
        width: 42px;
        height: 42px;
    }
}

@media (max-width: 576px) {
    .compare-checkbox-wrapper {
        width: 40px;
        height: 40px;
        top: 0.65rem;
        right: 0.65rem;
    }

    .listing-favorite-btn {
        top: 0.65rem;
        right: 0.65rem;
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    .compare-action-bar {
        width: 90% !important;
        left: 50% !important;
        transform: translateX(-50%) translateY(0) !important;
        bottom: 1.5rem !important;
        padding: 0.75rem 1rem !important;
    }

    .compare-action-bar button {
        font-size: 0.85rem;
        padding: 0.5rem 1rem !important;
    }
}