/* Fix layout for Available Songs container using CSS Grid natural behavior */

/* TEMPORARY: Visual test to verify height matching (remove after verification) */
.mix-builder-left::after {
    content: '';
    position: absolute;
    right: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(6, 215, 160, 0.3);
    pointer-events: none;
}

.mix-builder-right::after {
    content: '';
    position: absolute;
    left: -2px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: rgba(255, 209, 103, 0.3);
    pointer-events: none;
}

.mix-builder-left {
    position: relative;
}

.mix-builder-right {
    position: relative;
}

/* Let workout structure keep its natural height */
.mix-builder-left {
    /* Keep original behavior - let it size naturally */
    min-height: 0; /* Allow shrinking if needed in grid context */
}

/* Make Available Songs container work with CSS Grid natural height matching */
.mix-builder-right {
    /* Use flexbox within the grid item, but let grid control height */
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden; /* Enable scrolling on child elements */
    /* Let CSS Grid control the height - remove any height constraints */
    min-height: 0; /* Allow proper grid sizing */
    max-height: none !important; /* Override any max-height from other CSS */
    height: auto !important; /* Let grid determine height */
}

/* iOS-specific fixes for mix-builder-right */
.ios-device .mix-builder-right {
    /* On iOS, use more flexible height handling */
    overflow: visible !important;
    max-height: 70vh !important; /* Prevent taking up entire viewport */
}

/* Ensure the song list takes remaining space and scrolls properly */
.mix-song-list {
    flex: 1; /* Take remaining space within the flex container */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden;
    min-height: 0; /* Important: allows flexbox to shrink properly */
    
    /* Smooth scrolling */
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    
    /* Performance optimizations */
    contain: layout;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* iOS-specific fixes for song list */
.ios-device .mix-song-list {
    /* On iOS, use lighter containment to prevent layout issues */
    contain: layout !important;
    
    /* iOS-optimized scrolling */
    -webkit-overflow-scrolling: touch !important;
    overscroll-behavior: contain !important;
    
    /* Prevent iOS bounce scrolling issues */
    scroll-behavior: auto !important;
    
    /* Modern scrollbar styling */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: rgba(255, 209, 103, 0.6) rgba(255, 255, 255, 0.1); /* Firefox */
}

/* Modern scrollbar for Webkit browsers (Chrome, Safari, Edge) */
.mix-song-list::-webkit-scrollbar {
    width: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.mix-song-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin: 4px;
}

.mix-song-list::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #FFD167 0%, #06D7A0 100%);
    border-radius: 4px;
    border: 1px solid rgba(7, 58, 75, 0.2);
    transition: all 0.2s ease;
}

.mix-song-list::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #FFD167 0%, #04B891 100%);
    transform: scaleX(1.2);
    box-shadow: 0 2px 8px rgba(255, 209, 103, 0.3);
}

.mix-song-list::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, #E8BD4A 0%, #038F7A 100%);
}

/* Scrollbar corner */
.mix-song-list::-webkit-scrollbar-corner {
    background: rgba(255, 255, 255, 0.05);
}

/* Ensure filters section doesn't take too much space */
.song-filters {
    flex-shrink: 0; /* Don't shrink */
    margin-bottom: 15px;
}

.mix-builder-right h3 {
    flex-shrink: 0; /* Don't shrink */
    margin-bottom: 15px;
}

/* Mobile message styling */
.mobile-select-message {
    flex-shrink: 0;
    padding: 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
}

/* Ensure CSS Grid creates equal height containers */
.mix-builder-layout {
    align-items: stretch !important; /* Make both grid items the same height */
    /* Grid items will naturally be the same height due to stretch */
    display: grid !important; /* Ensure grid is applied */
}

/* Desktop-specific: Ensure no mobile constraints interfere */
@media (min-width: 969px) {
    .mix-builder-right {
        max-height: none !important; /* Remove any mobile max-height constraints */
        order: unset !important; /* Remove any mobile ordering */
    }
    
    .mix-builder-left {
        order: unset !important; /* Remove any mobile ordering */
    }
}

/* Fix mobile order - Workout Structure should come first */
@media (max-width: 968px) {
    .mix-builder-right {
        order: 1 !important; /* Available Songs comes after Workout Structure */
    }
    
    .mix-builder-left {
        order: 0 !important; /* Workout Structure comes first */
    }
}

/* Remove glass morphism effect from mobile song modal for better readability */
.mobile-song-modal-content {
    background: #073A4B !important; /* Solid background instead of transparent */
    border: 2px solid #FFD167 !important; /* Clear border */
    backdrop-filter: none !important; /* Remove any blur effects */
    /* Ensure proper centering and sizing */
    width: 100% !important;
    max-width: 600px !important;
    height: calc(100vh - 110px) !important; /* Account for navbar (70px) + padding (40px) */
    max-height: calc(100vh - 110px) !important;
}

.mobile-song-modal-header {
    background: #052D3B !important; /* Solid darker background for header */
    backdrop-filter: none !important; /* Remove any blur effects */
    border-bottom: 1px solid #FFD167 !important; /* Clear separator */
}

/* Ensure text is fully readable */
.mobile-song-modal-header h3,
.mobile-song-modal-close {
    color: #F6F2F2 !important;
    text-shadow: none !important;
}

/* Make sure song items in modal are also readable */
.mobile-song-list .mix-song-item {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 209, 103, 0.3) !important;
    backdrop-filter: none !important;
}

/* Fix muscle group tags in Available Songs - remove tag styling */
.mix-song-muscle {
    background: none !important; /* Remove tag background */
    color: rgba(255, 255, 255, 0.7) !important; /* Subtle text color */
    padding: 0 !important; /* Remove padding */
    border-radius: 0 !important; /* Remove border radius */
    font-size: 12px !important; /* Standard font size */
    font-weight: normal !important; /* Normal weight, not bold */
    border: none !important; /* Remove any borders */
    box-shadow: none !important; /* Remove any shadows */
    text-transform: none !important; /* Ensure normal case */
}

/* Fix header width to match layout width exactly */
.mix-header {
    margin: 20px 25px 0 25px !important; /* Match layout padding of 25px on sides */
    padding: 30px 0 !important; /* Remove side padding since margin handles width */
}

/* Ensure layout and header have consistent spacing */
.mix-builder-layout {
    margin: 0 25px 25px 25px !important; /* Match header margins */
    padding: 25px 0 !important; /* Remove side padding since margin handles width */
}

/* Mobile adjustments to maintain consistency */
@media (max-width: 1200px) {
    .mix-header {
        margin: 20px 20px 0 20px !important; /* Match reduced layout padding */
    }
    
    .mix-builder-layout {
        margin: 0 20px 20px 20px !important; /* Match header margins */
    }
}

@media (max-width: 968px) {
    .mix-header {
        margin: 15px 15px 0 15px !important; /* Match mobile padding */
        padding: 20px 0 !important; /* Reduced vertical padding for mobile */
    }
    
    .mix-builder-layout {
        margin: 0 15px 15px 15px !important; /* Match header margins */
    }
}

/* Fix Awesomplete positioning and styling for Mix Builder */
.mix-builder-section .awesomplete {
    position: relative !important;
    width: 100% !important;
}

.mix-builder-section .awesomplete ul {
    background-color: #073A4B !important; /* Match theme */
    border: 2px solid #FFD167 !important; /* Gold border */
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
    z-index: 1000 !important;
    max-height: 250px !important;
    overflow-y: auto !important;
}

.mix-builder-section .awesomplete li {
    padding: 12px 16px !important;
    color: #F6F2F2 !important;
    border-bottom: 1px solid rgba(255, 209, 103, 0.2) !important;
    transition: all 0.2s ease !important;
}

.mix-builder-section .awesomplete li:last-child {
    border-bottom: none !important;
}

.mix-builder-section .awesomplete li:hover,
.mix-builder-section .awesomplete li.awesomplete-active {
    background-color: #FFD167 !important;
    color: #073A4B !important;
    transform: translateX(2px) !important;
}

/* Mobile Awesomplete specific styles */
.mobile-song-modal .awesomplete {
    position: relative !important;
    width: 100% !important;
}

.mobile-song-modal .awesomplete ul {
    background-color: #052D3B !important;
    border: 2px solid #FFD167 !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
    z-index: 10002 !important; /* Higher than modal */
    max-height: 200px !important;
    overflow-y: auto !important;
}

.mobile-song-modal .awesomplete li {
    padding: 10px 14px !important;
    color: #F6F2F2 !important;
    border-bottom: 1px solid rgba(255, 209, 103, 0.2) !important;
    font-size: 14px !important;
}

.mobile-song-modal .awesomplete li:hover,
.mobile-song-modal .awesomplete li.awesomplete-active {
    background-color: #FFD167 !important;
    color: #073A4B !important;
}