/**
 * Mobile Optimizations
 * Enhanced touch interactions and mobile-specific improvements
 */

/* Improve touch targets */
@media (max-width: 768px) {
    /* Minimum touch target size */
    a, button, input, select, textarea, .clickable {
        min-height: 44px;
        min-width: 44px;
    }

    /* Better button spacing on mobile */
    button, .btn {
        padding: 12px 24px;
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Improve form inputs */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 14px 16px;
    }

    /* Mobile navigation improvements */
    nav {
        -webkit-overflow-scrolling: touch;
    }

    /* Prevent text selection on buttons */
    button, .btn, a.button {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

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

    /* Better image rendering on mobile */
    img {
        image-rendering: -webkit-optimize-contrast;
    }

    /* Mobile-friendly tables */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Fix iOS input shadows */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="search"],
    textarea,
    select {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 8px;
    }

    /* Improve touch feedback */
    .card, .project-card, article {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }

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

    /* Mobile-optimized popup */
    #leadPopupOverlay .max-w-4xl {
        max-width: 95vw !important;
        margin: 0 auto;
    }

    /* Cookie consent mobile */
    #cookieConsentPopup {
        left: 50% !important;
        right: auto !important;
        bottom: 10px !important;
        transform: translateX(-50%) !important;
        max-width: 95vw !important;
    }

    #cookieConsentPopup.translate-y-0 {
        transform: translateX(-50%) translateY(0) !important;
    }

    #cookieConsentPopup.translate-y-full {
        transform: translateX(-50%) translateY(150%) !important;
    }

    /* Mobile hamburger menu */
    .mobile-menu-button {
        padding: 8px;
        -webkit-tap-highlight-color: transparent;
    }

    /* Better card stacking */
    .grid {
        gap: 16px !important;
    }

    /* Mobile hero adjustments */
    .hero h1, .text-5xl, .text-6xl {
        font-size: 2rem !important;
        line-height: 1.2 !important;
    }

    .hero p, .text-xl {
        font-size: 1rem !important;
    }

    /* Sticky header on mobile */
    nav.sticky {
        position: sticky;
        top: 0;
        z-index: 1000;
    }

    /* Better footer spacing */
    footer {
        padding-bottom: 80px; /* Space for WhatsApp button */
    }

    /* Improve popup close buttons - target only button elements */
    .popup-close, button[onclick*="closeLeadPopup"], button[onclick*="closeCookiePopup"] {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mobile-optimized statistics */
    .stat-card {
        margin-bottom: 16px;
    }

    /* Better mobile search */
    .search-form input {
        margin-bottom: 12px;
    }

    /* Optimize dropdown on mobile */
    select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: right 12px center;
        padding-right: 36px;
    }
}

/* Landscape mobile optimizations */
@media (max-width: 896px) and (orientation: landscape) {
    .hero {
        min-height: 400px;
    }

    #leadPopupOverlay {
        padding: 20px 0;
        overflow-y: auto;
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
    /* Better grid layouts */
    .grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .grid-cols-3 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Tablet-friendly spacing */
    .container {
        padding: 0 24px;
    }
}

/* Fix iOS Safari bounce effect */
body {
    overscroll-behavior-y: none;
}

/* Prevent zoom on input focus (iOS) */
@media screen and (max-width: 768px) {
    @supports (-webkit-touch-callout: none) {
        input, select, textarea {
            font-size: 16px !important;
        }
    }
}

/* Safe area for notched devices */
@supports (padding: max(0px)) {
    /* Removed body padding to allow full-width header and hero */
    /* Content sections handle their own padding */

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

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .border {
        border-width: 2px;
    }

    button, .btn {
        border: 2px solid currentColor;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    /* Auto dark mode adjustments if needed */
}

/* Print optimizations */
@media print {
    header, footer, .no-print, #whatsappButton, #cookieConsentPopup, #leadPopupOverlay {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    a {
        text-decoration: underline;
    }

    a[href]:after {
        content: " (" attr(href) ")";
    }
}
