/* CRITICAL: Eliminate ALL horizontal scrolling */
/* This file should be loaded FIRST to prevent any horizontal overflow */

/* Universal box-sizing and overflow prevention */
*, *::before, *::after {
    box-sizing: border-box !important;
    max-width: 100vw !important;
}

/* Root level overflow prevention and scaling */
html {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    font-size: 16px !important; /* Base font size for scaling */
}

body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    min-height: 100vh !important;
    /* Dynamic scaling based on viewport */
    transform-origin: top left !important;
    position: relative !important;
}

/* Force all Wix containers to respect viewport bounds and scale properly */
#SITE_CONTAINER,
#site-root,
#masterPage,
#PAGES_CONTAINER,
#SITE_HEADER,
#SITE_FOOTER,
#SITE_HEADER_WRAPPER,
#SITE_FOOTER_WRAPPER {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    transform-origin: top left !important;
    position: relative !important;
}

/* Main site container scaling */
#SITE_CONTAINER {
    min-height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Ensure the main page content scales properly */
#site-root {
    width: 100vw !important;
    max-width: 100vw !important;
    transform-origin: top left !important;
}

/* Page content should fill available space */
#masterPage,
#PAGES_CONTAINER {
    flex: 1 !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Override Wix's responsive settings that might cause overflow */
body:not(.responsive) #site-root {
    min-width: unset !important;
    width: 100% !important;
    max-width: 100% !important;
}

body.device-mobile-optimized:not(.responsive) #SITE_CONTAINER {
    width: 100% !important;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* Fix all data-mesh elements */
[data-mesh-id],
[data-mesh-id$=-gridContainer],
[data-mesh-id$=centeredContent],
[data-mesh-id$=inlineContent],
[data-mesh-id$=-gridWrapper],
[data-mesh-id$=-rotated-wrapper] {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

/* Fix all Wix components */
[data-comp-id],
[id^="comp-"] {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Mesh layout fixes */
.mesh-layout,
.mesh-layout > *,
#masterPage.mesh-layout,
#masterPage.mesh-layout > * {
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
}

/* Grid fixes */
.AnQkDU,
.JsJXaX {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Fix any absolute positioning that might cause overflow */
[style*="position: absolute"],
[style*="position:absolute"] {
    max-width: 100% !important;
    right: 0 !important;
    left: auto !important;
}

/* Prevent transforms from pushing content outside viewport */
[style*="transform"] {
    max-width: 100% !important;
}

/* Media elements */
img, video, iframe, canvas, svg, embed, object {
    max-width: 100% !important;
    height: auto !important;
    width: auto !important;
}

/* Tables */
table {
    width: 100% !important;
    max-width: 100% !important;
    table-layout: fixed !important;
    overflow-x: auto !important;
    display: block !important;
}

/* Text and content */
pre, code {
    overflow-x: auto !important;
    white-space: pre-wrap !important;
    word-wrap: break-word !important;
    max-width: 100% !important;
}

/* Forms */
form, fieldset {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Buttons and inputs */
button, input, select, textarea {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Lists */
ul, ol, dl {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Block elements */
div, section, article, aside, header, footer, nav, main, p, h1, h2, h3, h4, h5, h6 {
    max-width: 100% !important;
    overflow-wrap: break-word !important;
    word-wrap: break-word !important;
    box-sizing: border-box !important;
}

/* Flexbox containers */
[style*="display: flex"],
[style*="display:flex"],
.flex {
    flex-wrap: wrap !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Grid containers */
[style*="display: grid"],
[style*="display:grid"],
.grid {
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Critical: Override any inline styles that might cause overflow */
[style*="width:"],
[style*="min-width:"] {
    max-width: 100% !important;
}

/* Mobile specific - ULTRA-AGGRESSIVE overflow prevention */
@media screen and (max-width: 768px) {
    * {
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }
    
    html, body {
        overflow-x: hidden !important;
        width: 100vw !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Force ALL elements to fit within mobile viewport */
    [style*="width"],
    [style*="min-width"],
    [style*="max-width"] {
        width: 100% !important;
        min-width: unset !important;
        max-width: 100% !important;
    }
    
    /* Remove ANY transforms that could cause overflow */
    [style*="transform"] {
        transform: none !important;
    }
    
    /* Target absolutely positioned elements */
    [style*="position: absolute"],
    [style*="position:absolute"] {
        position: relative !important;
        left: auto !important;
        right: auto !important;
        max-width: 100% !important;
    }
    
    /* Force flexbox items to wrap */
    [style*="display: flex"],
    [style*="display:flex"] {
        flex-wrap: wrap !important;
        max-width: 100% !important;
    }
    
    /* Grid layouts become single column */
    [style*="display: grid"],
    [style*="display:grid"] {
        display: block !important;
        max-width: 100% !important;
    }
    
    /* Target Wix-specific problematic classes */
    .mesh-layout,
    .AnQkDU,
    .JsJXaX {
        max-width: 100% !important;
        overflow-x: hidden !important;
        display: block !important;
        grid-template-columns: 1fr !important;
    }
    
    /* Ensure no element can escape the container */
    [data-mesh-id],
    [data-comp-id],
    [id^="comp-"] {
        max-width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
        contain: layout !important;
    }
    
    /* Additional safety measures */
    img, video, iframe, canvas, svg, embed, object {
        max-width: 100% !important;
        width: auto !important;
        height: auto !important;
    }
    
    table {
        width: 100% !important;
        max-width: 100% !important;
        table-layout: fixed !important;
        overflow-x: auto !important;
        display: block !important;
    }
    
    /* Target any inline styles that specify large widths */
    [style*="980px"],
    [style*="1200px"],
    [style*="1920px"] {
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
    }
    
    /* Prevent text from causing overflow */
    * {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }
}

/* Additional ultra-aggressive rules for all screen sizes */
/* Force all containers to never exceed viewport */
#SITE_CONTAINER,
#site-root,
#masterPage,
#PAGES_CONTAINER,
#SITE_HEADER,
#SITE_FOOTER,
#SITE_HEADER_WRAPPER,
#SITE_FOOTER_WRAPPER {
    contain: layout !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
}

/* Catch any missed overflow-causing elements */
@supports (container-type: inline-size) {
    * {
        container-type: inline-size !important;
    }
}

/* Final safety net - use CSS containment */
[data-mesh-id],
[data-comp-id] {
    contain: layout style !important;
}