/* W/Site base styles (moved out of base.html so browsers cache them across pages).
 * Per-agency values (colors, hero image) stay inline in base.html. */
/* Prevent horizontal scrolling */
html {
    overflow-x: hidden;
    max-width: 100%;
}

/* Ensure all containers respect viewport width */
.container {
    max-width: 100%;
    overflow-x: hidden;
}

/* Custom scrollbar (shared tokens — page + mobile menu) */
:root {
    --site-scrollbar-size: 8px;
    --site-scrollbar-track: #f1f5f9;
    --site-scrollbar-thumb: #cbd5e1;
    --site-scrollbar-thumb-hover: #94a3b8;
}

html,
#mobile-menu-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--site-scrollbar-thumb) var(--site-scrollbar-track);
}

::-webkit-scrollbar,
#mobile-menu-scroll::-webkit-scrollbar {
    width: var(--site-scrollbar-size);
    height: var(--site-scrollbar-size);
}

::-webkit-scrollbar-track,
#mobile-menu-scroll::-webkit-scrollbar-track {
    background: var(--site-scrollbar-track);
}

::-webkit-scrollbar-thumb,
#mobile-menu-scroll::-webkit-scrollbar-thumb {
    background: var(--site-scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover,
#mobile-menu-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--site-scrollbar-thumb-hover);
}

/* Icon styling to inherit primary color */
svg.icon-svg {
    stroke: var(--primary-color, #2563EB) !important;
    color: var(--primary-color, #2563EB);
}

svg.icon-svg path,
svg.icon-svg polyline,
svg.icon-svg line,
svg.icon-svg circle {
    stroke: var(--primary-color, #2563EB) !important;
}

/* For external image icons - filter will be set by JavaScript */
img.icon-svg {
    /* Filter will be dynamically set by JavaScript */
}

/* Fix dropdown overflow and scrollbar issues */
header {
    overflow: visible !important;
}

header .container {
    overflow: visible !important;
}

/* Categories nav megamenu — full labels, not squeezed by header grid */
#categories-dropdown.categories-dropdown-panel {
    width: max-content;
    min-width: 18rem;
    max-width: min(96vw, 72rem);
}

.categories-dropdown-grid {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 0;
}

.categories-dropdown-column {
    flex: 0 0 auto;
    min-width: 13.5rem;
    max-width: 22rem;
    box-sizing: border-box;
}

.categories-dropdown-column a {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    line-height: 1.4;
    hyphens: auto;
}

.nav-dropdown-title {
    background-color: var(--primary-color, #2563eb);
    color: var(--primary-text-color, #ffffff);
}

.categories-dropdown-links {
    list-style-type: disc;
    list-style-position: outside;
    padding-left: 1.125rem;
}

.categories-dropdown-links li::marker {
    color: var(--primary-color, #2563eb);
}

header nav {
    overflow: visible !important;
}

/* Ensure form containers allow dropdown overflow */
#homepageSearchForm,
#homepageSearchForm .homepage-search-field,
#homepageSearchForm .relative,
#homepageSearchForm .homepage-property-type,
.homepage-search-card,
.homepage-search-wrap {
    overflow: visible !important;
}

/* Ensure hero section containers allow dropdown overflow */
section.hero-background .container,
section.hero-background .max-w-2xl {
    overflow: visible !important;
}

/* Email breaking at @ symbol for mobile (contact page) */
.email-break {
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Allow breaking after @ symbol on mobile - break more naturally */
@media (max-width: 640px) {
    .email-break {
        white-space: normal;
        word-break: break-word;
        /* Allow breaking at @ and dots, but prefer word boundaries */
        overflow-wrap: anywhere;
    }
}

/* Footer email - mobile overflow to screen edge with fade (matches search bar) */
@media (max-width: 768px) {
    footer .container {
        overflow-x: visible;
    }
    
    .footer-email-fade {
        flex: 1;
        min-width: 0;
        overflow: hidden;
        margin-right: calc(50% - 50vw);
        padding-right: calc(50vw - 50%);
        mask-image: linear-gradient(to right, black 90%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
    }
    
    .footer-email-link {
        white-space: nowrap;
        word-break: normal;
        overflow-wrap: normal;
        display: block;
    }
}

/* Dynamic Text Color System
 * 
 * This system automatically adjusts text colors based on the brightness of 
 * primary and secondary background colors. It uses the WCAG relative luminance 
 * formula to determine if a color is light or dark, then applies appropriate 
 * text colors for optimal contrast.
 * 
 * Usage:
 * - text-primary-dynamic: Main text color for primary backgrounds
 * - text-secondary-dynamic: Main text color for secondary backgrounds  
 * - text-primary-muted-dynamic: Muted text color for primary backgrounds
 * - text-secondary-muted-dynamic: Muted text color for secondary backgrounds
 * - text-primary-subtle-dynamic: Subtle text color for primary backgrounds
 * - text-secondary-subtle-dynamic: Subtle text color for secondary backgrounds
 * 
 * Testing:
 * - Open browser console and run: testDynamicColors()
 * - Or manually update: updateDynamicColors('#your-color', '#your-color')
 */
:root {
    --primary-text-color: #ffffff;
    --secondary-text-color: #ffffff;
    --primary-text-muted: #e5e7eb;
    --secondary-text-muted: #e5e7eb;
    --primary-text-subtle: #d1d5db;
    --secondary-text-subtle: #d1d5db;
}

/* Dynamic text color classes */
.text-primary-dynamic {
    color: var(--primary-text-color) !important;
}

.text-secondary-dynamic {
    color: var(--secondary-text-color) !important;
}

.text-primary-muted-dynamic {
    color: var(--primary-text-muted) !important;
}

.text-secondary-muted-dynamic {
    color: var(--secondary-text-muted) !important;
}

.text-primary-subtle-dynamic {
    color: var(--primary-text-subtle) !important;
}

.text-secondary-subtle-dynamic {
    color: var(--secondary-text-subtle) !important;
}

/* Hover states for dynamic colors */
.hover\:text-primary-dynamic:hover {
    color: var(--primary-text-color) !important;
}

.hover\:text-secondary-dynamic:hover {
    color: var(--secondary-text-color) !important;
}

/* Background with dynamic text color classes */
.bg-primary-dynamic {
    background-color: var(--primary-color) !important;
    color: var(--primary-text-color) !important;
}

.bg-secondary-dynamic {
    background-color: var(--secondary-color) !important;
    color: var(--secondary-text-color) !important;
}

/* Border colors for dynamic backgrounds */
.border-primary-dynamic {
    border-color: var(--primary-color) !important;
}

.border-secondary-dynamic {
    border-color: var(--secondary-color) !important;
}

/* Smooth transitions */
* {
    transition: all 0.2s ease-in-out;
}

/* Loading animation */
.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Custom focus styles */
.focus-ring:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Search Input Placeholder - Match Input Text Color */
#searchInput::placeholder {
    color: #1f2937 !important;
    opacity: 1 !important;
}

/* Search Input Placeholder Fade - Mobile Only */
@media (max-width: 768px) {
    #searchInput::placeholder {
        mask-image: linear-gradient(to right, black 90%, transparent 100%);
        -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
    }
}

/* Text styles - gradients removed to respect user color choices */


/* Cozy Hero Background */
.hero-background {
    background-color: var(--primary-color);
    background-image: var(--hero-bg-image);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Hero effects - gradients removed to respect user color choices */
.hero-cozy-glow {
    background: rgba(0, 0, 0, 0.1);
}

/* Cozy text effects */
.hero-text-shadow {
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Warm cozy overlay - simplified */
.hero-warm-overlay {
    background: rgba(0, 0, 0, 0.1);
}

/* Property Carousel Styles */
.property-carousel {
    position: relative;
    overflow: visible;
    margin-bottom: 2rem; /* Space for shadow */
}

/* Two-layer technique for sharp image scaling */
.img-wrapper { 
    position: absolute; 
    inset: 0; 
    overflow: hidden; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
}
.img-wrapper img { 
    min-width: 100%; 
    min-height: 100%; 
    width: auto; 
    height: auto; 
    object-fit: cover; 
}

.carousel-container {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    gap: 1.5rem; /* Reduced gap to show more preview */
}

.carousel-item {
    flex: 0 0 calc(30% - 1rem); /* Smaller cards to show more preview */
    min-width: 0;
    padding: 0.5rem; /* Space for shadow */
}

.carousel-item.preview {
    flex: 0 0 calc(20% - 0.8rem); /* Larger preview area */
    opacity: 0.7;
    transform: scale(0.9);
    transition: all 0.3s ease;
}

.carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.carousel-nav:hover {
    background: #2563eb;
    border-color: #2563eb;
    color: white;
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.carousel-nav.prev {
    left: 10px;
}

.carousel-nav.next {
    right: 10px;
}

.carousel-nav:disabled {
    opacity: 0.3;
    cursor: default;
    transform: translateY(-50%);
}

.carousel-nav:disabled:hover {
    background: white;
    border-color: #e5e7eb;
    color: #6b7280;
    transform: translateY(-50%);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}       

.carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #d1d5db;
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-dot.active {
    background: #2563eb;
    transform: scale(1.2);
}

.carousel-dot:hover {
    background: #9ca3af;
}

/* Mobile responsiveness */
@media (max-width: 1024px) {
    .carousel-item {
        flex: 0 0 calc(45% - 0.6rem); /* 2 items per row on tablet */
    }
    
    .carousel-item.preview {
        flex: 0 0 calc(30% - 0.8rem); /* More preview on tablet */
    }
    
    
    .carousel-nav {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 768px) {
    .carousel-item {
        flex: 0 0 calc(100% - 0.5rem); /* 1 item per row on mobile */
    }
    
    .carousel-item.preview {
        display: none; /* Hide preview on mobile */
    }
    
    
    .carousel-nav {
        width: 40px;
        height: 40px;
    }
    
    .carousel-nav.prev {
        left: 5px;
    }
    
    .carousel-nav.next {
        right: 5px;
    }
}

/* Services Mosaic - Predefined Smart Grid Layouts */
.services-mosaic {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
    grid-auto-rows: 90px;
    width: 100%;
    max-width: 100%;
    overflow: visible;
    padding: 0.75rem 1rem;
}

@media (min-width: 640px) {
    .services-mosaic {
        padding: 0.75rem 1.5rem;
    }
}

@media (min-width: 768px) {
    .services-mosaic {
        padding: 0.75rem 2rem;
    }
}

@media (min-width: 1024px) {
    .services-mosaic {
        padding: 0.75rem 3rem;
    }
}

@media (min-width: 1280px) {
    .services-mosaic {
        padding: 0.75rem 4rem;
    }
}

@media (min-width: 1536px) {
    .services-mosaic {
        padding: 0.75rem 5rem;
    }
}

/* Service Card Background Icons */
.service-card .background-icon {
    position: absolute;
    top: -25%;
    right: -25%;
    width: 200%;
    height: 200%;
    opacity: 0.08;
    transition: opacity 0.3s ease;
    pointer-events: none;
    overflow: hidden;
}

.service-card:hover .background-icon {
    opacity: 0.12;
}

.service-card .background-icon svg {
    width: 100%;
    height: 100%;
    color: white;
}

/* 1 Service: Full banner */
.services-count-1 .service-card:nth-child(1) {
    grid-column: span 6;
    grid-row: span 2;
}

/* 2 Services: Large + Tall mosaic */
.services-count-2 .service-card:nth-child(1) {
    grid-column: span 4;
    grid-row: span 3;
}
.services-count-2 .service-card:nth-child(2) {
    grid-column: span 2;
    grid-row: span 3;
}

/* 3 Services: True mosaic - tall, wide, medium */
.services-count-3 .service-card:nth-child(1) {
    grid-column: span 2;
    grid-row: span 4;
}
.services-count-3 .service-card:nth-child(2) {
    grid-column: span 4;
    grid-row: span 2;
}
.services-count-3 .service-card:nth-child(3) {
    grid-column: span 4;
    grid-row: span 2;
}

/* 4 Services: Narrow square, two stacked rectangles, slightly wider square */
.services-count-4 {
    grid-template-columns: repeat(12, 1fr);
}
.services-count-4 .service-card:nth-child(1) {
    grid-column: 1 / span 4;
    grid-row: 1 / span 4;
}
.services-count-4 .service-card:nth-child(2) {
    grid-column: 5 / span 3;
    grid-row: 1 / span 2;
}
.services-count-4 .service-card:nth-child(3) {
    grid-column: 5 / span 3;
    grid-row: 3 / span 2;
}
.services-count-4 .service-card:nth-child(4) {
    grid-column: 8 / span 5;
    grid-row: 1 / span 4;
}

/* 5 Services: Asymmetric mosaic - 1 tall + 4 grid */
.services-count-5 .service-card:nth-child(1) {
    grid-column: span 2;
    grid-row: span 4;
}
.services-count-5 .service-card:nth-child(2) {
    grid-column: span 2;
    grid-row: span 2;
}
.services-count-5 .service-card:nth-child(3) {
    grid-column: span 2;
    grid-row: span 2;
}
.services-count-5 .service-card:nth-child(4) {
    grid-column: span 2;
    grid-row: span 2;
}
.services-count-5 .service-card:nth-child(5) {
    grid-column: span 2;
    grid-row: span 2;
}

/* Responsive */
@media (max-width: 768px) {
    .services-mosaic {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }
    .service-card {
        grid-column: span 1 !important;
        grid-row: auto !important;
        min-height: 180px;
        height: auto;
    }
    .service-card > .relative.h-full {
        height: auto;
        min-height: 180px;
    }
}

@media (max-width: 1024px) and (min-width: 769px) {
    .services-mosaic {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .services-count-3 .service-card:nth-child(1) {
        grid-column: span 4;
    }
    .services-count-3 .service-card:nth-child(2),
    .services-count-3 .service-card:nth-child(3) {
        grid-column: span 2;
    }
}

/* Popular Places Section Styles */
.popular-places-link {
    transition: all 0.2s ease;
    border-radius: 0.5rem;
}

/* Swiper Custom Styles */
.swiper {
    width: 100%;
    overflow: hidden; /* Prevent horizontal overflow */
}

.swiper-wrapper {
    align-items: stretch; /* Make all slides stretch to same height */
}

/* Ensure all slides have equal height */
.swiper-slide {
    height: auto;
    display: flex;
    align-items: stretch;
    width: 300px; /* Fixed width for consistent partial card display */
    flex-shrink: 0; /* Prevent slides from shrinking */
}

.swiper-slide > * {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Make property cards fill the slide height */
.swiper-slide .bg-white {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.swiper-slide .bg-white > div:last-child {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.swiper-button-next,
.swiper-button-prev {
    color: var(--primary-color);
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    margin-top: -25px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    transform: scale(1);
}

.swiper-button-next:hover,
.swiper-button-prev:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--primary-text-color);
    transform: scale(1.05);
    box-shadow: 0 8px 25px -5px rgba(0, 0, 0, 0.3);
}

.swiper-button-next:after,
.swiper-button-prev:after {
    font-size: 18px;
    font-weight: bold;
}

.swiper-button-disabled {
    opacity: 0 !important;
    cursor: default;
    transform: none !important;
    pointer-events: none !important;
}

.swiper-button-disabled:hover {
    opacity: 0 !important;
    background: white;
    border-color: #e5e7eb;
    color: #6b7280;
    transform: none !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.swiper-pagination-bullet {
    background: #d1d5db;
    width: 12px;
    height: 12px;
    margin: 0 6px;
    transition: all 0.3s ease;
}

.swiper-pagination-bullet-active {
    background: #2563eb;
    transform: scale(1.2);
}

.swiper-pagination-bullet:hover {
    background: #9ca3af;
}

/* Mobile menu — panel below header (menu node is outside header so fixed is viewport-relative) */
#mobile-menu {
    position: fixed;
    top: var(--mobile-menu-top, 4.5rem);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 67;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.88);
    transition: opacity 0.2s ease-out;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border: none;
    overflow: hidden;
}

#mobile-menu.hidden {
    display: none;
}

#mobile-menu-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.5rem 0.75rem;
}

#mobile-menu .mobile-menu-dropdown-toggle {
    -webkit-tap-highlight-color: transparent;
}

#mobile-menu .mobile-menu-dropdown-toggle:hover,
#mobile-menu .mobile-menu-dropdown-toggle:active,
#mobile-menu .mobile-menu-dropdown-toggle:focus {
    background-color: transparent;
    outline: none;
    box-shadow: none;
}

#mobile-menu .mobile-menu-dropdown-toggle:focus-visible {
    outline: 2px solid var(--primary-color, #2563eb);
    outline-offset: 2px;
}

#mobile-menu-footer {
    flex-shrink: 0;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    background: transparent;
}

header.mobile-menu-open {
    transform: translateY(0) !important;
}

/* Autocomplete dropdown styles */
#autocompleteDropdown {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}


/* Ensure the content area doesn't include padding that would affect sticky positioning */
#autocompleteContent {
    padding-bottom: 0;
}

/* Mobile menu item hover effects */
#mobile-menu a:hover {
    transform: translateX(4px);
}

#mobile-menu button:hover:not(.mobile-menu-dropdown-toggle) {
    transform: translateX(4px);
}

#mobile-menu .mobile-menu-dropdown-toggle,
#mobile-menu .mobile-menu-dropdown-toggle:hover,
#mobile-menu .mobile-menu-dropdown-toggle:active {
    transform: none;
}

/* Smooth transitions for mobile menu items */
#mobile-menu a,
#mobile-menu button {
    transition: all 0.2s ease-in-out;
}

#mobile-menu .mobile-menu-dropdown-toggle {
    transition: color 0.2s ease-in-out;
}

/* Mobile responsiveness */
@media (max-width: 1024px) {
    .swiper-slide {
        width: 280px; /* Smaller cards on tablet */
    }

    .swiper-button-next,
    .swiper-button-prev {
        width: 45px;
        height: 45px;
        margin-top: -22.5px;
    }
}

@media (max-width: 768px) {
    .swiper-slide {
        width: 260px; /* Even smaller cards on mobile */
    }

    .swiper-button-next,
    .swiper-button-prev {
        width: 40px;
        height: 40px;
        margin-top: -20px;
    }
}

@media (max-width: 480px) {
    .swiper-slide {
        width: 240px; /* Smallest cards on very small screens */
    }
}

/* Floating WhatsApp Button Styles */
#whatsapp-float {
    animation: bounce-gentle 3s infinite;
}

#whatsapp-float button,
#whatsapp-float a {
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

#whatsapp-float button:hover,
#whatsapp-float a:hover {
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.4);
}

/* Mobile responsiveness for WhatsApp button */
@media (max-width: 768px) {
    #whatsapp-float {
        bottom: 1rem;
        right: 1rem;
    }
}

/* Enhanced mobile responsiveness */
@media (max-width: 640px) {
    /* Hero section adjustments for mobile (non-homepage heroes) */
    .hero-background:not(.homepage-hero) {
        padding: 3rem 0;
    }

    /* Better mobile spacing */
    .container:not(section.hero-background.homepage-hero > .container) {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Mobile navigation improvements */
    .mobile-menu-item {
        padding: 0.75rem 1rem;
        font-size: 1rem;
    }

    /* Touch-friendly buttons */
    button, .btn {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better text readability on mobile */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* Prevent text selection on buttons and clickable elements */
    button,
    .btn,
    [role="button"],
    [type="button"],
    [type="submit"],
    [type="reset"],
    a.button,
    .clickable,
    [onclick],
    .property-carousel-prev,
    .property-carousel-next,
    .custom-sort-button,
    .custom-sort-option {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* Improved tap targets */
    a, button {
        touch-action: manipulation;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .hero-background:not(.homepage-hero) {
        padding: 2rem 0;
    }

    /* Compact spacing for very small screens */
    .container:not(section.hero-background.homepage-hero > .container) {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}
.custom-sort-dropdown {
    position: relative;
    display: inline-block;
}

.custom-sort-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    padding: 0;
    font-size: 0.875rem;
    color: var(--primary-color, #3b82f6);
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.custom-sort-button:hover {
    opacity: 0.8;
}

.custom-sort-label {
    white-space: nowrap;
}

.custom-sort-icon {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s ease;
}

.custom-sort-dropdown.open .custom-sort-icon {
    transform: rotate(180deg);
}

.custom-sort-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 180px;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    display: none;
    z-index: 50;
    animation: slideDown 0.2s ease-out;
}

.custom-sort-dropdown.open .custom-sort-menu {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-0.5rem);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.custom-sort-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #4b5563;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 0.25rem;
}

.custom-sort-option:last-child {
    margin-bottom: 0;
}

.custom-sort-option:hover {
    background: #f3f4f6;
    color: #111827;
}

.custom-sort-option.active {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--primary-color, #3b82f6);
    font-weight: 600;
}

.custom-sort-check {
    width: 1rem;
    height: 1rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.custom-sort-option.active .custom-sort-check {
    opacity: 1;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .custom-sort-button {
        font-size: 0.8125rem;
    }
    
    .custom-sort-menu {
        min-width: 160px;
    }
    
    .custom-sort-option {
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.125rem;
    }
}

/* Custom Transaction Dropdown Styles */
.custom-transaction-dropdown {
    position: relative;
    display: inline-block;
}

.custom-transaction-button {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    padding-right: 0.625rem;
    font-size: 1rem;
    font-weight: 500;
    color: #111827;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 210px;
}

.custom-transaction-button:hover {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-transaction-button:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-transaction-label {
    white-space: nowrap;
    color: var(--primary-color, #3b82f6);
}

.custom-transaction-icon {
    width: 1rem;
    height: 1rem;
    transition: transform 0.2s ease;
    color: #9ca3af;
}

.custom-transaction-dropdown.open .custom-transaction-icon {
    transform: rotate(180deg);
}

.custom-transaction-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 4px 10px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    display: none;
    z-index: 50;
    animation: slideDown 0.2s ease-out;
}

.custom-transaction-dropdown.open .custom-transaction-menu {
    display: block;
}

.custom-transaction-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: transparent;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    color: #4b5563;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 0.25rem;
}

.custom-transaction-option:last-child {
    margin-bottom: 0;
}

.custom-transaction-option:hover {
    background: #f3f4f6;
    color: #111827;
}

.custom-transaction-option.active {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--primary-color, #3b82f6);
    font-weight: 600;
}

.custom-transaction-check {
    width: 1rem;
    height: 1rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.custom-transaction-option.active .custom-transaction-check {
    opacity: 1;
}

.custom-transaction-dropdown.transaction-locked .custom-transaction-button {
    cursor: default;
    pointer-events: none;
}

.custom-transaction-dropdown.transaction-locked .custom-transaction-button:hover,
.custom-transaction-dropdown.transaction-locked .custom-transaction-button:focus {
    border-color: #d1d5db;
    box-shadow: none;
}

/* Homepage search — VivaReal-style card */
.homepage-search-card {
    background: #ffffff;
    border-radius: 1rem;
    padding: 1.5rem 1.25rem;
    box-shadow:
        0 1px 2px rgba(0, 0, 0, 0.06),
        0 2px 6px rgba(0, 0, 0, 0.08),
        0 6px 14px rgba(0, 0, 0, 0.07);
}

@media (min-width: 640px) {
    .homepage-search-card {
        padding: 1.75rem 2rem;
    }
}

/* Homepage hero — mobile: fixed image band + card overlaps bottom 10% */
@media (max-width: 639px) {
    section.hero-background.homepage-hero {
        --hero-scene-height: min(52vw, 280px);
        --hero-card-overlap: 2.15rem;
        display: block;
        height: var(--hero-scene-height);
        min-height: 0;
        background-image: none;
        background-color: transparent;
        padding: 0 !important;
        overflow: visible;
    }

    section.hero-background.homepage-hero::before {
        content: '';
        position: absolute;
        inset: 0;
        background-image: var(--hero-bg-image);
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        z-index: 0;
    }

    section.hero-background.homepage-hero > .absolute.inset-0,
    section.hero-background.homepage-hero > .absolute.top-0 {
        display: none;
    }

    /* Collapse in-flow wrappers; position card relative to hero section */
    section.hero-background.homepage-hero > .container {
        height: 0;
        padding: 0 !important;
        margin: 0;
        overflow: visible;
    }

    section.hero-background.homepage-hero > .container > .max-w-2xl {
        height: 0;
        overflow: visible;
    }

    section.hero-background.homepage-hero .homepage-search-wrap {
        position: absolute;
        left: 0.375rem;
        right: 0.375rem;
        top: calc(var(--hero-scene-height) - var(--hero-card-overlap));
        z-index: 10;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Reserve space for card spill before JS measures (avoids carousel jump) */
    main.homepage-main > .homepage-content {
        padding-top: var(--homepage-content-spill, 21rem) !important;
    }
}

@media (max-width: 480px) {
    section.hero-background.homepage-hero {
        --hero-scene-height: min(50vw, 240px);
    }
}

@media (min-width: 640px) {
    section.hero-background.homepage-hero::before {
        display: none;
    }

    section.hero-background.homepage-hero {
        height: auto;
        background-image: var(--hero-bg-image);
        background-color: var(--primary-color);
    }

    section.hero-background.homepage-hero .homepage-search-wrap {
        position: static;
        left: auto;
        right: auto;
        top: auto;
        opacity: 1;
        visibility: visible;
    }
}

.homepage-search-card-title {
    line-height: 1.25;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .homepage-search-card-title {
        margin-bottom: 1.5rem;
    }
}

.homepage-tx-switch {
    display: flex;
    align-items: center;
    gap: 1.75rem;
    margin-bottom: 1.5rem;
}

.homepage-tx-slot {
    flex: 0 0 auto;
}

.homepage-tx-option {
    appearance: none;
    -webkit-appearance: none;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.375rem 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    color: #6b7280;
    cursor: pointer;
    transition: color 0.2s ease, border-color 0.2s ease;
    user-select: none;
}

@media (min-width: 640px) {
    .homepage-tx-option {
        font-size: 1.125rem;
    }
}

.homepage-tx-option:hover {
    color: #374151;
}

.homepage-tx-option.active {
    color: var(--primary-color, #2563eb);
    border-bottom-color: var(--primary-color, #2563eb);
}

.homepage-tx-switch--single .homepage-tx-option,
.homepage-tx-switch--single .homepage-tx-option:hover {
    color: var(--primary-color, #2563eb);
    border-bottom-color: var(--primary-color, #2563eb);
    cursor: default;
    pointer-events: none;
}

.homepage-search-field-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

@media (min-width: 640px) {
    .homepage-search-field-label {
        font-size: 1rem;
    }
}

.homepage-search-field {
    position: relative;
    margin-bottom: 1.25rem;
}

.homepage-search-field:last-child {
    margin-bottom: 0;
}

.homepage-search-field-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #1f2937;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.homepage-search-field-input--with-chevron {
    padding-left: 2.75rem;
}

@media (min-width: 640px) {
    .homepage-search-field-input {
        padding: 1rem 1.25rem;
        font-size: 1.125rem;
    }

    .homepage-search-field-input--with-chevron {
        padding-left: 3rem;
    }
}

.homepage-search-field-input::placeholder {
    color: #6b7280;
}

.homepage-search-field-input:focus {
    outline: none;
    border-color: var(--primary-color, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

#homepageSearchForm #searchInput.homepage-search-field-input {
    color: #1f2937 !important;
}

#homepageSearchForm #searchInput.homepage-search-field-input::placeholder {
    color: #6b7280 !important;
    opacity: 1 !important;
    mask-image: none !important;
    -webkit-mask-image: none !important;
}

#homepagePlaceField.has-selection #searchInput.homepage-search-field-input::placeholder {
    color: #1f2937 !important;
    opacity: 1 !important;
}

.homepage-field-with-chevron {
    position: relative;
}

.homepage-field-with-chevron.open .homepage-field-chevron {
    transform: translateY(-50%) rotate(180deg);
}

.homepage-field-chevron {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: #9ca3af;
    pointer-events: none;
    transition: transform 0.2s ease;
    z-index: 1;
}

@media (min-width: 640px) {
    .homepage-field-chevron {
        left: 1.25rem;
    }
}

.homepage-property-type-trigger {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.homepage-property-type-label-wrap {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #6b7280;
}

.homepage-property-type-trigger.has-selection .homepage-property-type-label-wrap {
    color: #1f2937;
}

.homepage-property-type {
    position: relative;
}

.homepage-property-type-menu {
    position: absolute;
    top: calc(100% + 0.375rem);
    left: 0;
    right: 0;
    max-height: 20rem;
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    padding: 0.375rem;
    z-index: 70;
}

.homepage-property-type-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    margin-bottom: 0.25rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}

.homepage-property-type-option:last-child {
    margin-bottom: 0;
}

.homepage-property-type-option:hover {
    background: #f9fafb;
}

.homepage-property-type-option.selected {
    background: #eff6ff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.homepage-property-type-option input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary-color, #2563eb);
    flex-shrink: 0;
    pointer-events: none;
}

.homepage-property-type-option span {
    font-size: 1rem;
    font-weight: 500;
    color: #1f2937;
    line-height: 1.25;
}

.homepage-search-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    margin-top: 0.5rem;
    padding: 1rem 1.25rem;
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--primary-dynamic, #ffffff);
    background: var(--primary-color, #2563eb);
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.15s ease;
}

.homepage-search-submit-btn:hover {
    background: color-mix(in srgb, var(--primary-color, #2563eb) 90%, black);
    transform: scale(1.01);
}

/* Mobile adjustments for transaction dropdown */
@media (max-width: 768px) {
    .custom-transaction-button {
        font-size: 0.875rem;
        padding: 0.625rem 0.875rem;
        padding-right: 0.5rem;
        width: 185px;
    }
    
    .custom-transaction-option {
        font-size: 0.8125rem;
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.125rem;
    }
}

/* Saved Properties Remove Button Hover */
@media (min-width: 1024px) {
    .saved-property-card.group:hover .saved-property-remove-btn {
        opacity: 1 !important;
    }
}
