/* Touch-Optimized Styles for Mobile Devices */

/* Minimum touch target size (44x44px as per Apple/Google guidelines) */
.touch-target,
button,
a,
input[type="checkbox"],
input[type="radio"],
select {
    min-height: 44px;
    min-width: 44px;
    position: relative;
}

/* Ensure clickable area extends beyond visual boundaries */
.touch-target::before,
button::before {
    content: '';
    position: absolute;
    top: -8px;
    right: -8px;
    bottom: -8px;
    left: -8px;
    z-index: 1;
}

/* Mobile-optimized buttons */
@media (max-width: 768px) {
    /* Primary buttons */
    .btn,
    button[type="submit"],
    .btn-primary {
        padding: 16px 24px;
        font-size: 16px; /* Prevents zoom on iOS */
        font-weight: 600;
        border-radius: 12px;
        touch-action: manipulation; /* Disable double-tap zoom */
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
        position: relative;
        overflow: hidden;
    }
    
    /* Button press effect */
    .btn:active,
    button:active {
        transform: scale(0.98);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    /* Ripple effect on touch */
    .btn::after,
    button::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.5);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s;
    }
    
    .btn:active::after,
    button:active::after {
        width: 300px;
        height: 300px;
    }
    
    /* Form inputs */
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
        border-radius: 8px;
        touch-action: manipulation;
    }
    
    /* Radio and checkbox improvements */
    .radio-card,
    .checkbox-card {
        padding: 16px;
        margin-bottom: 12px;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }
    
    .radio-card:active,
    .checkbox-card:active {
        background-color: rgba(59, 130, 246, 0.1);
        transform: scale(0.98);
    }
    
    /* Improved touch feedback */
    .radio-card input[type="radio"],
    .checkbox-card input[type="checkbox"] {
        width: 24px;
        height: 24px;
        cursor: pointer;
    }
    
    /* Navigation links */
    nav a,
    .nav-link {
        padding: 12px 16px;
        display: inline-block;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Cards and clickable elements */
    .card,
    .clickable-card {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }
    
    .card:active,
    .clickable-card:active {
        transform: scale(0.98);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }
    
    /* Swipeable elements */
    .swipeable {
        touch-action: pan-y;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
    }
    
    .swipeable > * {
        scroll-snap-align: start;
    }
    
    /* Bottom navigation bar (if used) */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        display: flex;
        justify-content: space-around;
        background: white;
        border-top: 1px solid #e5e7eb;
        padding: 8px 0;
        z-index: 50;
    }
    
    .bottom-nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px;
        min-height: 56px;
        -webkit-tap-highlight-color: transparent;
    }
    
    .bottom-nav-item:active {
        background-color: rgba(59, 130, 246, 0.1);
    }
    
    /* Floating Action Button */
    .fab {
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        -webkit-tap-highlight-color: transparent;
        z-index: 40;
    }
    
    .fab:active {
        transform: scale(0.95);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }
    
    /* Dropdown menus */
    .dropdown-item {
        padding: 16px 20px;
        display: block;
        -webkit-tap-highlight-color: transparent;
    }
    
    .dropdown-item:active {
        background-color: #f3f4f6;
    }
    
    /* Toggle switches */
    .toggle-switch {
        width: 52px;
        height: 32px;
        position: relative;
        -webkit-tap-highlight-color: transparent;
    }
    
    .toggle-switch-handle {
        width: 28px;
        height: 28px;
        position: absolute;
        top: 2px;
        transition: transform 0.2s ease;
    }
    
    /* Sliders */
    input[type="range"] {
        -webkit-appearance: none;
        height: 44px;
        background: transparent;
        cursor: pointer;
    }
    
    input[type="range"]::-webkit-slider-thumb {
        -webkit-appearance: none;
        width: 32px;
        height: 32px;
        border-radius: 50%;
        background: #3b82f6;
        cursor: pointer;
        margin-top: -14px;
    }
    
    input[type="range"]::-webkit-slider-track {
        width: 100%;
        height: 4px;
        background: #e5e7eb;
        border-radius: 2px;
    }
    
    /* Modal close buttons */
    .modal-close {
        position: absolute;
        top: 16px;
        right: 16px;
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* List items */
    .list-item {
        padding: 16px;
        border-bottom: 1px solid #e5e7eb;
        -webkit-tap-highlight-color: transparent;
        transition: background-color 0.2s ease;
    }
    
    .list-item:active {
        background-color: #f9fafb;
    }
    
    /* Tab navigation */
    .tab-item {
        flex: 1;
        padding: 16px;
        text-align: center;
        -webkit-tap-highlight-color: transparent;
        transition: all 0.2s ease;
    }
    
    .tab-item:active {
        background-color: rgba(59, 130, 246, 0.1);
    }
}

/* Gesture hints */
.swipe-hint {
    position: relative;
}

.swipe-hint::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #9ca3af;
    border-radius: 2px;
}

/* Pull to refresh indicator */
.pull-to-refresh {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.pull-to-refresh.active {
    opacity: 1;
}

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

/* Disable text selection on interactive elements */
.no-select,
button,
.btn,
.card {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* iOS safe area support */
@supports (padding: max(0px)) {
    .safe-area-inset {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }
}

/* Haptic feedback trigger (requires JavaScript) */
.haptic-light {
    /* Triggers light haptic feedback on supported devices */
}

.haptic-medium {
    /* Triggers medium haptic feedback on supported devices */
}

.haptic-heavy {
    /* Triggers heavy haptic feedback on supported devices */
}

/* Accessibility improvements for touch */
@media (pointer: coarse) {
    /* Increase hit areas for touch devices */
    .small-button {
        padding: 12px;
        min-width: 48px;
        min-height: 48px;
    }
    
    /* Larger close buttons */
    .close-btn {
        width: 48px;
        height: 48px;
    }
    
    /* Larger form controls */
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
    }
}

/* Long press menu */
.long-press-menu {
    position: fixed;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
    padding: 8px 0;
    z-index: 100;
    display: none;
}

.long-press-menu.active {
    display: block;
}

.long-press-menu-item {
    padding: 12px 20px;
    -webkit-tap-highlight-color: transparent;
}

.long-press-menu-item:active {
    background-color: #f3f4f6;
}