@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;500;700;800&display=swap');

:root {
    --primary-color: #4318FF;
    /* Vibrant Blue */
    --secondary-color: #2B3674;
    /* Dark Navy */
    --accent-color: #FFC107;
    /* Amber */
    --background-color: #F4F7FE;
    /* Soft App BG */
    --text-color: #707EAE;
    /* Soft Grey */
    --heading-color: #1B2559;
    /* Deep Navy */
    --card-bg: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --border-radius: 20px;
    --font-family: 'Tajawal', sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #4318FF;
        /* Keep brand color */
        --background-color: #111C44;
        --text-color: #A3AED0;
        --heading-color: #FFFFFF;
        --card-bg: #1B254B;
        --glass-bg: rgba(27, 37, 75, 0.9);
        --glass-border: rgba(255, 255, 255, 0.05);
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--heading-color);
    font-weight: 700;
}

/* Header */
.main-header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.logo h1 {
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 800;
}

nav {
    display: flex;
    gap: 1.5rem;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    transition: color 0.3s;
}

nav a:hover {
    color: var(--primary-color);
}

/* Hero Section */
.hero {
    background: linear-gradient(135deg, var(--primary-color), #6610f2);
    color: white;
    padding: 2.5rem 1rem;
    /* Compact padding */
    text-align: center;
    border-radius: 0 0 24px 24px;
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.hero p {
    font-size: 1rem;
    margin-bottom: 1.5rem;
    opacity: 0.9;
}

/* Compact Search Bar */
/* HERO & LUXURY SEARCH SYSTEM */
.hero {
    background: linear-gradient(135deg, #1b2559 0%, #4318FF 100%);
    color: white;
    padding: 3rem 1rem;
    text-align: center;
    border-radius: 0 0 40px 40px;
    margin-bottom: 3rem;
    box-shadow: 0 10px 40px rgba(67, 24, 255, 0.2);
}

.search-bar {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    width: 100%;
}

.search-capsule {
    background: white;
    display: grid;
    /* Desktop Layout: Keyword (40%) | Div | Category (25%) | Div | Location (25%) | Button (Auto) */
    grid-template-columns: 4fr min-content 3fr min-content 3fr auto;
    /* Using ratio fr is safer than hard % matches */
    align-items: center;
    padding: 8px;
    border-radius: 60px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12);
    width: 100%;
    max-width: 950px;
    border: 1px solid rgba(0, 0, 0, 0.02);
    box-sizing: border-box;
    /* Ensure padding doesn't break math */
}

/* Ensure Helper is hidden */
.mobile-search-real {
    display: none !important;
}

.search-item {
    display: flex;
    align-items: center;
    padding: 0 15px;
    position: relative;
    height: 100%;
}

.search-icon {
    font-size: 1.2rem;
    opacity: 0.5;
    margin-left: 10px;
}

.luxury-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    background: transparent;
    height: 48px;
    font-family: var(--font-family);
    min-width: 0;
    /* Important for grid/flex shrinking */
}

.divider {
    width: 1px;
    height: 32px;
    background: #e0e0e0;
}

.search-btn-luxury {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0 35px;
    /* Use padding for width */
    height: 50px;
    /* Match input height + padding adjustment */
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 5px 15px rgba(67, 24, 255, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.search-btn-luxury:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(67, 24, 255, 0.4);
}

/* Mobile Search Trigger */
/* Mobile Real Search Visibility */
.mobile-search-real {
    display: none;
    /* Hide on Desktop */
}

.desktop-only-hide {
    display: none;
    /* Helpers */
}

@media (max-width: 992px) {
    .desktop-only-hide {
        display: block !important;
    }
}

/* Legacy trigger style removal or reuse */
.mobile-search-trigger {
    display: none;
}

/* Mobile Overrides */
@media (max-width: 992px) {

    /* Hide the huge desktop form items */
    .search-capsule .search-item,
    .search-capsule .divider,
    .search-capsule .search-btn-luxury {
        display: none !important;
    }

    /* Show the compact trigger */
    .mobile-search-trigger {
        display: flex !important;
    }

    /* Reset Capsule Container to be minimal */
    .search-capsule {
        display: block !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0 !important;
        border: none !important;
    }

    /* Make Hero Compact */
    .hero {
        padding: 6rem 1rem 2rem 1rem !important;
        /* Keep top padding for header */
        min-height: auto !important;
        margin-bottom: 1rem !important;
    }

    .hero h1 {
        font-size: 1.5rem;
        /* Smaller Font */
    }
}

/* Categories (Chips) */
.categories-container {
    padding: 0 1rem;
    display: flex;
    gap: 0.8rem;
    /* Tighter gap */
    overflow-x: auto;
    padding-bottom: 1rem;
    justify-content: center;
    /* Center on desktop */
}

.category-chip {
    background: white;
    padding: 0.5rem 1.2rem;
    /* Compact chips */
    border-radius: 50px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    font-weight: 600;
    color: #555;
    font-size: 0.85rem;
}

/* Property Grid */
.property-grid {
    display: grid;
    /* Increase min-width to prevent huge cards, fit more columns */
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
    /* Reduced gap */
    padding: 1rem 2rem;
    max-width: 1300px;
    margin: 0 auto;
}

.property-card {
    background: white;
    border-radius: 20px;
    /* Softer rounded corners */
    overflow: hidden;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
    /* Modern Soft Shadow */
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.property-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

.card-image-container {
    position: relative;
    width: 100%;
}

.card-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    color: #1b2559;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 800;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

.card-content {
    padding: 1.2rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.price {
    color: #0088cc;
    font-size: 1.4rem;
    /* Large Price */
    font-weight: 900;
    line-height: 1;
}

.currency {
    font-size: 0.8rem;
    font-weight: 600;
    color: #777;
    margin-right: 2px;
}

.title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.location {
    color: #888;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 12px;
}

.features-row {
    display: flex;
    gap: 15px;
    color: #555;
    font-size: 0.9rem;
    font-weight: 500;
    padding-top: 12px;
    border-top: 1px solid #f0f0f0;
}

/* Floating Action Button (for PWA add) */
/* Floating Action Button (for PWA add) */
.fab {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    /* RTL layout */
    background: var(--accent-color);
    color: #000;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 900;
}

/* Footer Styling */
.main-footer {
    background: #2c3e50;
    color: white;
    margin-top: 4rem;
    padding-top: 3rem;
}

.footer-content {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    padding: 0 2rem 2rem;
}

.footer-section h3 {
    color: var(--accent-color);
    margin-bottom: 1.2rem;
    font-size: 1.2rem;
}

.footer-section p {
    color: #bdc3c7;
    line-height: 1.6;
    font-size: 0.95rem;
}

.footer-section ul {
    list-style: none;
    padding: 0;
}

.footer-section ul li {
    margin-bottom: 0.8rem;
}

.footer-section ul li a {
    color: #bdc3c7;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-section ul li a:hover {
    color: white;
    padding-right: 5px;
    /* Subtle hover effect */
}

.social-links {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
}

.social-links a {
    color: white;
    text-decoration: none;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.5rem 1rem;
    border-radius: 50px;
}

.footer-bottom {
    background: #1a252f;
    text-align: center;
    padding: 1.5rem;
    color: #7f8c8d;
    font-size: 0.9rem;
    margin-top: 1rem;
}

/* Header Search Visibility */
.header-search-container {
    display: none;
    /* Hidden on mobile default */
}

@media (min-width: 993px) {
    .header-search-container {
        display: block !important;
    }
}

/* Mobile Responsive Overrides */
.nav-fab,
.mobile-nav-bar,
.header-fab-trigger,
.mobile-drawer,
.mobile-drawer-overlay {
    display: none;
}

/* Default Hidden (Desktop) */

@media (max-width: 992px) {

    /* Header Stacking */
    /* Header Stacking */
    .main-header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }

    /* Hide Desktop Nav on Mobile */
    .main-header nav {
        display: none !important;
    }

    /* MODERN DRAWER STYLES */

    /* 1. Trigger Button (Top Left) */
    /* 1. Trigger Button (Top Right) */
    .header-fab-trigger {
        display: flex !important;
        position: fixed;
        top: 25px;
        right: 20px;
        /* Switch to Right */
        left: auto;
        width: 45px;
        height: 45px;
        background: white;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        align-items: center;
        justify-content: center;
        z-index: 3000;
        cursor: pointer;
        border: 1px solid #f0f0f0;
        transition: transform 0.2s, background 0.2s;
        color: #333;
    }

    .header-fab-trigger:active {
        transform: scale(0.95);
        background: #f8f9fa;
    }

    .header-fab-trigger span {
        line-height: 1;
    }

    /* 2. Overlay (Dim Background) */
    .mobile-drawer-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 3001;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .mobile-drawer-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    /* 3. Drawer (The Menu - From Right) */
    .mobile-drawer {
        position: fixed;
        top: 0;
        right: 0;
        /* Anchor Right */
        left: auto;
        bottom: 0;
        width: 80%;
        max-width: 300px;
        background: white;
        z-index: 3002;
        transform: translate3d(100%, 0, 0);
        /* Start Right hidden */
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        box-shadow: -5px 0 25px rgba(0, 0, 0, 0.15);
        /* Shadow on Left */
    }

    .mobile-drawer.active {
        transform: translate3d(0, 0, 0);
    }

    /* Drawer Internal Layout */
    .drawer-header {
        padding: 25px 20px;
        background: #f8f9fa;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid #eee;
    }

    .drawer-header h3 {
        margin: 0;
        font-size: 1.2rem;
        color: var(--primary-color);
        font-weight: 800;
    }

    .close-drawer-btn {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: #888;
        cursor: pointer;
        padding: 5px;
    }

    .drawer-content {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .drawer-item {
        display: flex;
        align-items: center;
        padding: 15px;
        border-radius: 12px;
        text-decoration: none;
        color: #333;
        font-weight: 600;
        transition: background 0.2s;
    }

    .drawer-item:active {
        background: #f0f2f5;
    }

    .drawer-item .icon {
        font-size: 1.4rem;
        margin-left: 15px;
        width: 30px;
        text-align: center;
    }

    .drawer-item .text {
        flex: 1;
        font-size: 1rem;
    }

    .drawer-item .arrow {
        color: #ccc;
        font-size: 1.2rem;
    }

    .drawer-divider {
        height: 1px;
        background: #eee;
        margin: 10px 0;
    }

    .drawer-item.highlight {
        background: #eff4fb;
        color: var(--primary-color);
    }

    .drawer-footer {
        padding: 20px;
        text-align: center;
        font-size: 0.8rem;
        color: #aaa;
        border-top: 1px solid #eee;
    }
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #1b2559;
    font-size: 0.75rem;
    font-weight: 700;
    gap: 4px;
    min-width: 50px;
}

.mobile-nav-item span {
    font-size: 1.4rem;
    background: transparent;
    width: auto;
    height: auto;
    box-shadow: none;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #333;
    font-size: 0.8rem;
    font-weight: bold;
    gap: 5px;
    min-width: 60px;
}

.mobile-nav-item span {
    font-size: 1.4rem;
}

/* Hero Section */
.hero {
    padding: 3rem 1.5rem;
    border-radius: 0 0 30px 30px;
    text-align: center;
}

.hero h1 {
    font-size: 1.8rem;
    line-height: 1.3;
}

/* Search Bar Mobile */
.search-bar {
    flex-direction: column;
    padding: 1.5rem;
    gap: 15px;
    border-radius: 20px !important;
    /* Rounded container */
    background: rgba(255, 255, 255, 0.95);
    margin-top: 20px;
}

.search-bar input,
.search-bar select,
.search-bar button {
    width: 100% !important;
    height: 55px !important;
    margin: 0 !important;
    border-radius: 12px !important;
    font-size: 1rem;
    text-align: center;
}

.search-bar .search-btn {
    background: var(--accent-color) !important;
    color: #000 !important;
    font-weight: 800;
    box-shadow: 0 4px 15px rgba(255, 193, 7, 0.4);
}

/* Grid layout - Ensure single column */
.property-grid {
    grid-template-columns: 1fr;
    /* Force single column */
    gap: 1.5rem;
    padding: 1rem;
}

/* Categories */
.categories-container {
    padding: 0 1rem;
    padding-bottom: 10px;
}

.category-chip {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
}

/* Mobile Form Optimizations */
form input[type="text"],
form input[type="email"],
form input[type="password"],
form input[type="number"],
form input[type="tel"],
form select,
form textarea {
    width: 100%;
    height: 50px;
    /* Touch friendly */
    font-size: 16px;
    /* Stop iOS Zoom */
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 10px;
    border: 1px solid #ddd;
}

form textarea {
    height: 120px;
    padding-top: 15px;
}

form label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #444;
}

.input-group {
    display: block;
    width: 100%;
    margin-bottom: 15px;
}

button[type="submit"] {
    width: 100%;
    height: 55px;
    font-size: 1.1rem;
    border-radius: 50px;
}

/* Mobile Filter Logic */
.desktop-filters {
    display: none !important;
}

.filter-btn-mobile {
    display: block !important;
}

/* Bottom Sheet Styles */
.filter-btn-mobile {
    display: none;
    background: #f0f2f5;
    border: none;
    border-radius: 50px;
    padding: 0 20px;
    cursor: pointer;
    font-weight: bold;
    color: #333;
}

.bottom-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: none;
    align-items: flex-end;
}

.bottom-sheet {
    background: white;
    width: 100%;
    border-radius: 20px 20px 0 0;
    padding: 20px;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.2);
    animation: slideUpSheet 0.3s ease-out;
    max-height: 85vh;
    overflow-y: auto;
}

@keyframes slideUpSheet {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
}

.sheet-header h3 {
    margin: 0;
}

.close-sheet {
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.sheet-body label {
    display: block;
    margin: 15px 0 8px;
    font-weight: bold;
    color: #333;
}

.chip-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 8px 16px;
    background: #f0f2f5;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    border: 1px solid transparent;
}

/* Performance Optimizations */
.listings-section,
.main-footer {
    content-visibility: auto;
    contain-intrinsic-size: 1000px;
}

html {
    scroll-behavior: smooth;
}

.sheet-footer {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.sheet-footer button {
    flex: 1;
    padding: 15px;
    border-radius: 12px;
    border: none;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}

.apply-btn {
    background: #0088cc;
    color: white;
}

.reset-btn {
    background: #f0f2f5;
    color: #333;
}

.aspect-ratio-box {
    position: relative;
    width: 100%;
    background-color: #f4f4f4;
    overflow: hidden;
    aspect-ratio: 4/3;
}

.aspect-ratio-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Header Redesign */
.main-header.glass-header {
    background: rgba(255, 255, 255, 0.85) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.04);
    height: 90px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.6);
}

.header-container {
    max-width: 1400px;
    height: 100%;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    transition: transform 0.3s ease;
}

.brand-logo {
    height: 55px;
    width: auto;
}

.brand-name {
    font-family: 'Tajawal', sans-serif;
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--heading-color);
}

.header-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(240, 242, 245, 0.6);
    padding: 8px 10px;
    border-radius: 50px;
}

.nav-link {
    font-family: 'Tajawal', sans-serif;
    color: var(--text-color);
    font-weight: 600;
    padding: 10px 24px;
    border-radius: 30px;
    transition: all 0.3s;
}

.nav-link:hover {
    color: var(--primary-color);
    background: white;
}

/* --- MOBILE SEARCH DRAWER --- */
.mobile-search-trigger {
    display: none;
    width: 100%;
    background: white;
    padding: 15px 20px;
    border-radius: 50px;
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #333;
    font-size: 1.1rem;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.search-drawer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 10000;
    display: none;
    flex-direction: column;
    padding: 20px;
}

.search-drawer.active {
    display: flex;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
}

.drawer-input-group {
    margin-bottom: 20px;
}

.drawer-input-group label {
    display: block;
    font-weight: 700;
    color: var(--heading-color);
    margin-bottom: 8px;
}

.drawer-select,
.drawer-input {
    width: 100%;
    padding: 15px;
    border-radius: 12px;
    border: 1px solid #eee;
    background: #f8f9fa;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}

@media (max-width: 992px) {
    .header-center {
        display: none !important;
    }

    .header-container {
        padding: 0 1.5rem;
    }

    .brand-name {
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .advanced-search {
        display: none !important;
    }

    .mobile-search-trigger {
        display: flex;
    }

    .hero {
        padding: 2rem 1rem 4rem;
        border-radius: 0 0 30px 30px;
    }

    .hero h1 {
        font-size: 2rem !important;
    }

    .property-grid {
        grid-template-columns: 1fr;
    }

    body {
        padding-bottom: 70px;
    }
}