/* ===================================
   iPad Touch Fix - Apple Review Issue
   Fixes button responsiveness on iPad
   =================================== */

/* Target iPad and tablet devices specifically */
@media (min-width: 768px) and (max-width: 1366px) {
    /* Ensure all interactive elements are touchable */
    a, button, .btn, 
    input[type="submit"], 
    input[type="button"],
    .dropdown,
    .profile-button,
    .menu-toggle,
    [onclick],
    [role="button"] {
        cursor: pointer !important;
        -webkit-tap-highlight-color: rgba(194, 139, 82, 0.2);
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        touch-action: manipulation;
        pointer-events: auto !important;
    }
    
    /* Ensure buttons have proper touch targets */
    button, .btn, a.btn {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Fix dropdown menus for touch */
    .dropdown {
        position: relative;
        touch-action: manipulation;
    }
    
    .dropdown-menu {
        touch-action: manipulation;
        pointer-events: auto !important;
    }
    
    /* Ensure profile button is clickable */
    .profile-button {
        touch-action: manipulation;
        cursor: pointer;
        pointer-events: auto !important;
    }
    
    /* Fix any potential overlay issues */
    header {
        pointer-events: auto !important;
    }
    
    .navbar {
        pointer-events: auto !important;
    }
    
    .navbar-nav {
        pointer-events: auto !important;
    }
    
    /* Ensure all navigation items are touchable */
    .navbar-nav li,
    .navbar-nav li a {
        touch-action: manipulation;
        pointer-events: auto !important;
    }
    
    /* Fix form elements */
    input, select, textarea {
        touch-action: manipulation;
        pointer-events: auto !important;
    }
    
    /* Prevent any overlays from blocking interaction */
    body::before,
    body::after,
    main::before,
    main::after {
        pointer-events: none !important;
    }
    
    /* Ensure modals and popups are touchable */
    .modal, .popup, .overlay {
        touch-action: manipulation;
        pointer-events: auto !important;
    }
    
    /* Fix cards and clickable containers */
    .card, .tile, [class*="card"] {
        touch-action: manipulation;
    }
    
    /* Ensure links in cards are clickable */
    .card a, .tile a {
        touch-action: manipulation;
        pointer-events: auto !important;
    }
}

/* Specific fix for iPad Air 11-inch (1640x2360) */
@media (min-width: 1024px) and (max-width: 1366px) and (orientation: portrait),
       (min-width: 1024px) and (max-width: 1366px) and (orientation: landscape) {
    
    /* Force touch-friendly behavior on all interactive elements */
    * {
        -webkit-tap-highlight-color: rgba(194, 139, 82, 0.2);
    }
    
    /* Ensure no element blocks touch events */
    body, main, header, footer, nav, section, article, div {
        pointer-events: auto;
    }
    
    /* Fix any potential z-index issues */
    header {
        z-index: 1000 !important;
    }
    
    .navbar {
        z-index: 1001 !important;
    }
    
    /* Ensure dropdown works on touch */
    .dropdown:active .dropdown-menu,
    .dropdown.active .dropdown-menu {
        display: block !important;
    }
}

/* Global touch improvements for all devices */
@media (hover: none) and (pointer: coarse) {
    /* This targets touch devices specifically */
    
    /* Remove hover-only interactions */
    .dropdown:hover .dropdown-menu {
        display: none;
    }
    
    /* Make dropdowns work on click/tap instead */
    .dropdown.active .dropdown-menu,
    .dropdown.show .dropdown-menu {
        display: block !important;
    }
    
    /* Ensure all buttons are touch-friendly */
    button, .btn, a.btn, input[type="submit"], input[type="button"] {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(194, 139, 82, 0.2);
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Fix any hover-dependent UI */
    *:hover {
        -webkit-tap-highlight-color: rgba(194, 139, 82, 0.2);
    }
}

/* Prevent double-tap zoom on buttons */
button, .btn, a.btn {
    touch-action: manipulation;
}

/* Ensure smooth scrolling on touch devices */
* {
    -webkit-overflow-scrolling: touch;
}

/* Fix for iOS/iPadOS specific issues */
@supports (-webkit-touch-callout: none) {
    /* This targets iOS/iPadOS specifically */
    
    /* Prevent text selection on buttons */
    button, .btn, a.btn {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Ensure inputs work properly */
    input, select, textarea {
        -webkit-appearance: none;
        appearance: none;
    }
    
    /* Fix button appearance */
    button, .btn {
        -webkit-appearance: none;
        appearance: none;
    }
}
