/* Mobile Responsiveness Fixes - Comprehensive Solution */

/* Fix for touch-action issues that prevent clicking */
@media (max-width: 767px) {
    /* Override touch-action none that prevents clicking */
    html.html-modal-open {
        touch-action: auto !important;
        -ms-touch-action: auto !important;
    }
    
    /* Ensure all clickable elements work on mobile */
    button, 
    .btn, 
    input[type="button"], 
    input[type="submit"], 
    input[type="reset"],
    a[href],
    .clickable,
    [role="button"],
    .cursor-pointer {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
        cursor: pointer !important;
    }

    /* Fix for small buttons that are hard to tap */
    .btn-sm,
    .btn-xs,
    .icon-btn,
    .btn-icon {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Fix for form inputs that cause zoom on iOS */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        touch-action: manipulation !important;
    }

    /* Fix for search inputs specifically */
    .theme-header-mobile__search-form input {
        font-size: 16px !important;
        min-height: 44px !important;
    }

    /* Fix for mobile navigation toggles */
    .navbar-toggler {
        min-height: 44px !important;
        min-width: 44px !important;
        touch-action: manipulation !important;
    }

    /* Fix for cart drawer close button */
    .js-cart-drawer-close {
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
    }

    /* Fix for drawer close buttons */
    .drawer__close,
    .btn-close {
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
    }

    /* Fix for mobile header interactive elements */
    .js-mobile-header-show-specific-drawer {
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
    }

    /* Fix for theme color toggle */
    .theme-color-toggle {
        min-height: 48px !important;
        min-width: 48px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        touch-action: manipulation !important;
    }

    /* Fix for cart counter positioning */
    .theme-header-mobile__cart-counter {
        position: absolute !important;
        top: -8px !important;
        right: -8px !important;
        min-width: 20px !important;
        height: 20px !important;
        border-radius: 10px !important;
        background: #f63c3c !important;
        color: white !important;
        font-size: 12px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 2px 6px !important;
    }

    /* Fix for size classes that are too small */
    .size-32 {
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .size-40 {
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .size-48 {
        min-width: 48px !important;
        min-height: 48px !important;
    }

    /* Fix for scrollable areas */
    .cart-drawer__body,
    .drawer__body {
        -webkit-overflow-scrolling: touch !important;
    }

    /* Fix for iOS Safari viewport height */
    .cart-drawer,
    .drawer {
        height: 100vh !important;
        height: calc(var(--vh, 1vh) * 100) !important;
    }

    .cart-drawer__body,
    .drawer__body {
        height: calc(100vh - 120px) !important;
        height: calc((var(--vh, 1vh) * 100) - 120px) !important;
    }

    /* Fix for modal interactions */
    .modal {
        touch-action: auto !important;
    }

    .modal-dialog {
        touch-action: auto !important;
    }

    .modal-content {
        touch-action: auto !important;
    }

    /* Fix for SweetAlert interactions */
    .swal2-container {
        touch-action: auto !important;
    }

    .swal2-popup {
        touch-action: auto !important;
    }

    /* Fix for dropdown menus */
    .dropdown-menu {
        touch-action: auto !important;
    }

    .dropdown-item {
        touch-action: manipulation !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        padding: 12px 16px !important;
    }

    /* Fix for navigation links */
    .nav-link {
        touch-action: manipulation !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        padding: 12px 16px !important;
    }

    /* Fix for pagination */
    .pagination .page-link {
        touch-action: manipulation !important;
        min-height: 44px !important;
        min-width: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    /* Fix for tabs */
    .nav-tabs .nav-link {
        touch-action: manipulation !important;
        min-height: 44px !important;
        padding: 12px 16px !important;
    }

    /* Fix for list group items */
    .list-group-item-action {
        touch-action: manipulation !important;
        min-height: 44px !important;
        padding: 12px 16px !important;
    }

    /* Fix for form checkboxes and radios */
    .form-check-input {
        touch-action: manipulation !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .form-check-label {
        touch-action: manipulation !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        padding-left: 8px !important;
    }

    /* Fix for file inputs */
    input[type="file"] {
        touch-action: manipulation !important;
        min-height: 44px !important;
        min-width: 44px !important;
    }

    /* Fix for select elements */
    select {
        touch-action: manipulation !important;
        min-height: 44px !important;
        font-size: 16px !important;
    }

    /* Fix for links */
    a {
        touch-action: manipulation !important;
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1) !important;
    }

    /* Fix for any elements with pointer-events none */
    *[style*="pointer-events: none"] {
        pointer-events: auto !important;
    }

    /* Ensure proper z-index for interactive elements */
    .btn,
    button,
    a[href],
    .clickable {
        position: relative !important;
        z-index: 1 !important;
    }

    /* Fix for any overlays that might block interactions */
    .overlay,
    .modal-backdrop {
        pointer-events: auto !important;
    }

    /* Fix for disabled elements */
    .btn:disabled,
    button:disabled,
    input:disabled {
        opacity: 0.6 !important;
        pointer-events: none !important;
    }
}

/* Extra small devices - enhance touch targets */
@media (max-width: 575.98px) {
    /* Ensure buttons are large enough on very small screens */
    .btn-sm,
    .btn-xs,
    .icon-btn,
    .btn-icon {
        min-height: 48px !important;
        min-width: 48px !important;
        padding: 14px !important;
    }

    /* Stack buttons vertically when space is limited */
    .btn-group-vertical .btn {
        display: block !important;
        width: 100% !important;
        margin-bottom: 8px !important;
    }

    /* Increase font size for better readability */
    body {
        font-size: 16px !important;
    }

    /* Improve spacing for mobile */
    .container {
        padding-left: 16px !important;
        padding-right: 16px !important;
    }

    /* Better card spacing */
    .card {
        margin-bottom: 16px !important;
    }

    .card-body {
        padding: 16px !important;
    }
}

/* Landscape orientation - optimize for landscape */
@media (max-width: 767px) and (orientation: landscape) {
    .cart-drawer__body,
    .drawer__body {
        height: calc(100vh - 100px) !important;
        height: calc((var(--vh, 1vh) * 100) - 100px) !important;
    }

    /* Reduce padding in landscape */
    .container {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
}

/* High DPI displays - ensure crisp rendering */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    button,
    .btn,
    input[type="button"],
    input[type="submit"],
    input[type="reset"] {
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .btn {
        border-color: rgba(255, 255, 255, 0.2) !important;
    }
}

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