/* iOS Touch Scrolling Fix for Table Row Highlighting */
/* This prevents table rows from being highlighted during touch scrolling on Safari/iOS */

/* Disable user selection and pointer events during touch scrolling */
@media (hover: none) and (pointer: coarse) {
    /* Target all table bodies that might have interactive rows */
    tbody tr {
        -webkit-touch-callout: none;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }
    
    /* Prevent highlight on touch for tables with highlighting */
    .simple-table tbody tr,
    .table tbody tr,
    .datatable tbody tr,
    [class*="Table"] tbody tr {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    /* Allow text selection within table cells */
    tbody td,
    tbody th {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
    }
    
    /* Prevent accidental highlighting during scroll */
    tbody tr:active,
    tbody tr:hover {
        background-color: inherit !important;
    }
    
    /* Re-enable highlighting only for deliberate taps (not scrolls) */
    tbody tr.touch-selected {
        background-color: #f5f5f5 !important;
    }
    
    /* For rows that should highlight on tap (like shopping cart items) */
    tbody tr.highlightable-row.touch-selected,
    .bg-danger.touch-selected {
        background-color: #f8d7da !important;
    }
}

/* Additional iOS-specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS-specific styles */
    tbody {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Prevent the default gray overlay on tap */
    tbody tr {
        -webkit-tap-highlight-color: transparent;
    }
    
    /* Disable pointer events during scroll */
    .scrolling tbody tr {
        pointer-events: none;
    }
}

/* Ensure smooth scrolling on iOS devices */
.simple-table-scrollable,
.simple-table-scrollable-lg,
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Fix for sticky headers on iOS */
.sticky-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: white;
}