/* ==========================================
   ISA Overflow Prevention
   Comprehensive Horizontal Scroll Prevention
   ========================================== */

/* Global Overflow Prevention */
html {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
}

/* Prevent all elements from overflowing */
* {
    max-width: 100%;
    box-sizing: border-box;
}

/* Common overflow culprits */
img,
video,
iframe,
embed,
object,
svg {
    max-width: 100%;
    height: auto;
}

/* Tables responsive wrapper */
table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Pre and code blocks */
pre,
code {
    max-width: 100%;
    overflow-x: auto;
    word-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
}

/* Long text prevention */
p,
h1, h2, h3, h4, h5, h6,
li,
dd,
span {
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
}

/* Specific problematic elements */
#particles {
    position: fixed;
    max-width: 100vw;
    overflow: hidden;
}

#floating-isa-logo {
    max-width: 80px;
    right: 20px !important;
    left: auto !important;
}

.hero {
    max-width: 100vw;
    overflow: hidden;
}

.hero-glow {
    max-width: 100vw;
    overflow: hidden;
}

/* Container constraints */
.container {
    max-width: 100%;
    padding-left: 1rem;
    padding-right: 1rem;
}

section {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Navigation fixes */
nav {
    max-width: 100vw;
    overflow-x: hidden;
}

.nav-links {
    max-width: 100%;
}

/* Carousel container */
.carousel-container {
    max-width: 100%;
    overflow-x: hidden;
}

.carousel-track {
    max-width: 100%;
}

.carousel-slide {
    max-width: 100%;
}

/* Card elements */
.card,
.testimonial-card {
    max-width: 100%;
}

/* Form elements */
form {
    max-width: 100%;
}

input,
textarea,
select {
    max-width: 100%;
    width: 100%;
}

/* Button constraints */
button,
.btn,
a.btn {
    max-width: 100%;
    white-space: normal;
}

/* Grid and Flex fixes */
.grid {
    max-width: 100%;
}

.flex {
    max-width: 100%;
    flex-wrap: wrap;
}

/* Absolute positioned elements */
[class*="absolute"],
[style*="position: absolute"],
[style*="position:absolute"] {
    max-width: 100vw;
}

/* Fixed positioned elements */
[class*="fixed"],
[style*="position: fixed"],
[style*="position:fixed"] {
    max-width: 100vw;
}

/* Mobile specific overflow fixes */
@media (max-width: 768px) {
    /* Reset any large padding or margins */
    * {
        max-width: 100% !important;
    }
    
    /* Specific width overrides */
    [style*="width:"],
    [style*="min-width:"] {
        max-width: 100% !important;
    }
    
    /* Transform fixes */
    .hero-glow,
    #floating-isa-logo,
    .cta-pulse {
        transform-origin: center center;
    }
    
    /* Animation bounds */
    @keyframes floatAround {
        0%, 100% { transform: translate(0, 0) rotate(0deg); }
        25% { transform: translate(20px, -10px) rotate(90deg); }
        50% { transform: translate(-10px, -20px) rotate(180deg); }
        75% { transform: translate(-20px, 10px) rotate(270deg); }
    }
    
    /* Dropdown menus */
    .group .absolute {
        right: 0;
        left: 0;
        max-width: calc(100vw - 2rem);
        margin: 0 1rem;
    }
    
    /* Modal and overlay constraints */
    .modal,
    .overlay,
    #mobile-menu {
        max-width: 100vw;
        max-height: 100vh;
    }
}

/* Ultra small devices */
@media (max-width: 375px) {
    .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    /* Further constrain animations */
    * {
        animation-distance: 10px !important;
    }
}

/* Debug mode - uncomment to find overflow issues */
/*
* {
    border: 1px solid red !important;
}
*/