/* Advanced Scroll Performance Optimizations */

/* Force GPU acceleration for smooth scrolling */
.mix-song-list {
    transform: translateZ(0) !important;
    will-change: scroll-position !important;
    -webkit-overflow-scrolling: touch !important;
    
    /* Enhanced containment for better performance */
    contain: strict !important;
    
    /* Optimize repaints during scroll */
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    
    /* Reduce scroll jank */
    scroll-behavior: auto !important; /* Remove smooth scrolling that can cause jank */
    overscroll-behavior: contain !important;
}

/* Optimize individual song items for scroll performance */
.mix-song-item {
    /* GPU acceleration */
    transform: translateZ(0) !important;
    will-change: auto !important; /* Only set to 'transform' during hover */
    
    /* Containment for better performance */
    contain: layout style !important;
    
    /* Reduce repaints */
    backface-visibility: hidden !important;
    
    /* Remove expensive box-shadows during scroll */
    box-shadow: none !important;
    transition: none !important;
    
    /* Optimize text rendering */
    text-rendering: optimizeSpeed !important;
    -webkit-font-smoothing: subpixel-antialiased !important;
}

/* Only add hover effects when actually hovering (not during scroll) */
.mix-song-item:hover {
    will-change: transform !important;
    transform: translateZ(0) scale(1.02) !important;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2) !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease !important;
}

/* Remove hover effects during scroll to prevent jank */
.mix-song-list.scrolling .mix-song-item:hover {
    transform: translateZ(0) !important;
    box-shadow: none !important;
    transition: none !important;
}

/* Optimize song item content */
.mix-song-item .song-title,
.mix-song-item .song-artist,
.mix-song-item .song-duration,
.mix-song-item .mix-song-muscle {
    /* Optimize text rendering for scroll performance */
    text-rendering: optimizeSpeed !important;
    -webkit-font-smoothing: subpixel-antialiased !important;
    
    /* Prevent text selection during scroll */
    user-select: none !important;
    -webkit-user-select: none !important;
    
    /* Contain layout changes */
    contain: layout !important;
}

/* Optimize difficulty display */
.difficulty-display {
    contain: layout style !important;
    will-change: auto !important;
    transform: translateZ(0) !important;
}

/* Load more button optimization */
.load-more-btn {
    display: block !important;
    width: 100% !important;
    padding: 15px !important;
    margin: 20px 0 !important;
    background: linear-gradient(135deg, #FFD167 0%, #06D7A0 100%) !important;
    color: #073A4B !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    cursor: pointer !important;
    transition: transform 0.2s ease !important;
    
    /* Performance optimizations */
    contain: layout style !important;
    transform: translateZ(0) !important;
    will-change: transform !important;
}

.load-more-btn:hover {
    transform: translateZ(0) scale(1.05) !important;
}

.load-more-btn:active {
    transform: translateZ(0) scale(0.98) !important;
}

/* Optimize workout slots for better interaction performance */
.workout-slot {
    contain: layout style !important;
    transform: translateZ(0) !important;
    will-change: auto !important;
}

.workout-slot.selected {
    will-change: transform !important;
}

/* Optimize muscle group selection animation */
.workout-slot.selecting {
    transition: transform 0.2s ease !important;
    will-change: transform !important;
}

/* Remove expensive filters and effects during scroll or interaction */
.mix-builder-right.loading .mix-song-item {
    opacity: 0.7 !important;
    pointer-events: none !important;
    filter: none !important;
    backdrop-filter: none !important;
}

/* Optimize search input performance */
#mix-search-input {
    will-change: auto !important;
    contain: layout !important;
}

#mix-search-input:focus {
    will-change: contents !important;
}

/* Performance critical sections */
.mix-builder-layout {
    /* Optimize the main layout container */
    contain: layout !important;
    transform: translateZ(0) !important;
}

.mix-builder-left,
.mix-builder-right {
    /* Isolate layout changes between left and right panels */
    contain: layout style !important;
    transform: translateZ(0) !important;
}

/* Mobile optimizations */
@media (max-width: 968px) {
    .mix-song-item {
        /* Simplified mobile rendering */
        transform: none !important;
        will-change: auto !important;
        contain: layout !important;
    }
    
    .mix-song-item:hover {
        /* Reduce hover effects on mobile */
        transform: none !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* Optimize mobile scrolling */
    .mix-song-list {
        -webkit-overflow-scrolling: touch !important;
        scroll-behavior: auto !important;
    }
}

/* Performance monitoring helpers */
.performance-debug {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 12px;
    z-index: 9999;
    pointer-events: none;
    display: none; /* Hidden by default */
}

/* Show debug info when performance debugging is enabled */
body.debug-performance .performance-debug {
    display: block;
}