:root {
    --primary: #1A237E;
    /* Navy Blue */
    --surface: #FFFFFF;
    /* Clean White */
    --muted: #F8FAFC;
    /* Slate-tinged muted */
    --text: #334155;
    /* Slate 700 */
    --accent: #E2E8F0;
    /* Slate 200 */
    --accent-2: #94A3B8;
    /* Slate 400 */
    --muted-text: #475569;
    /* Slate 600 - Darker for better contrast */
    --border-color: #CBD5E1;
    /* Slate 300 */
    /* Light Gray Border */
    --radius: 12px;
    --shadow: 0 6px 30px rgba(0, 0, 0, 0.1);
    --glass: rgba(255, 255, 255, 0.6);
    --speed: 180ms;
    /* Portal Specific Variables */
    --portal-bg: #36454F;
    /* Charcoal */
    --portal-text: #FFFFF0;
    /* Ivory */
    --portal-border: #4F626F;
    /* Slate Gray */
    --portal-active-bg: #4F626F;
    /* Slate Gray */
}

[data-theme="dark"] {
    --primary: #9BA4B5;
    /* Light Slate Blue/Grey for contrast */
    --surface: #0F172A;
    /* Slate 900 */
    --muted: #1E293B;
    /* Slate 800 */
    --text: #F8FAFC;
    /* Slate 50 */
    --accent: #334155;
    /* Slate 700 */
    --accent-2: #475569;
    /* Slate 600 */
    --muted-text: #CBD5E1;
    /* Slate 300 - Lighter for better dark mode contrast */
    --border-color: #334155;
    /* Slate 700 */
}

/* Reset + base */
* {
    box-sizing: border-box
}

html,
body {
    height: 100%
}

body {
    margin: 0;
    font-family: 'Poppins', sans-serif;
    background: var(--muted);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    width: min(1200px, calc(100% - 2rem));
    margin: 2rem auto;
    padding: 0;
    flex: 1;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 700;
    color: var(--primary);
}

h2 {
    margin-top: 0;
    font-size: 2rem;
    text-align: center;
    margin-bottom: 2rem;
}

/* New Navbar Styles */
.navbar {
    padding: 1rem 0;
    transition: all 0.3s ease;
    background-color: var(--surface);
    /* Default background */
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary) !important;
}

.nav-link {
    color: var(--text) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: color 0.3s;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary) !important;
}

/* Sticky Footer Helpers */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1 0 auto;
}

footer {
    flex-shrink: 0;
}


.login-btn,
.register-btn {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.06)
}

.login-btn:hover,
.register-btn:hover {
    background: var(--accent);
}

.owner-btn,
.admin-btn {
    background: var(--accent-2);
    color: #fff;
    padding: 8px 12px;
    border-radius: 10px;
    border: none;
    font-weight: 600
}

.owner-btn:hover,
.admin-btn:hover {
    background: var(--accent)
}

/* HERO */
.hero-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 24px;
    padding: 48px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
    margin: 2rem;
    padding-top: 100px;
    /* Add padding to offset fixed navbar */
}

.hero-content {
    flex: 1;
    min-width: 300px
}

.hero-content h1 {
    font-size: 2.5rem;
    margin: 0 0 16px
}

.hero-content p {
    color: var(--muted-text);
    margin: 0 0 24px;
    font-size: 1.1rem;
    line-height: 1.6;
}

.hero-image img {
    width: 400px;
    border-radius: 14px;
    box-shadow: var(--shadow);
    object-fit: cover
}

@media (max-width: 768px) {
    main {
        width: calc(100% - 1rem);
        margin: 1rem auto;
    }

    .hero-section {
        margin: 1rem;
        padding: 24px 16px 18px;
        padding-top: 88px;
    }

    .hero-content {
        min-width: 0;
        width: 100%;
    }

    .hero-content h1 {
        font-size: 1.9rem;
        line-height: 1.2;
    }

    .hero-image img,
    .feature-card,
    .testimonial-card,
    .auth-box {
        width: 100%;
    }

    .feature-card {
        max-width: 100%;
    }

    .features {
        gap: 14px;
    }

    .listing-card-content,
    .premium-home-ad-content {
        padding: 1rem;
    }

    .footer-newsletter .btn-primary {
        position: static !important;
        width: 100%;
        transform: none !important;
        margin-top: 0.75rem;
    }

    .footer-newsletter .form-control {
        padding-right: 1.25rem;
    }

    .footer-bottom .container {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.5rem;
    }

    .auth-box {
        margin: 1rem;
    }
}

@media (max-width: 576px) {
    .hero-section {
        margin: 0.75rem;
        padding: 18px 14px 16px;
        padding-top: 84px;
    }

    .hero-section h1,
    .hero-content h1 {
        font-size: 1.55rem;
    }

    .hero-image img {
        width: 100%;
        max-width: 100%;
    }

    .feature-card {
        width: 100%;
    }

    .listing-card img {
        height: 180px;
    }

    .testimonials-grid,
    .results-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 991px) {
    .auth-split-layout {
        min-height: auto !important;
        height: auto !important;
        margin-top: 0 !important;
    }

    .auth-split-layout .col-lg-6,
    .auth-split-layout .col-lg-5,
    .auth-split-layout .col-lg-7 {
        min-height: auto;
    }

    .auth-split-layout .d-flex.align-items-center.justify-content-center {
        padding: 1rem 0;
    }

    .auth-split-layout .w-100[style*="max-width: 450px"],
    .auth-split-layout .w-100[style*="max-width: 600px"] {
        max-width: 100% !important;
        padding: 1.25rem !important;
    }

    .auth-split-layout .form-floating .form-control {
        height: 56px !important;
    }

    .auth-split-layout .d-flex.gap-3 {
        flex-direction: column;
    }

    .auth-split-layout .d-flex.gap-3 > .flex-grow-1 {
        width: 100%;
    }
}

.cta-btn {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    padding: 12px 24px;
    border-radius: 10px;
    text-decoration: none;
    transition: background-color var(--speed);
}

.cta-btn:hover {
    background: var(--accent);
}

/* FEATURES */
.features {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    margin: 4rem 0;
    justify-content: center
}

.feature-card {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    width: 300px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04);
    text-align: center;
    transition: all var(--speed) ease-in-out;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.feature-card img {
    width: 56px;
    margin-bottom: 12px
}

/* FEATURED HOMES */
.featured-homes {
    padding: 2rem 0;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.listing-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    /* Softer base shadow */
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.listing-card:hover {
    transform: translateY(-8px);
    /* Higher lift */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
    /* Deeper, wider shadow */
}

/* Specific targeting for new listings grid implementation */
.listing-card-new {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    background: linear-gradient(to bottom, var(--surface) 0%, var(--muted) 100%);
}

.listing-card-new:hover {
    transform: translateY(-8px) scale(1.01);
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15);
    border-color: transparent;
}

.listing-card-new img {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.listing-card-new:hover img {
    transform: scale(1.08);
    /* Slow, elegant zoom */
}

.listing-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.6s ease;
}

.listing-card:hover img {
    transform: scale(1.08);
}

.listing-card-content {
    padding: 1.5rem;
}

.listing-card-content h3 {
    margin-top: 0;
    font-size: 1.5rem;
}

.listing-card-content p {
    margin: 0.5rem 0;
    color: var(--muted-text);
}

/* TESTIMONIALS */
.testimonials {
    padding: 2rem 0;
    background: var(--muted);
}

.testimonials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.testimonial-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.testimonial-card p {
    margin: 0 0 1rem;
    font-style: italic;
    color: var(--muted-text);
}

.testimonial-card span {
    font-weight: 700;
    color: var(--primary);
}

.star-rating-display {
    margin-bottom: 1rem;
}

.star-rating-display .star {
    font-size: 1.2rem;
    color: #ccc;
}

.star-rating-display .star.selected {
    color: #ffc107;
}


/* FOOTER */
footer {
    background: var(--dark-bg, #121212);
    /* Use dark variable from home.css */
    color: var(--secondary-text, #B0B0B0);
    padding: 5rem 2rem 2rem;
    /* Increased top padding */
    margin-top: auto;
    position: relative;
}

footer h5 {
    color: var(--light-text, #FFFFFF);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

footer a {
    color: var(--secondary-text, #E2E8F0);
    /* Brighter base color */
    text-decoration: none;
    transition: color 0.3s ease, padding-left 0.3s ease, text-shadow 0.3s ease;
}

footer a:hover {
    color: var(--primary, #60A5FA);
    padding-left: 5px;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}

footer .text-muted,
footer p.text-muted,
footer p.small {
    color: var(--secondary-text, #E2E8F0) !important;
}

footer .list-unstyled li {
    margin-bottom: 0.75rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 2rem;
    margin-top: 3rem;
}

.social-links a {
    color: var(--secondary-text, #B0B0B0);
    background: var(--surface-bg, #1E1E1E);
    width: 44px;
    /* Larger icon container */
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s;
}

.social-links a:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
}

/* Footer Newsletter */
.footer-newsletter .form-control {
    background: var(--surface-bg, #1E1E1E);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 50px;
    padding: 0.75rem 1.5rem;
    transition: border-color 0.3s;
}

.footer-newsletter .form-control::placeholder {
    color: var(--secondary-text);
}

.footer-newsletter .form-control:focus {
    background: var(--surface-bg, #1E1E1E);
    box-shadow: none;
    border-color: var(--primary);
    color: white;
}

.footer-newsletter .btn-primary {
    border-radius: 50px;
    padding: 0.75rem 2rem;
    font-weight: 600;
    background: var(--primary);
    border-color: var(--primary);
    transition: background-color 0.3s, transform 0.3s;
}

.footer-newsletter .btn-primary:hover {
    background-color: #d76a4d;
    transform: scale(1.05);
}

/* UTILITY */
.sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0
}

.fade-in {
    animation: fadeIn 0.7s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

/* RESPONSIVE */
@media (max-width: 992px) {
    .hero-section {
        flex-direction: column;
        text-align: center;
    }

    .hero-image img {
        width: 80vw;
        max-width: 400px;
        margin-top: 2rem;
    }
}

@media (max-width: 768px) {
    .features {
        flex-direction: column;
        align-items: center;
    }

    .nav-toggle {
        display: inline-block
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--surface);
        padding: 12px;
        border-radius: 0 0 12px 12px;
        flex-direction: column
    }

    .nav-links.open {
        display: flex !important;
    }
}

/* Premium home ads layout */
.premium-home-ads-hero {
    background:
        radial-gradient(circle at 12% 20%, rgba(26, 35, 126, 0.18), transparent 40%),
        radial-gradient(circle at 84% 75%, rgba(251, 146, 60, 0.2), transparent 36%),
        linear-gradient(145deg, #f8fbff 0%, #fff9f0 48%, #ffffff 100%);
    border: 1px solid rgba(30, 41, 59, 0.08);
}

.premium-home-ad-card {
    border-radius: 18px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(30, 41, 59, 0.12);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);
    height: 100%;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.premium-home-ad-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.16);
}

.premium-home-ad-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.premium-home-ad-content {
    padding: 1rem;
}

.premium-home-ad-label {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #0f172a;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.22rem 0.62rem;
    margin-bottom: 0.55rem;
    letter-spacing: 0.03em;
}

.premium-home-ad-hero .premium-home-ad-image {
    height: 200px;
}

.premium-home-ad-hero h5 {
    color: #0f172a;
    font-weight: 800;
}

.premium-home-ad-hero p {
    color: #475569;
    font-size: 0.92rem;
    line-height: 1.45;
}

.premium-home-ad-partner .premium-home-ad-image {
    height: 140px;
}

@media (max-width: 768px) {
    .premium-home-ad-image {
        height: 160px;
    }

    .premium-home-ad-partner .premium-home-ad-image {
        height: 150px;
    }
}

/* AUTH PAGES (Login/Register) */
.auth-container {
    display: flex;
    min-height: 100vh;
    width: 100%;
    align-items: center;
    justify-content: center;
    background-color: var(--muted);
}

.auth-box {
    display: flex;
    width: 100%;
    max-width: 900px;
    margin: 2rem;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.auth-form-container {
    flex: 1;
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-image-container {
    flex: 1;
    display: none;
    /* Hidden on small screens */
}

.auth-image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-form-container .logo {
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-form-container h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-link {
    text-align: center;
    margin-top: 1.5rem;
}

@media (min-width: 768px) {
    .auth-image-container {
        display: block;
    }
}

@media (max-width: 576px) {
    .hero-section {
        padding: 18px
    }

    .hero-image img {
        width: 160px
    }

    h1 {
        font-size: 2rem;
    }
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    z-index: 1000;
    transition: opacity 0.3s, visibility 0.3s;
}

/* Cookie Consent Banner */
.cookie-consent-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--surface);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    display: none;
    /* Hidden by default */
    justify-content: center;
    align-items: center;
    gap: 1rem;
    z-index: 1100;
    flex-wrap: wrap;
}

.cookie-consent-banner p {
    margin: 0;
}

/* New Styles for Features and Location pages */

/* Tab navigation */
.tab-nav {
    border-bottom: 2px solid var(--border-color);
}

.tab-nav .nav-link {
    color: var(--muted-text);
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem 1.5rem;
    border: none;
    border-bottom: 4px solid transparent;
    transition: all 0.3s ease;
}

.tab-nav .nav-link.active,
.tab-nav .nav-link:hover {
    color: var(--primary);
    border-bottom-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Tab content animation */
.tab-pane {
    animation: fadeIn 0.5s ease-in-out;
}

/* Agent cards layout */
.agent-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
}

/* Dashboard / Profile Styles */
.dashboard-sidebar {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    padding: 20px;
}

.dashboard-nav-link {
    display: block;
    padding: 12px 20px;
    color: var(--text);
    border-radius: 10px;
    margin-bottom: 5px;
    transition: all 0.3s;
    text-decoration: none;
    font-weight: 500;
}

.dashboard-nav-link:hover,
.dashboard-nav-link.active {
    background: var(--primary);
    color: #fff;
}

.dashboard-nav-link i {
    width: 25px;
}

/* Favorite Button */
.favorite-btn {
    transition: transform 0.2s;
}

.favorite-btn:hover {
    transform: scale(1.1);
}

/* AI Chat Widget */
#ai-chat-toggle {
    position: fixed;
    bottom: 100px;
    /* Above WhatsApp button */
    right: 30px;
    width: 60px;
    height: 60px;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
}

#ai-chat-widget {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.2);
    z-index: 1050;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

#chat-header {
    background: var(--primary);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chat-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.bot-message {
    background: var(--primary);
    color: white;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.user-message {
    background: #e9ecef;
    color: var(--text);
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

#chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

#chat-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 15px;
    outline: none;
}

#chat-input:focus {
    border-color: var(--primary);
}

/* Home Page */
.hero-search {
    display: flex;
    max-width: 600px;
    margin: 2rem auto 0;
    background-color: var(--surface);
    border-radius: 50px;
    padding: 0.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.hero-search input {
    flex-grow: 1;
    border: none;
    background: transparent;
    padding: 0.5rem 1rem;
    font-size: 1rem;
}

.hero-search input:focus {
    outline: none;
}

.hero-search button {
    border-radius: 50px;
    padding: 0.5rem 2rem;
    font-weight: 600;
}

/* Features Section */
.features-section {
    padding: 5rem 0;
    background-color: #f8f9fa;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    margin-top: 3rem;
}

.feature-card .icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
}