/* =========================================================================
   FLUID RESPONSIVE LAYOUT SYSTEM
   =========================================================================
   This file safely overrides existing styles to enforce fluid responsiveness
   across all devices and aspect ratios without breaking the desktop design.
   ========================================================================= */

/* ── 1. GLOBAL RESET & BEHAVIOR ── */
html, body {
    overflow-x: hidden !important; /* Prevent horizontal scroll */
    min-width: 320px;
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Ensure the main page content expands to push footer to bottom */
.page-wraper {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}
.page-content {
    flex-grow: 1; /* Pushes footer down naturally */
    width: 100%;
}

/* Fluid Resets */
*, *::before, *::after {
    box-sizing: border-box;
}

/* ── 2. FLUID TYPOGRAPHY (Clamp) ── */
:root {
    /* Main Headings */
    --h1-fluid: clamp(2rem, 5vw + 1rem, 3.5rem);
    --h2-fluid: clamp(1.75rem, 4vw + 1rem, 2.75rem);
    --h3-fluid: clamp(1.5rem, 3vw + 1rem, 2.25rem);
    --h4-fluid: clamp(1.25rem, 2.5vw + 0.5rem, 1.75rem);
    
    /* Body & Controls */
    --p-fluid: clamp(0.875rem, 1.5vw + 0.5rem, 1.125rem);
    --btn-fluid: clamp(0.875rem, 1.5vw + 0.5rem, 1rem);
}

h1, .h1 { font-size: var(--h1-fluid) !important; line-height: 1.2; }
h2, .h2 { font-size: var(--h2-fluid) !important; line-height: 1.3; }
h3, .h3 { font-size: var(--h3-fluid) !important; line-height: 1.4; }
h4, .h4 { font-size: var(--h4-fluid) !important; line-height: 1.4; }
p, li { font-size: var(--p-fluid); line-height: 1.6; }

/* ── 3. FLUID IMAGES & MEDIA ── */
img, video, iframe, svg {
    max-width: 100%;
    height: auto;
    object-fit: cover;
}

/* Keep brand logos intact */
.site-logo img, .brand-logo img, .logo img {
    object-fit: contain;
}

/* ── 4. FLUID CONTAINERS ── */
.container, .container-fluid {
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    padding-left: clamp(15px, 4vw, 30px);
    padding-right: clamp(15px, 4vw, 30px);
}
/* Ensure rows don't overflow the padded containers */
.row {
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
}
.row > * {
    max-width: 100%;
}

/* ── 5. FLUID CARDS (Auto-Fit Grid) ── */
/* Replace fixed floats or flex with a modern grid that naturally stacks */
.card-grid, .properties-grid, .blog-grid, .services-grid {
    display: grid !important;
    gap: clamp(15px, 2vw, 30px);
    /* Auto fit: 1 card mobile, 2 tablet, 3-4 desktop */
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
    align-items: stretch;
}
.card-grid > *, .properties-grid > *, .blog-grid > *, .services-grid > * {
    display: flex;
    flex-direction: column;
    height: 100%;
}
/* Strip existing fixed widths inside modern grids */
.card-grid .col-md-3, .card-grid .col-md-4, .card-grid .col-md-6 {
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
    padding: 0 !important;
}

/* ── 6. FLUID FORMS ── */
input, select, textarea, button, .form-control {
    font-size: var(--btn-fluid) !important;
    max-width: 100%;
}
/* Force touch targets */
button, .btn, input[type="submit"], input[type="button"], a.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* 2-col to 1-col form layouts */
.form-row, .fluid-form {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
}

/* ── 7. RESPONSIVE TABLES ── */
@media (max-width: 768px) {
    table.responsive-table, .table-responsive table {
        display: block;
        width: 100%;
    }
    table.responsive-table thead, .table-responsive table thead {
        display: none; /* Hide headers on mobile */
    }
    table.responsive-table tbody, .table-responsive table tbody {
        display: block;
        width: 100%;
    }
    table.responsive-table tr, .table-responsive table tr {
        display: block;
        margin-bottom: 15px;
        border: 1px solid rgba(0,0,0,0.1);
        border-radius: 8px;
        padding: 10px;
        background: #fff;
    }
    table.responsive-table td, .table-responsive table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 8px 5px !important;
        border-top: 1px solid rgba(0,0,0,0.05);
    }
    table.responsive-table td::before, .table-responsive table td::before {
        content: attr(data-label);
        font-weight: 600;
        text-align: left;
        margin-right: 15px;
    }
    table.responsive-table td:first-child, .table-responsive table td:first-child {
        border-top: none;
    }
}

/* ── 8. HEADER & SIDEBAR ADAPTATIONS ── */
@media (max-width: 991px) {
    /* Mobile/Tablet Header Adjustments */
    .site-header {
        position: sticky;
        top: 0;
        z-index: 9999;
    }
    /* Force offcanvas sidebar on mobile */
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: 80%;
        max-width: 320px;
        z-index: 10000;
        transition: left 0.3s ease;
        overflow-y: auto;
    }
    .sidebar.active {
        left: 0;
    }
}

/* ── 9. PERFORMANCE & ACCESSIBILITY ── */
.content-section {
    content-visibility: auto; /* Optimizes rendering for off-screen sections */
    contain-intrinsic-size: 500px;
}
