/* ============================================
   COMPREHENSIVE RESPONSIVE UTILITIES
   Makes EVERYTHING responsive - no hardcoded widths
   ============================================ */

/* ============================================
   1. RESPONSIVE GRID SYSTEM
   Auto-adapts to screen size
   ============================================ */

/* Responsive Grid - Auto Columns */
.grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--space-xl, 2rem);
}

.grid-auto-sm {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmin(180px, 1fr));
    gap: var(--space-lg, 1.5rem);
}

.grid-auto-lg {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: var(--space-2xl, 3rem);
}

/* Override Fixed Grid Columns - Make Responsive */
.grid-2,
.grid-3,
.grid-4 {
    display: grid;
    gap: var(--space-xl, 2rem);
}

/* Desktop: Full columns */
@media (min-width: 1200px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

/* Laptop: Reduce columns */
@media (min-width: 992px) and (max-width: 1199px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

/* Tablet: Further reduce */
@media (min-width: 768px) and (max-width: 991px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile: Single column */
@media (max-width: 767px) {
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
        gap: var(--space-lg, 1.5rem);
    }
}

/* ============================================
   2. CONTAINER RESPONSIVE WIDTHS
   ============================================ */

.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 5vw, 2rem);
}

/* Small containers */
.container-sm {
    max-width: 800px;
}

/* Large containers */
.container-lg {
    max-width: 1600px;
}

/* Full width on mobile */
@media (max-width: 576px) {
    .container {
        padding: 0 1rem;
    }
}

/* ============================================
   3. FLEXBOX RESPONSIVE UTILITIES
   ============================================ */

.flex-responsive {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg, 1.5rem);
}

.flex-responsive > * {
    flex: 1 1 calc(50% - var(--space-lg, 1.5rem));
    min-width: 250px;
}

@media (max-width: 768px) {
    .flex-responsive > * {
        flex: 1 1 100%;
        min-width: 100%;
    }
}

/* ============================================
   4. RESPONSIVE TYPOGRAPHY
   ============================================ */

/* Fluid font sizes that scale with viewport */
h1 {
    font-size: clamp(2rem, 6vw, 4.5rem) !important;
    line-height: 1.2;
}

h2 {
    font-size: clamp(1.75rem, 5vw, 3.5rem) !important;
    line-height: 1.2;
}

h3 {
    font-size: clamp(1.5rem, 4vw, 2.5rem) !important;
    line-height: 1.3;
}

h4 {
    font-size: clamp(1.25rem, 3vw, 2rem) !important;
    line-height: 1.4;
}

p {
    font-size: clamp(0.95rem, 2vw, 1.1rem);
    line-height: 1.7;
}

/* ============================================
   5. RESPONSIVE SPACING
   ============================================ */

.section {
    padding: clamp(3rem, 8vw, 6rem) 0 !important;
}

.section-sm {
    padding: clamp(2rem, 5vw, 4rem) 0 !important;
}

.section-lg {
    padding: clamp(4rem, 10vw, 8rem) 0 !important;
}

/* ============================================
   6. CARD RESPONSIVE BEHAVIOR
   ============================================ */

.card,
.hover-lift-card,
.service-card,
.testimonial-card {
    padding: clamp(1.5rem, 4vw, 2.5rem) !important;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* ============================================
   7. BUTTON RESPONSIVE SIZING
   ============================================ */

.btn {
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1.5rem, 4vw, 2rem);
    font-size: clamp(0.9rem, 2vw, 1rem);
    white-space: nowrap;
}

.btn-lg {
    padding: clamp(1rem, 3vw, 1.5rem) clamp(2rem, 5vw, 3rem);
    font-size: clamp(1rem, 2.5vw, 1.25rem);
}

.btn-sm {
    padding: clamp(0.5rem, 1.5vw, 0.75rem) clamp(1rem, 3vw, 1.5rem);
    font-size: clamp(0.85rem, 1.8vw, 0.95rem);
}

/* Responsive button groups */
.btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md, 1rem);
}

@media (max-width: 576px) {
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ============================================
   8. HERO SECTION RESPONSIVE
   ============================================ */

.hero {
    min-height: max(600px, 80vh) !important;
    padding-top: clamp(100px, 15vh, 150px) !important;
    padding-bottom: clamp(2rem, 8vh, 4rem) !important;
}

.hero-content {
    max-width: min(800px, 90vw);
}

.hero-title {
    font-size: clamp(2rem, 8vw, 4.5rem) !important;
    margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.hero-description {
    font-size: clamp(1rem, 3vw, 1.25rem) !important;
    max-width: min(600px, 100%);
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-lg, 1.5rem);
}

@media (max-width: 576px) {
    .hero-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .hero-actions .btn {
        width: 100%;
    }
}

/* ============================================
   9. NAVIGATION RESPONSIVE
   ============================================ */

.nav-container,
.header-container {
    padding: 0 clamp(1rem, 3vw, 2rem) !important;
    gap: clamp(0.5rem, 2vw, 1.5rem);
}

.nav-links {
    gap: clamp(1rem, 3vw, 2rem);
}

/* ============================================
   10. STATS GRID RESPONSIVE
   ============================================ */

.stats-grid {
    display: grid;
    gap: var(--space-xl, 2rem);
}

@media (min-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 768px) and (max-width: 1199px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 767px) {
    .stats-grid { 
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-lg, 1.5rem);
    }
}

@media (max-width: 480px) {
    .stats-grid { 
        grid-template-columns: 1fr;
    }
}

/* ============================================
   11. PORTFOLIO GRID RESPONSIVE
   ============================================ */

.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
    gap: var(--space-xl, 2rem);
}

@media (max-width: 576px) {
    .portfolio-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   12. TECH GRID RESPONSIVE
   ============================================ */

.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-lg, 1.5rem);
}

@media (max-width: 768px) {
    .tech-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: var(--space-md, 1rem);
    }
}

@media (max-width: 480px) {
    .tech-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-sm, 0.5rem);
    }
}

/* ============================================
   13. FOOTER RESPONSIVE
   ============================================ */

.footer-grid {
    display: grid;
    gap: var(--space-2xl, 3rem);
}

@media (min-width: 992px) {
    .footer-grid {
        grid-template-columns: 2fr repeat(3, 1fr);
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-xl, 2rem);
        text-align: center;
    }
    
    .footer-social {
        justify-content: center;
    }
}

/* ============================================
   14. FORM RESPONSIVE
   ============================================ */

.form-group {
    margin-bottom: var(--space-lg, 1.5rem);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: clamp(0.9rem, 2vw, 1rem);
    padding: clamp(0.75rem, 2vw, 1rem) clamp(1rem, 3vw, 1.5rem);
}

/* ============================================
   15. TABLE RESPONSIVE
   ============================================ */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-responsive table {
    min-width: 600px;
    width: 100%;
}

@media (max-width: 768px) {
    .table-responsive {
        border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
        border-radius: 8px;
    }
}

/* ============================================
   16. IMAGE RESPONSIVE
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

.img-fluid {
    width: 100%;
    height: auto;
}

/* ============================================
   17. VIDEO RESPONSIVE
   ============================================ */

.video-responsive {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 ratio */
    height: 0;
    overflow: hidden;
}

.video-responsive iframe,
.video-responsive video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ============================================
   18. MODAL RESPONSIVE
   ============================================ */

.modal-content {
    width: 90vw;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: clamp(1.5rem, 4vw, 2.5rem);
}

@media (max-width: 576px) {
    .modal-content {
        width: 95vw;
        padding: 1.5rem;
        border-radius: 12px;
    }
}

/* ============================================
   19. PREVENT HORIZONTAL SCROLL
   ============================================ */

html,
body {
    max-width: 100vw;
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

/* ============================================
   20. MEGA MENU FULLY RESPONSIVE
   ============================================ */

.mega-menu {
    width: min(95vw, 1100px) !important;
    max-width: 100% !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    box-sizing: border-box;
}

.mega-menu-inner {
    display: grid;
    gap: var(--space-xl, 2rem);
    width: 100%;
}

@media (min-width: 1200px) {
    .mega-menu-inner {
        grid-template-columns: 1fr 1fr 0.8fr;
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .mega-menu {
        width: 90vw !important;
    }
    
    .mega-menu-inner {
        grid-template-columns: 1fr 1fr;
    }
    
    .mega-featured {
        grid-column: 1 / -1;
    }
}

@media (min-width: 768px) and (max-width: 991px) {
    .mega-menu {
        width: 85vw !important;
    }
    
    .mega-menu-inner {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
    .mega-menu {
        position: static !important;
        width: 100% !important;
        transform: none !important;
        left: 0 !important;
        margin: 0 !important;
        padding: var(--space-md) !important;
    }
}

/* ============================================
   21. UTILITIES - RESPONSIVE VISIBILITY
   ============================================ */

/* Hide on mobile */
@media (max-width: 767px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 768px) and (max-width: 991px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 992px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

@media (max-width: 767px) {
    .show-mobile {
        display: block !important;
    }
    
    .show-mobile-flex {
        display: flex !important;
    }
}

/* ============================================
   22. RESPONSIVE GAP UTILITIES
   ============================================ */

.gap-responsive {
    gap: clamp(1rem, 3vw, 2rem);
}

.gap-sm-responsive {
    gap: clamp(0.5rem, 2vw, 1rem);
}

.gap-lg-responsive {
    gap: clamp(1.5rem, 4vw, 3rem);
}

/* ============================================
   23. ASPECT RATIO UTILITIES
   ============================================ */

.aspect-16-9 {
    aspect-ratio: 16 / 9;
    width: 100%;
}

.aspect-4-3 {
    aspect-ratio: 4 / 3;
    width: 100%;
}

.aspect-1-1 {
    aspect-ratio: 1 / 1;
    width: 100%;
}

/* ============================================
   24. RESPONSIVE PADDING/MARGIN UTILITIES
   ============================================ */

.p-responsive {
    padding: clamp(1rem, 4vw, 2rem);
}

.px-responsive {
    padding-left: clamp(1rem, 4vw, 2rem);
    padding-right: clamp(1rem, 4vw, 2rem);
}

.py-responsive {
    padding-top: clamp(1rem, 4vw, 2rem);
    padding-bottom: clamp(1rem, 4vw, 2rem);
}

/* ============================================
   25. SAFE AREA INSETS (for notched devices)
   ============================================ */

@supports (padding: env(safe-area-inset-left)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* ============================================
   26. FINAL CATCH-ALL - NO OVERFLOW
   ============================================ */

*:not(html):not(body):not(.full-width) {
    max-width: 100%;
}

/* Ensure specific elements can be full width */
html,
body,
.full-width,
.w-100 {
    max-width: 100vw !important;
}
