﻿/* Enhanced scrolling for all scrollable areas - Comprehensive Trackpad Fix */

/* Base trackpad scrolling optimization */
.modal-body,
.scrollable-area,
.timeline-container,
.notes-container,
[style*="overflow-y: auto"],
[style*="overflow: auto"],
.overflow-auto,
.overflow-y-auto {
    /* Essential trackpad scrolling properties */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    /* Hardware acceleration for smoother trackpad scrolling */
    transform: translateZ(0);
    will-change: scroll-position;
    /* Prevent momentum scrolling conflicts */
    touch-action: pan-y;
}

/* Specific fixes for GlobalModal trackpad scrolling */
#defaultModal .modal-body {
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    overscroll-behavior: contain !important;
    transform: translateZ(0) !important;
    will-change: scroll-position !important;
    touch-action: pan-y !important;
    /* Ensure proper trackpad momentum */
    -webkit-transform: translate3d(0, 0, 0) !important;
    -moz-transform: translate3d(0, 0, 0) !important;
    transform: translate3d(0, 0, 0) !important;
}

/* Specific fixes for GlobalDrawer trackpad scrolling */
#GlobalDrawer .modal-body,
#GlobalDrawer #DrawerContentContainer {
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    overscroll-behavior: contain !important;
    transform: translateZ(0) !important;
    will-change: scroll-position !important;
    touch-action: pan-y !important;
    /* Hardware acceleration for trackpad */
    -webkit-transform: translate3d(0, 0, 0) !important;
    -moz-transform: translate3d(0, 0, 0) !important;
    transform: translate3d(0, 0, 0) !important;
}

    /* Fix for nested scrollable content in modals/drawers */
    #defaultModal .modal-body *,
    #GlobalDrawer #DrawerContentContainer * {
        /* Allow child elements to inherit smooth scrolling */
        -webkit-overflow-scrolling: inherit;
    }

/* Trackpad scrolling for Summernote editor */
#GlobalDrawer .note-editable,
#defaultModal .note-editable,
.note-editing-area {
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    scroll-behavior: smooth !important;
    transform: translateZ(0) !important;
    touch-action: pan-y !important;
}

/* Enhanced scrolling for data tables in modals/drawers */
#defaultModal .dataTables_scrollBody,
#GlobalDrawer .dataTables_scrollBody {
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    overscroll-behavior: contain !important;
    transform: translateZ(0) !important;
    touch-action: pan-y !important;
}

/* Table responsive containers */
#defaultModal .table-responsive,
#GlobalDrawer .table-responsive,
.items-datatable-container {
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    overscroll-behavior-x: contain !important;
    overscroll-behavior-y: contain !important;
    transform: translateZ(0) !important;
}

/* Fix for SlimScroll conflicts with trackpad */
.slimScrollDiv,
.slimScrollBar,
.slimScrollRail {
    -webkit-overflow-scrolling: touch !important;
    scroll-behavior: smooth !important;
    transform: translateZ(0) !important;
}

/* Prevent scroll conflicts on modal backdrop */
.modal-open {
    overflow: hidden !important;
}

.modal-backdrop {
    overscroll-behavior: none !important;
}

/* macOS specific trackpad optimizations */
@media (pointer: fine) and (hover: hover) {
    /* Likely desktop/laptop with precise pointer (trackpad/mouse) */
    .modal-body,
    #GlobalDrawer #DrawerContentContainer {
        /* Enhance trackpad scroll sensitivity */
        scroll-snap-type: none;
        -webkit-scroll-snap-type: none;
        /* Better momentum for trackpad */
        -webkit-momentum-scrolling: normal;
    }
}

/* Webkit specific trackpad momentum fixes */
@supports (-webkit-overflow-scrolling: touch) {
    .modal-body,
    #GlobalDrawer #DrawerContentContainer {
        -webkit-overflow-scrolling: touch !important;
        /* Force hardware acceleration */
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        -webkit-perspective: 1000 !important;
        perspective: 1000 !important;
    }
}

/* Additional fix for Bootstrap modal conflicts */
.modal.fade .modal-dialog {
    -webkit-transform: translate(0, -25%) !important;
    transform: translate(0, -25%) !important;
}

.modal.show .modal-dialog {
    -webkit-transform: translate(0, 0) !important;
    transform: translate(0, 0) !important;
}

/* Ensure proper z-index stacking for trackpad scrolling */
.modal-content {
    transform: translateZ(0) !important;
    will-change: transform !important;
}

/* Fix for any remaining scroll issues */
html, body {
    overscroll-behavior: none;
}

.modal-open body {
    overscroll-behavior: none !important;
}
