/* ==========================================
   ENHANCED RESPONSIVE STYLES - ALL DEVICES
   ========================================== */

/* ==========================================
   MOBILE FIRST APPROACH - BASE STYLES
   ========================================== */

/* Ensure proper viewport handling */
* {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

/* Prevent horizontal scroll on mobile */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

/* Better touch targets for mobile */
button,
.btn,
a,
input,
textarea,
select {
    min-height: 44px;
    touch-action: manipulation;
}

/* ==========================================
   IPAD MINI (768px x 1024px)
   ========================================== */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    /* iPad Mini Portrait Specific Styles */

    .hero-content {
        padding: 60px 40px;
        grid-template-columns: 1fr;
        gap: 50px;
    }

    .hero h1 {
        font-size: 45px;
        line-height: 1.2;
    }

    .hero-card {
        max-width: 600px;
        margin: 0 auto;
        padding: 35px;
    }

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

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

    .projects-gallery {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }

    .container {
        max-width: 100%;
        padding: 0 40px;
    }

    .why-content {
        grid-template-columns: 1fr;
        gap: 50px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 30px;
    }
}

@media (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    /* iPad Mini Landscape Specific Styles */

    .hero-content {
        padding: 60px 50px;
        grid-template-columns: 1fr 1fr;
        gap: 60px;
    }

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

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

/* ==========================================
   IPAD AIR & IPAD PRO 11" (820px x 1180px)
   ========================================== */
@media (min-width: 820px) and (max-width: 1180px) {

    /* Navigation optimization for iPad Air */
    .header-content {
        height: 85px;
        padding: 0 40px;
    }

    /* Show desktop nav on iPad Air landscape */
    @media (orientation: landscape) {
        nav {
            display: flex;
            gap: 5px;
        }

        nav > a,
        .nav-dropdown-trigger {
            padding: 8px 14px;
            font-size: 14px;
        }

        .mobile-menu-btn {
            display: none;
        }

        .header-content > .btn-primary {
            display: inline-flex;
            padding: 12px 20px;
            font-size: 14px;
        }
    }

    /* Portrait mode - use mobile menu */
    @media (orientation: portrait) {
        nav {
            display: none;
        }

        .mobile-menu-btn {
            display: block;
        }

        .header-content > .btn-primary {
            display: none;
        }
    }

    .hero h1 {
        font-size: 48px;
    }

    .section-header h2 {
        font-size: 38px;
    }

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

    .partners-grid {
        gap: 35px;
    }
}

/* ==========================================
   IPAD PRO 12.9" (1024px x 1366px)
   ========================================== */
@media (min-width: 1024px) and (max-width: 1366px) {

    .container {
        max-width: 1200px;
        padding: 0 50px;
    }

    .hero-content {
        max-width: 1200px;
        padding: 80px 50px;
    }

    @media (orientation: portrait) {
        .hero-content {
            grid-template-columns: 1fr;
            gap: 60px;
        }

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

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

    @media (orientation: landscape) {
        .hero-content {
            grid-template-columns: 1.2fr 1fr;
        }

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

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

/* ==========================================
   MOBILE PHONES - ENHANCED
   ========================================== */

/* Small Phones (320px - 375px) */
@media (max-width: 375px) {

    .container {
        padding: 0 15px;
    }

    .header-content {
        padding: 0 15px;
        height: 65px;
    }

    .logo {
        height: 45px;
    }

    .logo img {
        height: 100%;
        max-height: 45px;
    }

    .hero h1 {
        font-size: 26px;
        line-height: 1.3;
    }

    .hero p {
        font-size: 14px;
        line-height: 1.6;
    }

    .hero-card {
        padding: 25px 20px;
        border-radius: 12px;
    }

    .hero-form input,
    .hero-form textarea {
        padding: 14px 16px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .btn {
        padding: 14px 20px;
        font-size: 14px;
    }

    .section-header h2 {
        font-size: 24px;
        line-height: 1.3;
    }

    .service-card {
        padding: 25px 20px;
    }

    /* Stack all buttons vertically on very small screens */
    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Medium Phones (375px - 428px) including iPhone 12/13/14 */
@media (min-width: 375px) and (max-width: 428px) {

    .hero h1 {
        font-size: 30px;
    }

    .hero-content {
        padding: 50px 20px;
    }

    .section-header h2 {
        font-size: 28px;
    }

    .service-card {
        padding: 30px 25px;
    }

    .hero-features {
        gap: 10px;
    }

    .hero-feature {
        font-size: 13px;
        padding: 10px 14px;
    }
}

/* Large Phones (428px - 480px) including iPhone Pro Max */
@media (min-width: 428px) and (max-width: 480px) {

    .hero h1 {
        font-size: 32px;
    }

    .hero p {
        font-size: 16px;
    }

    .section-header h2 {
        font-size: 30px;
    }

    .hero-card {
        padding: 35px 25px;
    }
}

/* ==========================================
   ENHANCED MOBILE MENU
   ========================================== */
@media (max-width: 1024px) {

    .mobile-menu {
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        background: white;
        box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    }

    .mobile-menu.active {
        animation: slideDown 0.3s ease;
    }

    .mobile-menu > a,
    .mobile-menu-link {
        padding: 18px 20px;
        font-size: 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        border-bottom: 1px solid rgba(0,0,0,0.05);
    }

    .mobile-menu > a:active,
    .mobile-menu-link:active {
        background: var(--cream);
    }

    .mobile-submenu {
        padding: 15px 0;
        background: rgba(250, 248, 245, 0.5);
    }

    .mobile-submenu a {
        padding: 12px 30px;
        font-size: 15px;
    }

    .mobile-submenu a:active {
        background: white;
    }

    /* Better hamburger menu button */
    .mobile-menu-btn {
        width: 48px;
        height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 8px;
    }

    .mobile-menu-btn svg {
        width: 24px;
        height: 24px;
    }

    .mobile-menu-btn:active {
        background: var(--cream);
        transform: scale(0.95);
    }
}

/* ==========================================
   RESPONSIVE IMAGES
   ========================================== */
@media (max-width: 768px) {

    /* Optimize hero background images */
    .hero-background img {
        object-position: center;
    }

    /* Service images */
    .service-with-image .service-image {
        height: 160px;
        margin: -20px -20px 20px;
    }

    /* Showcase images */
    .showcase-item {
        aspect-ratio: 16/9;
    }

    /* Project images */
    .projects-gallery .project-image {
        height: 200px;
    }

    /* Testimonial images */
    .testimonial-image {
        height: 150px;
    }

    /* Banner images */
    .image-banner {
        height: 350px;
    }
}

/* ==========================================
   RESPONSIVE FORMS & CTA QUOTE SECTION FIX
   ========================================== */

/* Fix CTA Quote Forms on all screen sizes */
@media (max-width: 1200px) {
    .cta-section .cta-content {
        grid-template-columns: 1fr !important;
        gap: 40px;
    }

    .cta-section .cta-form {
        max-width: 600px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {

    /* Ensure all form inputs are touch-friendly */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 14px 16px !important;
        border-radius: 8px;
        width: 100% !important;
        -webkit-appearance: none;
        appearance: none;
        box-sizing: border-box;
        margin-bottom: 12px;
        border: 2px solid #e8e4df !important;
    }

    /* Stack form rows on mobile */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0;
    }

    .form-row input {
        width: 100% !important;
        margin-bottom: 12px;
    }

    /* Full-width submit buttons */
    .hero-form .btn,
    .contact-form .btn,
    .cta-form .btn {
        width: 100% !important;
        padding: 16px !important;
        font-size: 16px !important;
        justify-content: center;
        margin-top: 10px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    /* Better select dropdowns */
    select {
        background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
        background-repeat: no-repeat;
        background-position: right 16px center;
        background-size: 20px;
        padding-right: 48px !important;
    }

    /* CTA Section Quote Form Specific Fixes */
    .cta-section {
        padding: 60px 0;
    }

    .cta-section .container {
        padding: 0 20px;
    }

    .cta-section .cta-content {
        background: white;
        border-radius: 16px;
        padding: 40px 20px !important;
        display: flex;
        flex-direction: column;
        gap: 25px;
    }

    .cta-section .cta-text {
        text-align: center;
    }

    .cta-section .cta-text h2 {
        font-size: 26px;
        margin-bottom: 10px;
        line-height: 1.2;
    }

    .cta-section .cta-text p {
        font-size: 15px;
        color: #6a6a6a;
    }

    .cta-section .cta-form {
        width: 100% !important;
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    .cta-section .cta-form input,
    .cta-section .cta-form textarea,
    .cta-section .cta-form select {
        width: 100% !important;
        box-sizing: border-box !important;
        margin-bottom: 12px;
    }

    .cta-section .cta-form textarea {
        min-height: 100px;
        resize: vertical;
    }

    .cta-section .cta-form .btn {
        margin-top: 8px;
        width: 100% !important;
        min-height: 50px;
    }

    /* Fix placeholder text */
    .cta-form input::placeholder,
    .cta-form textarea::placeholder {
        color: #999;
        opacity: 1;
    }
}

@media (max-width: 480px) {
    .cta-section .cta-content {
        padding: 30px 15px !important;
        border-radius: 12px;
    }

    .cta-section .cta-text h2 {
        font-size: 22px;
    }

    .cta-section .cta-text p {
        font-size: 14px;
    }

    .cta-form input,
    .cta-form textarea,
    .cta-form select {
        padding: 12px 14px !important;
    }
}

@media (max-width: 375px) {
    .cta-section .cta-content {
        padding: 25px 12px !important;
    }

    .cta-section .cta-text h2 {
        font-size: 20px;
    }
}

/* ==========================================
   RESPONSIVE TYPOGRAPHY
   ========================================== */

/* Fluid typography for better readability */
@media (min-width: 320px) and (max-width: 1200px) {

    h1 {
        font-size: clamp(28px, 5vw + 1rem, 58px);
    }

    h2 {
        font-size: clamp(24px, 4vw + 0.5rem, 44px);
    }

    h3 {
        font-size: clamp(20px, 3vw + 0.5rem, 32px);
    }

    p {
        font-size: clamp(14px, 1.5vw + 0.5rem, 18px);
    }

    .hero p {
        font-size: clamp(15px, 2vw + 0.5rem, 18px);
    }
}

/* ==========================================
   RESPONSIVE SPACING
   ========================================== */

/* Dynamic spacing based on screen size */
@media (max-width: 768px) {
    section {
        padding: 60px 0;
    }

    .section-header {
        margin-bottom: 40px;
    }

    .cta-section {
        padding: 60px 0;
    }

    footer {
        padding: 60px 0 20px;
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    section {
        padding: 80px 0;
    }

    .section-header {
        margin-bottom: 50px;
    }
}

/* ==========================================
   RESPONSIVE GRIDS
   ========================================== */

/* Services Grid - Progressive Enhancement */
@media (min-width: 480px) and (max-width: 768px) {
    .services-grid {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

@media (min-width: 768px) and (max-width: 1024px) {
    .services-grid {
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    }
}

/* Projects Grid - Progressive Enhancement */
@media (min-width: 480px) and (max-width: 768px) {
    .projects-gallery {
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    }
}

/* ==========================================
   LANDSCAPE ORIENTATION FIXES
   ========================================== */

/* Small devices in landscape */
@media (max-height: 500px) and (orientation: landscape) {

    .hero {
        min-height: 100vh;
    }

    .hero-content {
        padding: 40px;
    }

    .hero h1 {
        font-size: 32px;
    }

    .hero-card {
        display: none; /* Hide form on small landscape to save space */
    }
}

/* Tablets in landscape */
@media (min-width: 768px) and (max-width: 1024px) and (orientation: landscape) {

    .hero-content {
        grid-template-columns: 1fr 1fr;
        gap: 50px;
    }

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

/* ==========================================
   ACCESSIBILITY IMPROVEMENTS
   ========================================== */

/* Better focus states for mobile */
@media (max-width: 1024px) {

    *:focus {
        outline: 3px solid var(--accent);
        outline-offset: 2px;
    }

    button:focus,
    .btn:focus {
        box-shadow: 0 0 0 3px rgba(165, 67, 86, 0.5);
    }
}

/* ==========================================
   PERFORMANCE OPTIMIZATIONS
   ========================================== */

/* Reduce animations on mobile for better performance */
@media (max-width: 768px) {
    * {
        animation-duration: 0.3s !important;
    }

    /* Disable parallax effects on mobile */
    .hero-background,
    .banner-container {
        transform: none !important;
    }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation: none !important;
        transition: none !important;
    }
}

/* ==========================================
   SPECIAL DEVICE FIXES
   ========================================== */

/* iPhone X/11/12/13/14 Safe Areas */
@supports (padding: max(0px)) {
    .header-content,
    .container,
    .footer-grid {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .mobile-menu {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    footer {
        padding-bottom: max(30px, env(safe-area-inset-bottom));
    }
}

/* Samsung Galaxy Fold */
@media (max-width: 280px) {
    .container {
        padding: 0 10px;
    }

    .hero h1 {
        font-size: 22px;
    }

    .btn {
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* Surface Duo */
@media (min-width: 540px) and (max-width: 720px) {
    .services-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* ==========================================
   CONTENT SECTIONS - MOBILE FIX
   ========================================== */

/* Fix content sections on all pages for mobile devices */
@media (max-width: 1200px) {
    .content-section .content-grid {
        grid-template-columns: 1fr !important;
        gap: 50px;
    }

    .content-section .content-grid.reverse {
        direction: ltr !important;
    }
}

@media (max-width: 1024px) {
    .content-section .content-grid {
        grid-template-columns: 1fr !important;
        gap: 40px;
    }

    .content-section .content-text {
        order: 1;
        width: 100%;
        max-width: 100%;
    }

    .content-section .content-image {
        order: 2;
        width: 100%;
        height: 300px;
        margin: 0 auto;
    }
}

@media (max-width: 768px) {
    .content-section {
        padding: 60px 0;
    }

    .content-section .content-grid {
        display: flex !important;
        flex-direction: column;
        gap: 30px;
    }

    .content-section .content-text {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0;
    }

    .content-section .content-text h2 {
        font-size: 28px;
        margin-bottom: 15px;
    }

    .content-section .content-text p {
        font-size: 15px;
        line-height: 1.6;
        margin-bottom: 15px;
    }

    .content-section .content-text ul {
        margin: 20px 0;
        padding: 0;
    }

    .content-section .content-text li {
        font-size: 14px;
        padding: 8px 0;
        display: flex;
        align-items: flex-start;
        gap: 10px;
    }

    .content-section .content-text li svg {
        flex-shrink: 0;
        margin-top: 2px;
    }

    .content-section .content-image {
        width: 100% !important;
        height: 200px;
        border-radius: 12px;
    }

    .content-section .btn {
        margin-top: 20px;
    }
}

@media (max-width: 480px) {
    .content-section {
        padding: 50px 0;
    }

    .content-section .content-text h2 {
        font-size: 24px;
        line-height: 1.2;
    }

    .content-section .content-text p {
        font-size: 14px;
    }

    .content-section .content-text li {
        font-size: 13px;
    }

    .content-section .content-text li svg {
        width: 18px;
        height: 18px;
        min-width: 18px;
    }

    .content-section .content-image {
        height: 150px;
    }

    .content-section .content-image svg {
        width: 60px;
        height: 60px;
    }

    .content-section .btn {
        width: 100%;
        justify-content: center;
        padding: 14px 20px;
    }
}

@media (max-width: 375px) {
    .content-section .container {
        padding: 0 15px;
    }

    .content-section .content-text h2 {
        font-size: 22px;
    }

    .content-section .content-text p {
        font-size: 13px;
    }

    .content-section .content-text li {
        font-size: 12px;
    }
}

/* ==========================================
   WHY SECTION - MOBILE OVERLAP FIX
   ========================================== */

/* Fix overlapping text in Why Choose Us section */
@media (max-width: 1200px) {
    .why-content {
        grid-template-columns: 1fr;
        gap: 50px;
    }

    .why-image-card {
        max-width: 700px;
        margin: 0 auto;
    }
}

@media (max-width: 1024px) {
    .why-content {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .why-text {
        order: 1;
        text-align: center;
    }

    .why-image {
        order: 2;
    }

    .why-features {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .why-image-card {
        max-width: 600px;
        margin: 0 auto;
        padding: 40px 30px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }

    .stat-item {
        padding: 20px 15px;
    }

    .stat-number {
        font-size: 40px;
    }

    .stat-label {
        font-size: 13px;
    }
}

@media (max-width: 768px) {
    .why-section {
        padding: 60px 0;
    }

    .why-content {
        grid-template-columns: 1fr !important;
        gap: 30px;
    }

    .why-text {
        text-align: left;
    }

    .why-text h2 {
        font-size: 28px;
        margin-bottom: 15px;
    }

    .why-text > p {
        font-size: 15px;
        margin-bottom: 25px;
    }

    .why-features {
        gap: 20px;
        margin-bottom: 30px;
    }

    .why-feature {
        gap: 15px;
    }

    .why-icon {
        width: 50px;
        height: 50px;
        min-width: 50px;
    }

    .why-feature h4 {
        font-size: 16px;
        margin-bottom: 3px;
    }

    .why-feature p {
        font-size: 13px;
        line-height: 1.4;
    }

    .why-image {
        width: 100%;
    }

    .why-image-card {
        width: 100%;
        max-width: 100%;
        padding: 30px 20px;
        border-radius: 12px;
        box-sizing: border-box;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }

    .stat-item {
        padding: 15px 10px;
        text-align: center;
    }

    .stat-number {
        font-size: 32px;
        margin-bottom: 5px;
        line-height: 1;
    }

    .stat-label {
        font-size: 12px;
        line-height: 1.3;
    }
}

@media (max-width: 480px) {
    .why-text h2 {
        font-size: 24px;
        line-height: 1.2;
    }

    .why-text > p {
        font-size: 14px;
    }

    .why-features {
        gap: 15px;
        margin-bottom: 25px;
    }

    .why-feature {
        gap: 12px;
    }

    .why-icon {
        width: 45px;
        height: 45px;
        min-width: 45px;
    }

    .why-feature h4 {
        font-size: 15px;
    }

    .why-feature p {
        font-size: 12px;
    }

    .why-image-card {
        padding: 25px 15px;
    }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }

    .stat-item {
        padding: 12px 8px;
    }

    .stat-number {
        font-size: 28px;
    }

    .stat-label {
        font-size: 11px;
    }
}

/* Very small screens (iPhone SE, Galaxy Fold) */
@media (max-width: 375px) {
    .why-section {
        padding: 50px 0;
    }

    .why-text h2 {
        font-size: 22px;
    }

    .why-icon {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .why-feature h4 {
        font-size: 14px;
    }

    .why-feature p {
        font-size: 11px;
    }

    .why-image-card {
        padding: 20px 12px;
    }

    .stat-number {
        font-size: 24px;
    }

    .stat-label {
        font-size: 10px;
    }
}

@media (max-width: 320px) {
    .stat-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-number {
        font-size: 28px;
    }

    .stat-label {
        font-size: 11px;
    }
}

/* ==========================================
   PRINT STYLES
   ========================================== */
@media print {
    .top-bar,
    .mobile-menu-btn,
    .mobile-menu,
    .hero-form,
    .cta-form,
    .footer-social {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    .container {
        max-width: 100%;
        padding: 0;
    }
}