/**
 * Custom Music Track Mixer - Frontend Styles
 * Version: 8.29 (Desktop Button Layout Fix)
 */

/* ==========================================================================
   1. THEME ELEMENT HIDING (Original Logic)
   ========================================================================== */
.cstm-mixer-active .product_title.entry-title { display: none !important; }
.cstm-mixer-active .summary.entry-summary p.price { display: none !important; }
.cstm-mixer-active form.cart .single_add_to_cart_button { display: none !important; }
.cstm-mixer-active .product-images { display: none !important; }
.cstm-mixer-active .woocommerce-product-details__short-description { display: none !important; }

/* ==========================================================================
   2. MIXER LAYOUT & WRAPPER
   ========================================================================== */
.cstm-mixer-active .summary.entry-summary {
    width: 100% !important; 
    max-width: 100% !important;
    text-align: left; 
    display: block !important;
}

#cstm-mixer-wrapper-main {
    width: var(--mixer-width, 100%); 
    max-width: 100%;
    margin-left: auto !important; 
    margin-right: auto !important;
    text-align: left !important;
}

@media (max-width: 768px) {
    #cstm-mixer-wrapper-main {
        width: var(--mixer-mobile-width, 100%) !important;
    }
}

/* ==========================================================================
   3. INTERNAL COMPONENTS (Thumbnail, Price, Title)
   ========================================================================== */
.cstm-product-thumbnail-inline {
    width: var(--thumb-d, 60px) !important; 
    height: var(--thumb-d, 60px) !important;
    border-radius: 8px; 
    object-fit: cover;
    margin-right: 15px;
    display: block !important; 
    opacity: 1 !important;
    visibility: visible !important;
    border: 1px solid #ddd; 
}

@media (max-width: 768px) {
    .cstm-product-thumbnail-inline {
        width: var(--thumb-m, 40px) !important;
        height: var(--thumb-m, 40px) !important;
    }
}

.cstm-mixer-price-inline {
    font-size: 1.25rem; 
    font-weight: 700;
    line-height: 1; 
    white-space: nowrap;
    padding: 0.5rem 1rem; 
    border-style: solid;
    border-width: 2px;
}
.cstm-mixer-price-inline del { opacity: 0.6; }

#cstm-mixer-wrapper-main .cstm-mixer-title-container {
    display: flex !important; 
    align-items: center; 
    margin-bottom: 20px;
    justify-content: space-between !important; 
    flex-wrap: wrap; 
}

#cstm-mixer-wrapper-main .cstm-mixer-title-container h3 {
    margin: 0; line-height: 1.2; padding: 0; display: block; font-size: 1.5rem; 
}

/* ==========================================================================
   4. SLIDER STYLING (Volume, Pan & EQ)
   ========================================================================== */
.range-lg::-webkit-slider-thumb,
.cstm-eq-group input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: #3B82F6; cursor: pointer;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
    transition: background-color 0.15s ease-in-out;
}

.range-lg::-moz-range-thumb,
.cstm-eq-group input[type=range]::-moz-range-thumb {
    width: 16px; height: 16px; border-radius: 50%;
    background: #3B82F6; cursor: pointer;
}

body { font-family: 'Inter', sans-serif; }

/* ==========================================================================
   5. WAVEFORM VISUALIZER STYLES
   ========================================================================== */
#playhead-container {
    height: 48px !important; 
    background-color: #f3f4f6; 
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    position: relative;
    overflow: hidden;
}

.cstm-wave-mask {
    -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
    -webkit-mask-position: center; mask-position: center;
    -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
    width: 100%; height: 100%; display: block;
    background-repeat: no-repeat; background-position: center; background-size: cover;
}

.cstm-wave-layer-bg { opacity: 1 !important; }

#playhead-bar {
    background-color: transparent !important; 
    border-right: 1px solid rgba(0,0,0,0.1); 
    overflow: hidden; z-index: 10;
}

/* ==========================================================================
   6. WOODMART THEME SPECIFIC OVERRIDES
   ========================================================================== */
.cstm-mixer-active .product-image-summary-inner { display: block !important; }

.cstm-mixer-active .summary.entry-summary {
    width: 100% !important; max-width: 100% !important;
    flex: 0 0 100% !important; margin: 0 !important;
    padding-left: 0 !important; padding-right: 0 !important;
}

/* ==========================================================================
   7. NEW: MASTER EQ RESPONSIVE LAYOUT
   ========================================================================== */
.cstm-eq-container {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    width: 100%;
}

.cstm-eq-label {
    flex-shrink: 0;
    white-space: nowrap;
}

.cstm-eq-controls {
    display: flex;
    flex: 1; /* Take remaining width */
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
}

.cstm-eq-group {
    display: flex;
    align-items: center;
    flex: 1; /* Each EQ band takes equal width */
    min-width: 0; /* Allow flexbox shrinking */
}

.cstm-eq-group input[type="range"] {
    width: 100% !important; /* Slider fills the group width */
    flex-grow: 1;
    margin: 0 8px;
    min-width: 40px;
}

/* ==========================================================================
   8. MOBILE & LANDSCAPE TABLET UI POLISH
   Updated breakpoint to 1024px to handle mobile landscape orientation
   ========================================================================== */
@media (max-width: 1024px) {
    #cstm-mixer-wrapper-main .track-row {
        padding-left: 0.25rem !important; padding-right: 0.25rem !important;
    }
    #cstm-mixer-wrapper-main .track-row .text-4xl {
        font-size: 1.5rem !important; margin-right: 0.5rem !important;
    }
    #cstm-mixer-wrapper-main .mute-button,
    #cstm-mixer-wrapper-main .solo-button {
        padding: 4px 8px !important; font-size: 0.7rem !important; 
        min-height: 30px !important; line-height: 1 !important; width: 100% !important; 
    }
    #cstm-mixer-wrapper-main .mute-button svg { display: none !important; }

    /* --- EQ MOBILE LAYOUT: Title on Top, Sliders Below --- */
    .cstm-eq-container {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
    }
    
    .cstm-eq-label {
        width: 100%;
        margin-bottom: 8px;
        border-bottom: 1px solid #e5e7eb;
        padding-bottom: 4px;
    }
    
    .cstm-eq-controls {
        width: 100%;
        gap: 0.5rem;
        padding-right: 5px; /* Avoid edge cutting */
    }

    /* --- 2-Row Button Layout Logic (For Mobile & Landscape) --- */
    
    /* 1. Container: Stack vertically */
    #cstm-mixer-wrapper-main .cstm-controls-footer {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        padding-top: 15px !important;
        align-items: stretch !important; /* Ensure full width */
    }

    /* 2. Top Row (Play, Loop, Reset): Side-by-side, equal width */
    #cstm-mixer-wrapper-main .cstm-btn-group-main {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        width: 100% !important;
        gap: 8px !important;
        margin: 0 !important;
    }
    
    /* Remove default spacing utility to prevent conflicts */
    #cstm-mixer-wrapper-main .cstm-btn-group-main > :not([hidden]) ~ :not([hidden]) {
        margin-left: 0 !important;
    }

    /* Button Styling: Equal Flex */
    #cstm-mixer-wrapper-main #play-button,
    #cstm-mixer-wrapper-main #reset-button,
    #cstm-mixer-wrapper-main #loop-button {
        flex: 1 !important; /* Share width equally */
        width: auto !important;
        min-height: 48px !important; 
        max-height: 48px !important;
        display: flex !important; 
        align-items: center !important; 
        justify-content: center !important;
        font-size: 0.8rem !important; 
        padding: 0 4px !important; 
        margin: 0 !important;
        white-space: nowrap;
    }

    /* 3. Bottom Row (Save): Full Width */
    #cstm-mixer-wrapper-main .cstm-btn-group-save {
        width: 100% !important;
        margin: 0 !important;
        flex-direction: column !important; /* Force stack for saves */
        gap: 10px !important;
    }
    
    #cstm-mixer-wrapper-main #save-button,
    #cstm-library-save-btn {
        width: 100% !important;
        display: flex !important;
        align-items: center;
        justify-content: center;
        min-height: 54px !important;
        height: auto !important;
        padding: 10px !important;
        white-space: normal !important;
        text-align: center !important;
        font-size: 1rem !important; 
    }

    /* FIX: PRESETS SCROLLBAR & PADDING */
    #cstm-preset-container {
        padding-right: 20px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        -ms-overflow-style: none; 
        scrollbar-width: none; 
    }
    #cstm-preset-container::-webkit-scrollbar { display: none; }

    /* FIX: MAIN CONTAINER PADDING */
    #cstm-mixer-wrapper-main {
        padding-left: 15px !important;
        padding-right: 15px !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* FIX: SPACING BETWEEN WAVEFORM AND MASTER VOLUME */
    #cstm-mixer-wrapper-main #playhead-container {
        margin-bottom: 30px !important; 
    }
}

/* ==========================================================================
   9. LOADING OVERLAY & LOOP FEATURES
   ========================================================================== */
.cstm-loader-overlay {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
    z-index: 100;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border-radius: 12px; transition: opacity 0.3s ease;
}
.cstm-spinner {
    width: 40px; height: 40px;
    border: 4px solid #e5e7eb; border-top: 4px solid #3B82F6; 
    border-radius: 50%; animation: cstm-spin 1s linear infinite;
    margin-bottom: 10px;
}
@keyframes cstm-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Loop Handles */
.cstm-loop-handle {
    position: absolute; top: 0; bottom: 0; width: 4px;
    background-color: #F59E0B; cursor: ew-resize; z-index: 20;
    display: none; 
}
.cstm-loop-handle::after {
    content: ''; position: absolute; top: -6px; left: -6px;
    width: 16px; height: 16px; background-color: #F59E0B;
    border-radius: 50%; border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.cstm-loop-region {
    position: absolute; top: 0; bottom: 0;
    background-color: rgba(245, 158, 11, 0.2); z-index: 15;
    display: none; pointer-events: none;
}
#loop-button.loop-active {
    background-color: #F59E0B !important; color: white !important;
    border-color: #D97706 !important;
}