/* Responsive Design for UrbanHomes */

/* --- Standard Laptop (max-width: 1440px) --- */
@media (max-width: 1440px) {

    /* Global Layout Compactness */
    .app-container {
        max-width: 100vw;
        overflow-x: hidden;
    }

    .main-content {
        padding: 10px 15px 20px 15px !important;
        /* Tighter padding */
    }

    .sidebar {
        width: 210px !important;
        /* Compact sidebar */
    }

    .topbar {
        height: 60px !important;
        /* Very compact topbar */
        padding: 0 15px !important;
    }

    .avatar {
        width: 35px !important;
        height: 35px !important;
    }

    /* Typography Scaling */
    .hero-title {
        font-size: 55px !important;
    }

    h2,
    .page-title h2 {
        font-size: 26px !important;
    }

    h3 {
        font-size: 16px !important;
    }

    p,
    .hero-desc {
        font-size: 13px !important;
    }

    /* Component Compacting */
    .card,
    .stat-card,
    .dashboard-section {
        padding: 15px !important;
        /* Reduced from 24px */
    }

    .stat-value {
        font-size: 1.5rem !important;
        /* Reduced from 1.875rem */
    }

    .stat-icon-wrapper {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }

    /* Landing Page Specifics */
    .landing-nav,
    .hero-section,
    .account-type-container,
    .auth-nav,
    .section-header,
    .features-section,
    .cta-section,
    .subscription-container,
    .main-footer {
        padding-left: 40px !important;
        padding-right: 40px !important;
    }

    .login-form-container {
        padding: 30px !important;
    }

    .account-type-container {
        margin: 20px auto !important;
        padding: 0 40px !important;
    }

    /* Reduce gaps in grids */
    .grid-4,
    .grid-3,
    .grid-2,
    .stats-grid {
        gap: 15px !important;
    }
}

/* --- Tablet & Small Desktop (max-width: 1024px) --- */
@media (max-width: 1024px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-2 {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rent-grid-top,
    .rent-grid-bottom {
        grid-template-columns: 1fr !important;
    }
}

/* --- Dashboard Mobile (max-width: 768px) --- */
@media (max-width: 768px) {

    /* Layout Reset */
    .app-container {
        flex-direction: column;
    }

    /* Fixed Sidebar for Mobile */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 1000;
        transition: left 0.3s ease-in-out;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.1);
        height: 100vh;
        overflow-y: auto;
    }

    .sidebar.open {
        left: 0;
    }

    .close-sidebar-btn {
        display: block !important;
    }

    /* Sidebar Overlay */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        backdrop-filter: blur(2px);
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Main Content Adjustments */
    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 0;
    }

    .content-wrapper {
        padding: 15px;
    }

    /* Topbar Adjustments */
    .topbar {
        padding: 0 15px !important;
        height: 60px !important;
    }

    .mobile-toggle {
        display: block !important;
    }

    .dashboard-welcome {
        display: none;
    }

    .topbar-search {
        display: none;
    }

    .hide-mobile {
        display: none !important;
    }

    .topbar-actions {
        margin-left: auto;
        gap: 10px;
    }

    .btn-icon {
        width: 35px;
        height: 35px;
    }

    /* Grids & Cards */
    .grid-3,
    .grid-2,
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        display: block;
        width: 100%;
        overflow-x: auto;
        white-space: nowrap;
    }

    .card {
        overflow: hidden;
    }

    /* Modals */
    .modal-content,
    .modal-box {
        width: 95% !important;
        max-width: 95% !important;
        margin: 10px auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Forms */
    .form-group {
        margin-bottom: 15px;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-bar .search-box,
    .filter-bar select,
    .filter-bar button {
        width: 100%;
        margin-bottom: 10px;
    }

    /* Hide Hero Image on Tablet/Mobile */
    .hero-image {
        display: none !important;
    }

    /* Footer Bottom Responsiveness */
    .footer-bottom {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 20px 0;
    }

    .footer-legal {
        justify-content: center;
        margin-top: 5px;
    }
}

/* --- Dark Mode Tweaks for Dashboard Mobile --- */
body.dark-mode .sidebar {
    background: #111c44;
    border-right: 1px solid #2b3674;
}

body.dark-mode .topbar {
    background: #111c44 !important;
    border-bottom-color: #2b3674 !important;
}

body.dark-mode .mobile-toggle {
    color: white;
}

/* --- Landing Pages Mobile (max-width: 900px) --- */
@media (max-width: 900px) {

    /* Global Container */
    .container {
        padding: 0 20px !important;
        width: 100% !important;
        box-sizing: border-box;
    }

    /* Global Typography & Elements */
    h1 {
        font-size: 32px !important;
        line-height: 1.2 !important;
    }

    h2 {
        font-size: 26px !important;
        line-height: 1.3 !important;
    }

    p {
        font-size: 16px !important;
        line-height: 1.6 !important;
    }

    img {
        max-width: 100%;
        height: auto;
    }

    /* Section Spacing - Professional Breathing Room */
    .audience-section,
    .features-section,
    .testimonials-section,
    .app-section {
        padding: 60px 20px !important;
    }

    /* Navigation Bar */
    .landing-nav {
        padding: 0 20px !important;
        height: 70px !important;
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    .nav-links-desktop {
        display: none !important;
    }

    .auth-buttons {
        display: none;
        /* Hide default buttons, show mobile toggle via JS */
    }

    .mobile-menu-btn {
        display: block !important;
        font-size: 24px;
        background: none;
        border: none;
        cursor: pointer;
        color: var(--text-main);
        padding: 5px;
    }

    body.dark-mode .mobile-menu-btn {
        color: white;
    }

    /* Mobile Menu Dropdown/Overlay */
    .mobile-menu-container {
        display: none;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100%;
        background: #ffffff;
        padding: 20px;
        box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
        z-index: 999;
        flex-direction: column;
        border-top: 1px solid #f3f4f6;
    }

    body.dark-mode .mobile-menu-container {
        background: #111c44;
        border-top-color: #2b3674;
    }

    .mobile-menu-container.active {
        display: flex;
        animation: slideDown 0.3s ease-out forwards;
    }

    @keyframes slideDown {
        from {
            opacity: 0;
            transform: translateY(-10px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .mobile-nav-link {
        padding: 15px 0;
        border-bottom: 1px solid #f3f4f6;
        color: var(--text-main);
        font-weight: 600;
        text-decoration: none;
        font-size: 16px;
    }

    body.dark-mode .mobile-nav-link {
        color: white;
        border-bottom-color: #2b3674;
    }

    .mobile-auth-buttons {
        margin-top: 20px;
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .mobile-auth-buttons .btn {
        width: 100%;
    }

    /* Hero Section */
    .hero-section {
        flex-direction: column;
        padding: 40px 20px !important;
        text-align: center;
        min-height: auto;
    }

    .hero-content {
        padding-right: 0 !important;
        margin-bottom: 40px;
    }

    .hero-image {
        text-align: center;
    }

    .hero-title {
        font-size: 32px !important;
        line-height: 1.2;
    }

    .hero-desc {
        margin: 0 auto 30px;
        font-size: 16px;
    }

    .hero-cta {
        flex-direction: column;
        width: 100%;
        gap: 15px;
        margin: 0 auto;
    }

    /* App Section Alignment */
    .app-content {
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .app-content p {
        margin: 0 auto 40px;
    }

    .app-features-grid {
        margin: 0 auto 40px;
        text-align: left;
        /* Keep features left aligned within centered block */
    }

    .app-badges {
        justify-content: center;
    }

    .hero-cta input,
    .hero-cta button {
        width: 100%;
        margin: 0;
    }

    /* General Grids */
    .grid-4,
    .grid-3,
    .grid-2,
    .grid-4-cards,
    .grid-3-features,
    .grid-2-app,
    .grid-3-testimonials {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }

    /* Stats Section - Premium Mobile Experience */
    .stats-section .grid-4 {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }

    .stat-item {
        margin-bottom: 0;
        padding: 20px;
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.08);
        /* More visible glass effect */
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        text-align: left;
        gap: 20px;
        transition: transform 0.2s;
    }

    .stat-item:active {
        transform: scale(0.98);
        background: rgba(255, 255, 255, 0.12);
    }

    .stat-icon {
        width: 60px !important;
        height: 60px !important;
        font-size: 24px !important;
        margin: 0 !important;
        flex-shrink: 0;
        background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05)) !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }

    .stat-content-wrapper {
        flex: 1;
    }

    .stat-item h2 {
        font-size: 36px !important;
        margin-bottom: 2px !important;
        line-height: 1 !important;
        background: linear-gradient(to right, #fff, #e2e8f0);
        background-clip: text;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
    }

    .stat-item p {
        font-size: 15px !important;
        font-weight: 600 !important;
        color: rgba(255, 255, 255, 0.95);
        margin: 0;
        line-height: 1.2 !important;
    }

    .stat-item p span {
        font-size: 13px !important;
        margin-top: 4px !important;
        color: rgba(255, 255, 255, 0.7);
        font-weight: 400;
        display: block;
    }

    /* Footer */
    .main-footer {
        padding: 40px 20px 20px !important;
    }

    /* Footer - Professional Mobile Layout */
    .main-footer {
        padding: 50px 20px 30px !important;
    }

    .footer-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 40px 20px;
        text-align: left;
        /* text-align left for links matches professional sites */
    }

    /* Brand Section - Centered & Full Width */
    .footer-brand {
        grid-column: 1 / -1;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .footer-brand p {
        max-width: 100%;
        margin: 15px 0 20px;
    }

    /* Link Columns - Naturally fall into 2-column grid */
    .footer-links h4 {
        font-size: 15px;
        margin-bottom: 20px;
    }

    /* App Section - Aligned with Grid */
    .footer-app {
        grid-column: auto;
        text-align: left;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        margin-top: 0;
    }

    .footer-badges {
        flex-direction: column !important;
        align-items: flex-start;
        justify-content: flex-start;
        gap: 10px;
    }

    .footer-legal {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 15px;
    }

    /* Specific Page Fixes */

    /* About & Others */
    .about-hero,
    .career-hero,
    .press-hero {
        padding: 60px 20px !important;
        text-align: center;
    }

    .about-grid,
    .team-grid {
        grid-template-columns: 1fr !important;
    }

    /* Pricing */
    .pricing-toggle {
        margin-bottom: 30px;
    }

    .pricing-grid {
        grid-template-columns: 1fr !important;
    }

    .comparison-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* Contact */
    .contact-container {
        grid-template-columns: 1fr !important;
    }

    .contact-info,
    .contact-form-container {
        width: 100%;
    }

    /* Features */
    .feature-row {
        flex-direction: column !important;
    }

    .feature-row.reverse {
        flex-direction: column-reverse !important;
    }

    .feature-text {
        padding: 0 !important;
        margin-bottom: 30px;
    }

    /* Blog */
    .blog-grid {
        grid-template-columns: 1fr !important;
    }

    .featured-article {
        grid-template-columns: 1fr !important;
    }

    .featured-content {
        padding: 30px !important;
    }

    .featured-image {
        height: 250px !important;
        min-height: 250px !important;
        order: -1;
    }

    .filter-section {
        padding: 20px 10px;
        text-align: left;
        display: flex;
        gap: 10px;
        overflow-x: scroll;
    }

    /* Policy Pages (Terms, Privacy, Cookies) */
    .policy-container {
        flex-direction: column !important;
        padding: 0 20px !important;
        gap: 20px !important;
    }

    .policy-nav {
        width: 100% !important;
        position: relative !important;
        top: 0 !important;
        margin-bottom: 20px;
        max-height: none !important;
        border-bottom: 1px solid #eee;
        padding: 20px !important;
    }

    .policy-content {
        padding: 25px !important;
    }

    /* Login Side Visual */
    .login-wrapper {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .login-side-visual {
        display: none;
    }

    .login-form-container {
        padding: 40px 20px;
    }
}

@media (max-width: 480px) {
    .stats-section .grid-4 {
        grid-template-columns: 1fr !important;
    }

    /* Center Stats Content on Mobile */
    .stat-item {
        flex-direction: column;
        justify-content: center;
        text-align: center !important;
        gap: 15px;
        padding: 30px 20px;
    }

    .stat-icon {
        margin: 0 auto !important;
    }

    .stat-content-wrapper {
        text-align: center;
        width: 100%;
    }

    .stat-item h2 {
        justify-content: center;
        display: flex;
    }

    .hero-title {
        font-size: 28px !important;
    }

    /* Hide App Image on very small screens to save space */
    .app-image {
        display: none !important;
    }
}

/* Helper Class for Mobile Toggle linked to JS */
.mobile-menu-btn {
    display: none;
    /* Hidden on desktop */
}

/* Hide Mobile Menu Container on Desktop */
.mobile-menu-container {
    display: none;
}