/* PWA Mobile Touch Fixes for Android & iOS */

/* Ensure all buttons are properly touchable on mobile */
.circle-btn, .nav-btn, .open-button, .close-button {
    touch-action: manipulation !important;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    cursor: pointer;
    position: relative;
    z-index: 10;
}

/* Fix Android button responsiveness */
.category-btn, .device-btn {
    touch-action: manipulation !important;
    -webkit-tap-highlight-color: rgba(204, 0, 0, 0.3);
    tap-highlight-color: rgba(204, 0, 0, 0.3);
    -webkit-touch-callout: none;
    cursor: pointer;
    min-height: 44px; /* iOS minimum touch target */
    min-width: 44px;
    position: relative;
    z-index: 10;
}

/* Ensure navigation buttons are clickable */
.nav-btn {
    touch-action: manipulation !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: rgba(204, 0, 0, 0.3);
    background: transparent;
    border: none;
    padding: 10px;
    min-height: 44px;
    min-width: 44px;
}

.nav-btn:active {
    transform: scale(0.95);
    opacity: 0.7;
}

/* Fix disabled state for navigation buttons */
.nav-btn[disabled] {
    pointer-events: none !important;
    opacity: 0.3;
    color: grey;
}

/* Ensure proper touch targets for all interactive elements */
button, select, .styled-select {
    touch-action: manipulation !important;
    min-height: 44px;
    cursor: pointer;
}

/* Fix iOS Safari touch issues */
.device-slide {
    touch-action: pan-x !important;
    -webkit-overflow-scrolling: touch;
}

.devices-container {
    touch-action: pan-x !important;
    -webkit-overflow-scrolling: touch;
    overflow: hidden;
}

/* Improve touch feedback */
.circle-btn:active, .device-btn:active, .category-btn:active {
    transform: scale(0.95);
    transition: transform 0.1s ease;
}

/* iOS PWA specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari specific styles */
    body {
        -webkit-text-size-adjust: 100%;
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Prevent zoom on iOS */
    input, select, textarea {
        font-size: 16px !important;
    }
    
    /* Fix iOS button rendering */
    button {
        -webkit-appearance: none;
        appearance: none;
        border-radius: 0;
    }
    
    .circle-btn {
        -webkit-appearance: none;
        appearance: none;
    }
}

/* Android Chrome specific fixes */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .nav-btn, .category-btn, .device-btn {
        -webkit-tap-highlight-color: rgba(204, 0, 0, 0.3);
        outline: none;
        border: none;
    }
}

/* Ensure overlay and dialog are touchable */
.overlay {
    touch-action: auto !important;
    -webkit-overflow-scrolling: touch;
}

.dialog {
    touch-action: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* High contrast focus indicators for accessibility */
.circle-btn:focus, .nav-btn:focus, .device-btn:focus, .category-btn:focus {
    outline: 2px solid #cc0000;
    outline-offset: 2px;
}

/* Remove default button styling that might interfere with touch */
button {
    background: none;
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

/* Ensure proper stacking context for clickable elements */
.categories-buttons, .devices-buttons {
    position: relative;
    z-index: 5;
}

/* Fix potential z-index issues */
.banner, .banner-img {
    position: relative;
    z-index: 1;
}

.main-content {
    position: relative;
    z-index: 2;
}

/* Ensure dropdown is properly touchable */
.styled-select {
    -webkit-appearance: menulist;
    appearance: menulist;
    touch-action: manipulation !important;
    cursor: pointer;
    background: white;
    border: 1px solid #ccc;
    padding: 8px;
}

/* Progressive Web App fixes for better offline support */
@media (display-mode: standalone) {
    /* PWA specific styles */
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
    
    /* Hide address bar area in PWA mode */
    .header {
        padding-top: env(safe-area-inset-top);
    }
}

/* Improve performance on mobile */
.device-slide-content, .device-slide {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Prevent accidental selections during swipe */
.devices-container *, .device-slide * {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* But allow text selection in dialog content */
.dialog * {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}