/* ===== Comprehensive Responsive Design ===== */
/* Optimized for Desktop, Tablet, and Mobile */

/* ===== DESKTOP FIRST OPTIMIZATIONS ===== */
/* Large Desktop (1400px and above) */
@media (min-width: 1400px) {
    .container {
        max-width: 1320px;
        padding: 0 2rem;
    }

    .hero-title {
        font-size: 4rem;
        line-height: 1.1;
    }

    .hero-subtitle {
        font-size: 1.375rem;
        max-width: 600px;
        margin: 0 auto 3rem;
    }

    .section-title {
        font-size: 3rem;
    }

    .services-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2.5rem;
    }

    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2.5rem;
    }

    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2.5rem;
    }
}

/* Standard Desktop (1200px to 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
    .container {
        max-width: 1200px;
        padding: 0 1.5rem;
    }

    .hero-title {
        font-size: 3.5rem;
        line-height: 1.1;
    }

    .hero-subtitle {
        font-size: 1.25rem;
        max-width: 550px;
        margin: 0 auto 2.5rem;
    }

    .services-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }

    .projects-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }

    .testimonials-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 2rem;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }
}

/* Medium Desktop (992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
    .container {
        max-width: 960px;
        padding: 0 1.5rem;
    }

    .hero-title {
        font-size: 3rem;
        line-height: 1.2;
    }

    .hero-subtitle {
        font-size: 1.125rem;
        max-width: 500px;
        margin: 0 auto 2rem;
    }

    .services-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }

    /* Navigation adjustments */
    .nav-menu {
        gap: 1.5rem;
    }

    .nav-link {
        padding: 0.5rem 1rem;
        font-size: 0.95rem;
    }
}

/* ===== TABLET OPTIMIZATIONS ===== */
/* Large Tablet (768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .container {
        max-width: 720px;
        padding: 0 1.5rem;
    }

    .hero {
        min-height: 80vh;
        padding-top: 100px;
    }

    .hero-title {
        font-size: 2.5rem;
        line-height: 1.2;
        margin-bottom: 1.5rem;
    }

    .hero-subtitle {
        font-size: 1.125rem;
        margin-bottom: 2rem;
    }

    .hero-buttons {
        flex-direction: row;
        gap: 1rem;
        justify-content: center;
    }

    .hero-buttons .btn {
        flex: 1;
        max-width: 200px;
    }

    .services-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .projects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .testimonials-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 1rem;
    }

    /* Navigation stays desktop-style */
    .mobile-menu-btn {
        display: none;
    }

    .nav-menu {
        position: static;
        flex-direction: row;
        background: transparent;
        height: auto;
        width: auto;
        padding: 0;
        box-shadow: none;
        border: none;
    }

    /* Contact form optimization */
    .contact-grid {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }

    .form-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }
}

/* ===== MOBILE OPTIMIZATIONS ===== */
/* Large Mobile (576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
    .container {
        max-width: 540px;
        padding: 0 1rem;
    }

    .hero {
        min-height: 100vh;
        padding-top: 90px;
        display: flex;
        align-items: center;
    }

    .hero-title {
        font-size: clamp(2rem, 6vw, 2.5rem);
        line-height: 1.2;
        margin-bottom: 1rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 2rem;
    }

    .hero-buttons {
        flex-direction: column;
        gap: 1rem;
        align-items: center;
    }

    .hero-buttons .btn {
        width: 100%;
        max-width: 280px;
        padding: 1rem 2rem;
    }

    /* Grid layouts */
    .services-grid,
    .projects-grid,
    .testimonials-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    /* Mobile Navigation */
    .mobile-menu-btn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        width: 44px;
        height: 44px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
        border-radius: 8px;
        transition: background-color 0.3s ease;
    }

    .mobile-menu-btn:hover {
        background-color: var(--bg-secondary);
    }

    .mobile-menu-btn span {
        width: 20px;
        height: 2px;
        background: var(--text-primary);
        margin: 2px 0;
        transition: all 0.3s ease;
    }

    /* Animated hamburger */
    .mobile-menu-btn.active span:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px);
    }

    .mobile-menu-btn.active span:nth-child(2) {
        opacity: 0;
    }

    .mobile-menu-btn.active span:nth-child(3) {
        transform: rotate(-45deg) translate(7px, -6px);
    }

    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 100vw;
        height: calc(100vh - 70px);
        background: var(--bg-primary);
        transition: left 0.3s ease;
        padding: 2rem 1.5rem;
        overflow-y: auto;
        flex-direction: column;
        z-index: 999;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }

    .nav-menu.active {
        left: 0;
    }

    .nav-menu li {
        width: 100%;
        margin-bottom: 0.5rem;
    }

    .nav-link {
        display: block;
        padding: 1rem 0;
        font-size: 1.1rem;
        border-bottom: 1px solid var(--border-color);
        transition: all 0.3s ease;
    }

    .nav-link:hover,
    .nav-link.active {
        color: var(--accent-color);
        padding-left: 1rem;
    }

    /* Contact form */
    .contact-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .form-row {
        display: block;
    }

    .form-group {
        margin-bottom: 1.5rem;
    }
}

/* Small Mobile (up to 575px) */
@media (max-width: 575px) {
    .container {
        padding: 0 1rem;
    }

    .hero {
        min-height: 100vh;
        padding-top: 80px;
        display: flex;
        align-items: center;
    }

    .hero-title {
        font-size: clamp(1.75rem, 8vw, 2.25rem);
        line-height: 1.2;
        margin-bottom: 1rem;
    }

    .hero-subtitle {
        font-size: 1rem;
        line-height: 1.6;
        margin-bottom: 1.5rem;
    }

    .section-title {
        font-size: clamp(1.5rem, 6vw, 2rem);
        line-height: 1.3;
    }

    .section-subtitle {
        font-size: 0.95rem;
        line-height: 1.6;
    }

    /* All grids single column */
    .services-grid,
    .projects-grid,
    .testimonials-grid,
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Buttons */
    .btn {
        padding: 0.875rem 1.5rem;
        font-size: 0.95rem;
    }

    .btn-large {
        padding: 1rem 2rem;
        font-size: 1rem;
    }

    /* Cards */
    .service-card,
    .project-card,
    .testimonial-card {
        padding: 1.25rem;
        border-radius: 12px;
    }

    /* Navigation */
    .navbar {
        padding: 0.5rem 0;
    }

    .nav-wrapper {
        padding: 0.75rem 1rem;
    }

    .logo {
        font-size: 1.125rem;
    }

    .nav-menu {
        padding: 1.5rem 1rem;
        top: 60px;
        height: calc(100vh - 60px);
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        text-align: center;
    }

    .social-links {
        justify-content: center;
        gap: 1rem;
    }
}

/* Extra Small Mobile (up to 320px) */
@media (max-width: 320px) {
    .container {
        padding: 0 0.75rem;
    }

    .hero-title {
        font-size: 1.5rem;
        line-height: 1.3;
    }

    .hero-subtitle {
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.75rem 1.25rem;
        font-size: 0.9rem;
    }

    .service-card,
    .project-card,
    .testimonial-card {
        padding: 1rem;
    }

    section {
        padding: 2rem 0;
    }
}

/* ===== UNIVERSAL RESPONSIVE ELEMENTS ===== */

/* Improved Touch Targets for All Mobile Devices */
@media (max-width: 768px) {
    .btn,
    .nav-link,
    .social-link,
    .mobile-menu-btn {
        min-height: 44px;
        min-width: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        touch-action: manipulation;
    }

    /* Fixed Navigation */
    .navbar {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        border-bottom: 1px solid var(--border-color);
    }

    [data-theme="dark"] .navbar {
        background: rgba(10, 10, 10, 0.95);
    }

    /* Ensure content doesn't hide behind fixed navbar */
    main,
    .hero {
        padding-top: 80px;
    }

    /* Form optimizations */
    .form-group input,
    .form-group textarea,
    .form-group select {
        width: 100%;
        padding: 1rem;
        border: 2px solid var(--border-color);
        border-radius: 8px;
        font-size: 16px; /* Prevents zoom on iOS */
        background: var(--bg-primary);
        color: var(--text-primary);
        transition: border-color 0.3s ease, box-shadow 0.3s ease;
    }

    .form-group input:focus,
    .form-group textarea:focus,
    .form-group select:focus {
        outline: none;
        border-color: var(--accent-color);
        box-shadow: 0 0 0 3px rgba(135, 197, 230, 0.1);
    }
}

/* Landscape orientation specific styles */
@media (max-width: 768px) and (orientation: landscape) {
    .hero {
        min-height: 80vh;
        padding-top: 60px;
    }

    .nav-menu {
        height: calc(100vh - 50px);
        top: 50px;
    }

    .navbar {
        padding: 0.25rem 0;
    }
}

/* Touch device specific improvements */
@media (hover: none) and (pointer: coarse) {
    .btn:hover,
    .service-card:hover,
    .project-card:hover {
        transform: none;
    }

    .btn:active {
        transform: scale(0.98);
    }

    .service-card:active,
    .project-card:active {
        transform: scale(0.98);
    }
}

/* High-DPI/Retina Display Optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo,
    .btn,
    .service-icon,
    .social-link svg {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .mobile-menu-btn,
    .theme-toggle,
    .hero-buttons,
    .cta-section {
        display: none !important;
    }

    .hero {
        padding-top: 0;
    }

    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
}

/* Performance optimizations for all devices */
* {
    -webkit-tap-highlight-color: transparent;
}

img {
    height: auto;
    max-width: 100%;
    object-fit: cover;
}

html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

body {
    overflow-x: hidden;
}

/* Better text readability across all devices */
p, li {
    line-height: 1.6;
    max-width: 65ch; /* Optimal reading length */
}

h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
    margin-bottom: 1rem;
}

/* Smooth transitions for theme switching */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Focus management for accessibility */
:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* Skip to main content link for accessibility */
.skip-to-main {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--accent-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    transition: top 0.3s ease;
}

.skip-to-main:focus {
    top: 6px;
}