/* ==========================================================================
   Global Responsive Overrides
   Enhances responsiveness across the entire site without altering HTML content.
   ========================================================================== */

/* 1. Universal Box Sizing & Overflow Protection */
html, body {
    max-width: 100vw;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    -webkit-font-smoothing: antialiased;
}

*, *::before, *::after {
    box-sizing: border-box !important;
}

/* 2. Fluid Media and Embedded Content */
img, video, iframe, canvas, svg {
    max-width: 100% !important;
    height: auto !important;
    display: block; /* Removes bottom space */
}

/* 3. Global Padding & Margin Overrides for Mobile */
@media screen and (max-width: 768px) {
    /* Reduce large gaps on smaller screens */
    .container, .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .row {
        margin-left: -15px !important;
        margin-right: -15px !important;
    }

    section, .section-padding, .w3-agileits-services, .agile_about_top, .footer_top_agileits {
        padding: 40px 0 !important; /* Standardize vertical padding */
    }

    /* Soften hardcoded static widths */
    div, section, article {
        max-width: 100% !important;
    }

    /* Better stacking for grids */
    .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12,
    .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12 {
        padding-left: 15px !important;
        padding-right: 15px !important;
        margin-bottom: 20px !important; /* Add space between stacked items */
    }
    
    /* Last item in a stacked grid shouldn't have extra bottom margin */
    .row > [class*="col-"]:last-child {
        margin-bottom: 0 !important;
    }
}

/* 4. Navigation & Header Fixes for Mobile */
@media screen and (max-width: 991px) {
    .agileits_top_menu {
        padding: 10px 0;
        height: auto;
        line-height: normal !important; /* Override legacy line-height: 1px causing overlap */
    }

    .header-top-actions, .w3l_header_right, .w3l_header_left {
        text-align: center !important;
        float: none !important;
        width: 100% !important;
        margin-bottom: 12px !important; /* Increased margin to prevent crowding */
        display: block !important;
        position: relative;
        z-index: 5;
    }
    
    .w3l_header_left ul {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        gap: 15px;
        padding: 0;
        margin: 0 0 12px 0;
    }

    .w3ls-social-icons.header-top-actions {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        margin-bottom: 15px !important;
    }

    .header-btn, .btn-header-cta {
        padding: 8px 14px !important; /* Slightly larger targets */
        font-size: 13px !important;
        margin: 4px !important; /* Add some spacing between buttons */
        display: inline-block;
    }

    .trust-strip {
        position: relative;
        z-index: 1;
        margin-top: 5px;
        border-top: 1px solid rgba(255,255,255,0.1);
        padding-top: 10px;
    }

    .trust-strip-inner {
        display: flex;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        line-height: 1.6;
        padding: 10px 15px;
        font-size: 12px;
    }
    
    .trust-strip-label, .trust-strip-stats {
        display: block;
        margin: 2px 0;
    }

    /* Fix Hamburger Menu Button */
    .navbar-toggle.nav-main-toggle {
        background-color: #2563eb !important; /* Brand Blue */
        border: none !important;
        border-radius: 6px !important;
        margin-top: 12px;
    }

    .navbar-toggle.nav-main-toggle .icon-bar {
        background-color: #ffffff !important;
    }

    .navbar-toggle.nav-main-toggle:hover, 
    .navbar-toggle.nav-main-toggle:focus {
        background-color: #1d4ed8 !important;
    }

    .nav-main-toggle-label {
        color: #ffffff !important;
        font-weight: 600;
        margin-right: 5px;
    }
    
    .navbar-collapse {
        background-color: #fff;
        max-height: 70vh;
        overflow-y: auto;
        box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    }
    
    .navbar-nav {
        margin: 0;
        padding: 15px 0;
    }
    
    .navbar-nav > li {
        width: 100%;
        text-align: left;
    }
    
    .navbar-nav > li > a {
        padding: 12px 20px !important;
        border-bottom: 1px solid #f1f1f1;
    }

    /* Prevent text overlapping CTA buttons */
    .hero-slide-content {
        padding-top: 20px;
        padding-bottom: 40px;
    }

    .hero-display-title {
        font-size: 24px !important;
        line-height: 1.2 !important;
    }

    .hero-caption {
        padding-top: 60px !important;
    }

    /* Ensure services grid doesn't overlap */
    .home-services {
        padding-top: 60px !important;
        padding-bottom: 60px !important;
    }
}

/* 5. Footer Responsive Fixes */
@media screen and (max-width: 768px) {
    .footer_grid {
        text-align: center !important;
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    .footer_grid h3 {
        margin-top: 20px !important;
    }
    
    .address li {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .address i {
        margin-bottom: 10px;
    }
}

/* 6. Typography Scaling & Readability (Mobile) */
@media screen and (max-width: 576px) {
    /* Prevent text stretching or tiny mobile fonts */
    body {
        font-size: 15px !important;
        line-height: 1.6 !important;
    }
    
    /* Ensure long words don't break containers */
    p, a, h1, h2, h3, h4, h5, h6 {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    .btn, .header-btn, .btn-header-cta {
        display: inline-block;
        width: auto !important;
        max-width: 100%;
        text-align: center;
        padding: 12px 24px;
        white-space: normal; /* Let button text wrap if needed */
    }
}

/* 7. Forms and Input Fixes */
input, select, textarea {
    max-width: 100% !important;
}

@media screen and (max-width: 768px) {
    .form-control {
        width: 100% !important;
        margin-bottom: 15px !important;
    }
}

/* 8. Fix Disruptive Image & Block Hover Animations */
/* Prevent image/block scaling from overflowing past screen width */
.gfort-image, .price-block, .gallery-grid, .portfolio-items, [class*="hover"] {
    overflow: hidden; 
}

/* On mobile, disable large zoom/scale animations entirely as they cause UX issues */
@media screen and (max-width: 991px) {
    img, .price-block, .portfolio-items, .services-grid, div.background-image-block {
        -webkit-transform: none !important;
        -moz-transform: none !important;
        -ms-transform: none !important;
        -o-transform: none !important;
        transform: none !important;
        transition: none !important; 
    }
    
    .price-block:hover, .w3-agileits-vpn-grid:hover, .w3layouts-pricing:hover, img:hover {
        transform: none !important;
        -webkit-transform: none !important;
    }
}

/* Smooth out base transitions for desktop */
img {
    transition: transform 0.3s ease-in-out !important;
}

/* ==========================================================================
   9. Legacy inner pages (nav-linked product/service templates)
   style.css forces .col-md-7 to ~58% at all widths, adds .pull-right { margin-right: 190px }
   on small screens, fixed .content-block-container p widths, and gfort-42 full-bleed overlay.
   Scoped to .page-content so home / modals are unaffected.
   ========================================================================== */
@media screen and (max-width: 991px) {
    .page-content .section-container {
        overflow: visible;
    }

    /* Grid: undo global .col-md-7 width + float / margin on columns */
    .page-content .row > [class*="col-md-7"],
    .page-content .row [class*="col-lg-"].col-md-7 {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
    }

    .page-content .row > [class*="col-md-5"] {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
    }

    .page-content .container .row > .pull-right {
        float: none !important;
        margin-right: 0 !important;
    }

    /* Hero image column: stack in flow; do not cover text */
    .page-content .gfort-42-column {
        position: relative !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        float: none !important;
        margin-right: 0 !important;
        z-index: 1;
        overflow: visible !important;
    }

    .page-content .gfort-42-column .background-image-block,
    .page-content .gfort-42-column .background-image-block.gfort-image {
        position: relative !important;
        height: auto !important;
        width: 100% !important;
        overflow: visible !important;
    }

    .page-content .gfort-42-column .background-image-block img,
    .page-content .gfort-42-column .parallax-effect img {
        position: relative !important;
        display: block !important;
        width: 100% !important;
        max-width: 480px;
        height: auto !important;
        min-width: 0 !important;
        min-height: 0 !important;
        left: auto !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        -webkit-transform: none !important;
        transform: none !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Icon + heading blocks: avoid one-character-per-line wrapping */
    .page-content .content-block-style-3 i.circle-icon-block-lg + h4,
    .page-content .content-block-style-3 h4 {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .page-content .content-block-style-3 h4 a {
        display: block;
        white-space: normal;
        word-break: normal;
        overflow-wrap: break-word;
    }

    .page-content .n-service-provider {
        margin-left: 0 !important;
    }

    .page-content .tittle-block-header h2 {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .page-content .line-separator-3,
    .page-content .line-separator.line-separator-3 {
        margin-left: 0 !important;
    }

    .page-content .title-block {
        margin-left: 0 !important;
    }

    .page-content .wtk-mbl {
        margin-left: 0 !important;
    }
}

@media screen and (max-width: 767px) {
    /* Mobile block in style.css sets fixed widths on these */
    .page-content .content-block-container p {
        width: auto !important;
        max-width: 100% !important;
    }

    .page-content .title-block-container h2 {
        width: auto !important;
        max-width: 100% !important;
    }

    .page-content .cashback-header-details,
    .page-content .wtk-heading-text {
        margin-top: 1.25rem !important;
    }
}

