/* ===================================
   MOBILE RESPONSIVE FIXES - COMPREHENSIVE
   Fixes inline scrolling and content truncation on mobile
   =================================== */

/* Mobile Grid Layout Fixes - Stack columns on mobile */
@media (max-width: 768px) {

    /* Force all inline grid layouts to single column */
    [style*="display: grid"][style*="grid-template-columns: 1fr 1fr"],
    [style*="display: grid"][style*="grid-template-columns: repeat(3, 1fr)"],
    [style*="display: grid"][style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    /* Reduce excessive padding on mobile */
    [style*="padding: 4rem 3rem"],
    [style*="padding: 3.5rem 3rem"],
    [style*="padding: 3rem 2rem"] {
        padding: 2rem 1.5rem !important;
    }

    [style*="padding: 2.5rem 2rem"] {
        padding: 1.5rem 1rem !important;
    }

    /* Fix margin-bottom spacing */
    [style*="margin-bottom: 4rem"] {
        margin-bottom: 2rem !important;
    }

    [style*="margin-bottom: 3rem"] {
        margin-bottom: 1.5rem !important;
    }

    /* Ensure images don't have fixed heights on mobile */
    [style*="height: 400px"] {
        height: auto !important;
        min-height: 250px !important;
    }

    [style*="height: 350px"] {
        height: auto !important;
        min-height: 200px !important;
    }
}

/* Small Mobile Devices - Additional fixes */
@media (max-width: 480px) {

    /* Further reduce padding */
    [style*="padding: 4rem"],
    [style*="padding: 3rem"],
    [style*="padding: 2.5rem"],
    [style*="padding: 2rem"] {
        padding: 1.25rem 1rem !important;
    }

    /* Reduce font sizes for better fit */
    [style*="font-size: 3.5rem"] {
        font-size: 2rem !important;
    }

    [style*="font-size: 2.75rem"],
    [style*="font-size: 2.5rem"] {
        font-size: 1.75rem !important;
    }

    [style*="font-size: 2.25rem"],
    [style*="font-size: 2rem"] {
        font-size: 1.5rem !important;
    }

    [style*="font-size: 1.75rem"],
    [style*="font-size: 1.5rem"] {
        font-size: 1.25rem !important;
    }

    [style*="font-size: 1.35rem"],
    [style*="font-size: 1.25rem"] {
        font-size: 1.1rem !important;
    }

    /* Fix line heights */
    [style*="line-height: 1.8"],
    [style*="line-height: 1.9"] {
        line-height: 1.6 !important;
    }
}

/* Fix specific sections that commonly cause scrolling issues */
@media (max-width: 768px) {

    /* Pillar cards - ensure they stack properly */
    .pillar-card {
        padding: 1.5rem 1rem !important;
        margin-bottom: 1rem !important;
    }

    /* Service features lists */
    .service-features {
        padding: 0 !important;
    }

    .service-features li {
        padding: 0.75rem 0 !important;
        font-size: 0.95rem !important;
    }

    /* Fix absolute positioned decorative elements */
    [style*="position: absolute"][style*="width: 300px"],
    [style*="position: absolute"][style*="width: 400px"],
    [style*="position: absolute"][style*="width: 500px"] {
        display: none !important;
    }

    /* Ensure max-width containers don't exceed viewport */
    [style*="max-width: 1200px"],
    [style*="max-width: 900px"],
    [style*="max-width: 800px"],
    [style*="max-width: 700px"] {
        max-width: 100% !important;
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    /* Fix border radius on mobile */
    [style*="border-radius: 24px"] {
        border-radius: 16px !important;
    }

    [style*="border-radius: 20px"] {
        border-radius: 12px !important;
    }
}

/* Fix inline flex layouts */
@media (max-width: 640px) {
    [style*="display: flex"][style*="gap: 3rem"] {
        flex-direction: column !important;
        gap: 1.5rem !important;
    }

    [style*="display: flex"][style*="gap: 2rem"] {
        flex-direction: column !important;
        gap: 1rem !important;
    }

    /* Fix inline-block badges and tags */
    [style*="display: inline-block"][style*="padding: 0.75rem 1.5rem"],
    [style*="display: inline-block"][style*="padding: 0.5rem 1.5rem"] {
        padding: 0.5rem 1rem !important;
        font-size: 0.875rem !important;
    }
}

/* Ensure no content is cut off */
@media (max-width: 768px) {

    /* Remove any max-height that might truncate content */
    section,
    div[class*="section"],
    div[class*="container"] {
        max-height: none !important;
        overflow: visible !important;
    }

    /* Ensure text is always readable */
    p,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    span,
    li,
    a {
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        hyphens: auto !important;
    }

    /* Fix any width issues */
    * {
        min-width: 0 !important;
    }
}

/* Fix hero actions on mobile */
@media (max-width: 640px) {
    .hero-actions {
        flex-direction: column !important;
        gap: 1rem !important;
        width: 100% !important;
    }

    .hero-actions .btn {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* Fix service row cards on mobile */
@media (max-width: 968px) {
    .service-row-card {
        padding: 1rem !important;
    }

    .service-row-content {
        padding: 1.5rem 1rem !important;
    }

    .service-row-image {
        padding: 1rem !important;
    }
}

@media (max-width: 640px) {
    .service-row-card {
        padding: 0.75rem !important;
    }

    .service-row-content {
        padding: 1.25rem 0.75rem !important;
    }

    .service-row-image {
        padding: 0.75rem !important;
    }
}

/* Fix footer on mobile */
@media (max-width: 768px) {

    .footer-content,
    .footer-main {
        padding: 2rem 1rem !important;
    }

    .footer-grid {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
}

/* Ensure container padding is appropriate */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

@media (max-width: 480px) {
    .container {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* Fix any remaining inline styles that cause issues */
@media (max-width: 768px) {

    /* Fix width constraints */
    [style*="width: 45%"],
    [style*="width: 50%"],
    [style*="width: 55%"] {
        width: 100% !important;
    }

    /* Fix flex basis */
    [style*="flex: 1"] {
        flex: 1 1 100% !important;
    }

    /* Fix gap spacing */
    [style*="gap: 3rem"] {
        gap: 1.5rem !important;
    }

    [style*="gap: 2.5rem"] {
        gap: 1.25rem !important;
    }
}

/* ===================================
   Touch & Mobile Device Optimizations
   =================================== */

/* Remove tap highlight on mobile for cleaner UX */
a, button, [role="button"], input, select, textarea, label {
    -webkit-tap-highlight-color: transparent;
}

/* Prevent text size inflation on mobile Safari */
html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

/* Smooth scrolling for mobile */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Prevent horizontal overflow on mobile */
body {
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Better touch targets */
a, button, [role="button"] {
    touch-action: manipulation;
}

/* Fix iOS safe area insets for notched devices */
@supports (padding: env(safe-area-inset-top)) {
    .header,
    .nav,
    .new-footer {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .footer-bottom {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Prevent zoom on input focus for mobile */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
textarea,
select {
    font-size: 16px !important;
}

/* ===================================
   Tiny Mobile Devices (320px and below)
   =================================== */
@media (max-width: 360px) {

    /* Force single column on all grids */
    [style*="display: grid"] {
        grid-template-columns: 1fr !important;
    }

    /* Further reduce padding */
    [style*="padding"],
    section {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }

    /* Ensure nothing overflows */
    * {
        max-width: 100% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    /* Stack hero actions */
    .hero-actions {
        flex-direction: column !important;
        width: 100% !important;
    }

    .hero-actions .btn {
        width: 100% !important;
    }

    /* Footer adjustments */
    .footer-brand img {
        width: 80px !important;
        height: 80px !important;
    }

    .footer-brand {
        min-height: auto !important;
    }

    .footer-section {
        min-height: auto !important;
    }
}