/* Enhanced Responsive Design - Comprehensive Fixes */

/* Better Breakpoint System */
@media (max-width: 1400px) {
    .container {
        max-width: 1320px;
    }
}

@media (max-width: 1200px) {
    .container {
        max-width: 1140px;
        padding: 0 2rem;
    }
    
    .hero-wrapper {
        gap: 3rem;
    }
}

@media (max-width: 992px) {
    .container {
        max-width: 960px;
        padding: 0 1.5rem;
    }
    
    /* Fix grid layouts */
    .services-grid,
    .features-grid,
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .hero-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 1rem;
    }
    
    /* Single column layouts */
    .services-grid,
    .features-grid,
    .portfolio-grid,
    .blog-grid,
    .region-features {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    
    /* Hero improvements */
    .hero {
        padding: 2rem 0 !important;
        min-height: auto !important;
    }
    
    .hero-title {
        font-size: clamp(1.75rem, 6vw, 2.5rem) !important;
        line-height: 1.2 !important;
        margin-bottom: 1rem !important;
    }
    
    .hero-subtitle {
        font-size: clamp(1rem, 2.5vw, 1.125rem) !important;
        margin-bottom: 2rem !important;
    }
    
    .hero-cta {
        flex-direction: column;
        gap: 1rem;
    }
    
    .hero-cta .btn {
        width: 100%;
    }
    
    /* Stats improvements */
    .hero-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
        margin-top: 2rem !important;
    }
    
    .stat-item {
        padding: 1rem !important;
    }
    
    .stat-number {
        font-size: 1.5rem !important;
    }
    
    .stat-label {
        font-size: 0.8rem !important;
    }
    
    /* Section titles */
    .section-title {
        font-size: clamp(1.5rem, 5vw, 2rem) !important;
        margin-bottom: 2rem !important;
    }
    
    /* Service cards */
    .service-card {
        padding: 1.5rem !important;
    }
    
    .service-icon-3d {
        width: 60px !important;
        height: 60px !important;
        font-size: 2rem !important;
        margin-bottom: 1rem !important;
    }
    
    /* Industry cards */
    .industry-card {
        padding: 1.5rem !important;
    }
    
    .industry-icon-3d {
        width: 70px !important;
        height: 70px !important;
        font-size: 2.5rem !important;
    }
    
    /* Contact form */
    .contact-wrapper {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
    }
    
    .contact-form {
        padding: 1.5rem !important;
    }
    
    /* Page hero */
    .page-hero {
        padding: 2rem 0 !important;
    }
    
    .page-hero h1 {
        font-size: clamp(1.5rem, 5vw, 2rem) !important;
    }
    
    /* Buttons */
    .btn {
        padding: 0.875rem 1.5rem !important;
        font-size: 0.95rem !important;
    }
    
    /* Footer */
    .footer-top,
    .footer-content {
        grid-template-columns: 1fr !important;
        gap: 2rem !important;
        text-align: left;
    }
    
    /* Process steps */
    .process-steps,
    .workflow-3d {
        flex-direction: column;
        gap: 2rem;
    }
    
    .workflow-step-3d::before {
        display: none;
    }
    
    /* Building 3D */
    .building-3d {
        height: 200px;
    }
    
    .building-block {
        width: 40px;
    }
}

@media (max-width: 576px) {
    .container {
        padding: 0 0.75rem;
    }
    
    .hero-stats {
        grid-template-columns: 1fr !important;
    }
    
    .section-title {
        font-size: 1.5rem !important;
    }
    
    .service-card,
    .industry-card {
        padding: 1.25rem !important;
    }
    
    .btn {
        padding: 0.75rem 1.25rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Hide 3D elements on very small screens for performance */
    .hero-3d-container,
    .particles-3d {
        display: none;
    }
}

/* Tablet specific optimizations */
@media (min-width: 769px) and (max-width: 1024px) {
    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
    
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .hero-wrapper {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .hero-image-wrapper {
        order: -1;
    }
}

/* Large screen optimizations */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
    }
    
    .hero-title {
        font-size: clamp(3rem, 5vw, 4rem);
    }
    
    .section-title {
        font-size: clamp(2.5rem, 4vw, 3rem);
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: auto !important;
        padding: 1.5rem 0 !important;
    }
    
    .hero-stats {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .service-icon-3d,
    .industry-icon-3d {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    .btn,
    a,
    button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .service-card:hover,
    .industry-card:hover {
        transform: none;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    /* Can be implemented if dark mode is desired */
}

/* Print optimizations */
@media print {
    .header,
    .footer,
    .btn,
    .mobile-menu-toggle,
    .hero-3d-container,
    .particles-3d,
    .back-to-top {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
        color: #000;
        background: #fff;
    }
    
    a {
        text-decoration: underline;
        color: #000;
    }
    
    .section-title {
        page-break-after: avoid;
    }
    
    .service-card,
    .industry-card {
        page-break-inside: avoid;
    }
}

/* Fix overflow issues */
* {
    max-width: 100%;
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Better text wrapping */
p, li, td, th {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Fix table responsiveness */
table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
}

@media (max-width: 768px) {
    table {
        font-size: 0.875rem;
    }
}

/* Improve form responsiveness */
.form-group {
    width: 100%;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    box-sizing: border-box;
}

/* Better grid fallbacks */
.grid-auto-fit {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

@media (max-width: 768px) {
    .grid-auto-fit {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

/* Fix flexbox issues */
.flex-container {
    display: flex;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .flex-container {
        flex-direction: column;
    }
}

/* Better spacing on mobile */
@media (max-width: 768px) {
    section {
        padding: 3rem 0 !important;
    }
    
    .section-spacing {
        padding: 2rem 0 !important;
    }
}

/* Improve readability on small screens */
@media (max-width: 576px) {
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    h1 {
        font-size: 1.75rem;
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem;
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem;
        line-height: 1.4;
    }
}

