/* Mobile Touch Fixes - Ensures responsive touch events */

/* Critical mobile viewport fixes */
html {
    height: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    overflow-x: hidden;
}

body {
    min-height: 100%;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100);
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    touch-action: pan-x pan-y;
}

/* Ensure all clickable elements respond to touch */
button,
.btn,
a,
[role="button"],
[onclick],
.clickable,
.service-card,
.provider-card,
.category-chip,
.time-slot,
.staff-option,
.tab-button,
.action-btn,
.modal-close,
.filter-tab,
.booking-card {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
    position: relative;
    z-index: 1;
}

/* Minimum touch targets for accessibility */
button:not(.icon-only),
.btn:not(.icon-only),
a:not(.icon-only),
[role="button"]:not(.icon-only) {
    min-height: 44px;
    min-width: 44px;
    padding: 8px 16px;
}

/* Icon-only buttons still need adequate size */
.icon-only,
button.icon-only,
.btn.icon-only {
    min-height: 44px;
    min-width: 44px;
    padding: 10px;
}

/* Enhanced touch feedback */
.touch-active {
    transform: scale(0.95) !important;
    opacity: 0.8 !important;
    transition: transform 0.1s ease, opacity 0.1s ease !important;
}

/* Fix iOS touch callout and selection issues */
* {
    -webkit-touch-callout: default;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

/* Specific fixes for interactive elements */
.service-card,
.provider-card,
.booking-card {
    -webkit-tap-highlight-color: rgba(52, 152, 219, 0.2);
    touch-action: manipulation;
    cursor: pointer;
}

.category-chip,
.time-slot,
.staff-option {
    -webkit-tap-highlight-color: rgba(52, 152, 219, 0.3);
    touch-action: manipulation;
    cursor: pointer;
}

/* Fix modal and overlay touch issues */
.modal-overlay {
    touch-action: auto;
    pointer-events: auto;
}

.modal-content {
    touch-action: auto;
    pointer-events: auto;
}

/* Ensure forms are touchable */
input,
textarea,
select {
    pointer-events: auto !important;
    touch-action: manipulation;
    -webkit-appearance: none;
    border-radius: 0;
}

/* Fix input zoom issues on iOS */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea {
    font-size: 16px !important;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Better scrolling for mobile */
.scrollable,
.modal-body,
.wizard-content,
.tab-content,
.bookings-grid,
.providers-grid {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Fix any z-index stacking issues */
.loading-screen {
    z-index: 9999 !important;
    pointer-events: auto;
}

.modal-overlay {
    z-index: 1000 !important;
}

.customer-header,
.site-header {
    z-index: 100 !important;
}

/* Prevent double-tap zoom but allow single taps */
.no-zoom {
    touch-action: manipulation;
}

/* Fix viewport height issues */
.full-height {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

/* Safe area handling for notched devices */
@supports (padding: max(0px)) {
    .safe-area-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .safe-area-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .safe-area-left {
        padding-left: max(1rem, env(safe-area-inset-left));
    }
    
    .safe-area-right {
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* Fix iOS Safari specific issues */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific fixes */
    html {
        -webkit-text-size-adjust: 100%;
    }
    
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fix sticky hover states on iOS */
    .hover-fix {
        cursor: pointer;
    }
    
    .hover-fix:hover {
        background-color: transparent;
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) {
    /* Android Chrome specific styles */
    button,
    .btn {
        -webkit-appearance: none;
        outline: none;
    }
}

/* High DPI / Retina display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Better rendering for high-DPI screens */
    * {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* Dark mode safe touch targets */
@media (prefers-color-scheme: dark) {
    .touch-active {
        background-color: rgba(255, 255, 255, 0.1) !important;
    }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .touch-active {
        transition: none !important;
        transform: none !important;
    }
}

/* Debug mode for touch issues (uncomment to enable) */
/*
.debug-touch * {
    outline: 1px solid rgba(255, 0, 0, 0.3) !important;
}

.debug-touch button,
.debug-touch .btn,
.debug-touch [onclick] {
    outline: 2px solid rgba(0, 255, 0, 0.5) !important;
}
*/