/**
 * PinkCode LearnDash Beautifier - Sidebar Course Content Visibility Fixes
 * 
 * Fixes visibility issues in the course content sidebar for better UX
 * - White text color for completed lessons (green background)
 * - Hidden expand button elements for cleaner interface
 * - Optimized for both desktop and mobile views
 * 
 * @package PinkCodeLearnDashBeautifier
 * @since 1.6.4
 * @author Pink Code Queen - Nariman Jafari
 * @link https://pinkcodequeen.com
 */

/* ============================================
   COMPLETED LESSON TITLE VISIBILITY FIX
   ============================================ */

/**
 * Make lesson titles white when completed (green background)
 * Ensures text is clearly visible against the gradient background
 */
#sidebar .ld-item-list .learndash-complete .ld-item-title,
#sidebar .ld-item-list .ld-status-complete .ld-item-title,
#sidebar .learndash-complete .ld-item-title,
#sidebar .ld-status-complete .ld-item-title,
.ld-item-list .learndash-complete .ld-item-title,
.ld-item-list .ld-status-complete .ld-item-title,
.learndash-complete a .ld-item-title,
.ld-item-list-item.learndash-complete .ld-item-title {
    color: #ffffff !important;
}

/**
 * Ensure quiz count badges are also white
 */
#sidebar .ld-item-list .learndash-complete .ld-item-components,
#sidebar .ld-item-list .ld-status-complete .ld-item-components,
.learndash-complete .ld-item-components,
.ld-item-list-item.learndash-complete .ld-item-components {
    color: #ffffff !important;
}

/**
 * Fix for completed lesson links
 */
#sidebar .ld-item-list .learndash-complete a.ld-item-name,
#sidebar .learndash-complete a.ld-item-name,
.ld-item-list .learndash-complete a.ld-item-name,
.ld-item-list-item.learndash-complete a.ld-item-name {
    color: #ffffff !important;
}

/* ============================================
   CLICKABLE LESSON CARD STYLING
   ============================================ */

/**
 * Add border and improved background for completed lessons (green)
 * Makes them clearly clickable with enhanced depth
 */
.ld-item-list-item.learndash-complete a.ld-item-name,
.learndash-complete a.ld-item-name {
    border: 2px solid rgba(16, 185, 129, 0.4) !important;
    border-radius: 8px !important;
    padding: 12px !important;
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

/**
 * Hover effect for completed lessons
 */
.ld-item-list-item.learndash-complete a.ld-item-name:hover,
.learndash-complete a.ld-item-name:hover {
    border-color: rgba(16, 185, 129, 0.7) !important;
    background: linear-gradient(135deg, #047857 0%, #065f46 100%) !important;
    transform: translateX(4px) !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3) !important;
}

/**
 * Add border and improved background for incomplete lessons (white)
 * Makes them clearly clickable with subtle styling
 */
.ld-item-list-item.learndash-incomplete a.ld-item-name,
.learndash-incomplete a.ld-item-name,
.ld-item-list-item:not(.learndash-complete):not(.learndash-incomplete) a.ld-item-name {
    border: 2px solid rgba(203, 213, 225, 0.6) !important;
    border-radius: 8px !important;
    padding: 12px !important;
    background: #ffffff !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

/**
 * Hover effect for incomplete lessons
 */
.ld-item-list-item.learndash-incomplete a.ld-item-name:hover,
.learndash-incomplete a.ld-item-name:hover,
.ld-item-list-item:not(.learndash-complete):not(.learndash-incomplete) a.ld-item-name:hover {
    border-color: rgba(148, 163, 184, 0.8) !important;
    background: #f8fafc !important;
    transform: translateX(4px) !important;
    box-shadow: 0 4px 12px rgba(100, 116, 139, 0.15) !important;
}

/**
 * Larger font size for lesson titles in MAIN CONTENT AREA only
 * Sidebar keeps the default size
 */
.learndash-wrapper .ld-item-list-item .ld-item-title,
.learndash-wrapper a.ld-item-name .ld-item-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    line-height: 1.5 !important;
}

/**
 * Keep sidebar font size normal
 */
#sidebar .ld-item-list .ld-item-title,
#sidebar a.ld-item-name .ld-item-title {
    font-size: 14px !important;
    font-weight: 500 !important;
}

/* ============================================
   HIDE ENTIRE EXPAND BUTTON IN SIDEBAR ONLY
   ============================================ */

/**
 * Completely hide the expand/collapse button in SIDEBAR only
 * Main content area will still show the full button
 */
#sidebar .ld-expand-button,
#sidebar .ld-item-list .ld-expand-button,
#sidebar .ld-item-details .ld-expand-button {
    display: none !important;
    visibility: hidden !important;
}

/* ============================================
   STYLE EXPAND BUTTON IN MAIN CONTENT AREA
   ============================================ */

/**
 * Show expand button with white text in main content area
 * This targets expand buttons OUTSIDE the sidebar
 */
.learndash-wrapper .ld-expand-button .ld-text,
.learndash-wrapper .ld-expand-button .ld-icon-arrow-down {
    color: #ffffff !important;
}

/**
 * Ensure the button itself has proper styling in main area
 */
.learndash-wrapper .ld-expand-button {
    color: #ffffff !important;
}

/**
 * White color for the arrow icon background in main area
 */
.learndash-wrapper .ld-expand-button .ld-icon-arrow-down.ld-icon.ld-primary-background {
    background-color: rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

/**
 * Keep screen-reader text accessible but visually hidden
 * This maintains accessibility for screen readers
 */
.screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================
   MOBILE VIEW OPTIMIZATIONS
   ============================================ */

@media (max-width: 768px) {
    /**
     * Ensure white text on completed lessons in mobile
     */
    #sidebar .ld-item-list .learndash-complete .ld-item-title,
    #sidebar .ld-item-list .ld-status-complete .ld-item-title,
    .ld-item-list .learndash-complete .ld-item-title,
    .ld-item-list .ld-status-complete .ld-item-title,
    .learndash-complete .ld-item-title,
    .ld-item-list-item.learndash-complete .ld-item-title {
        color: #ffffff !important;
        font-weight: 500 !important;
    }
    
    /**
     * Completely hide expand button in SIDEBAR in mobile as well
     */
    #sidebar .ld-expand-button,
    #sidebar .ld-item-list .ld-expand-button,
    #sidebar .ld-item-details .ld-expand-button {
        display: none !important;
        visibility: hidden !important;
    }
    
    /**
     * Keep main content area expand buttons visible with white color
     */
    .learndash-wrapper .ld-expand-button .ld-text,
    .learndash-wrapper .ld-expand-button .ld-icon-arrow-down {
        color: #ffffff !important;
    }
    
    /**
     * Mobile: Adjust clickable card styling
     */
    .ld-item-list-item a.ld-item-name {
        padding: 10px !important;
        border-width: 1.5px !important;
    }
    
    /**
     * Mobile: Font size for main content area
     */
    .learndash-wrapper .ld-item-list-item .ld-item-title,
    .learndash-wrapper a.ld-item-name .ld-item-title {
        font-size: 15px !important;
    }
}

@media (max-width: 480px) {
    /**
     * Extra small screens - ensure visibility
     */
    #sidebar .ld-item-list .learndash-complete .ld-item-title,
    .ld-item-list .learndash-complete .ld-item-title,
    .learndash-complete .ld-item-title {
        color: #ffffff !important;
        font-size: 14px !important;
        font-weight: 500 !important;
    }
    
    /**
     * Main content area expand buttons stay visible
     */
    .learndash-wrapper .ld-expand-button .ld-text,
    .learndash-wrapper .ld-expand-button .ld-icon-arrow-down {
        color: #ffffff !important;
    }
    
    /**
     * Extra small: Compact clickable card styling
     */
    .ld-item-list-item a.ld-item-name {
        padding: 8px !important;
        gap: 8px !important;
    }
    
    /**
     * Extra small: Font size for main content area
     */
    .learndash-wrapper .ld-item-list-item .ld-item-title,
    .learndash-wrapper a.ld-item-name .ld-item-title {
        font-size: 14px !important;
    }
}

/* ============================================
   HIGH CONTRAST MODE SUPPORT
   ============================================ */

@media (prefers-contrast: high) {
    /**
     * Ensure text remains visible in high contrast mode
     */
    #sidebar .ld-item-list .learndash-complete .ld-item-title,
    .learndash-complete .ld-item-title {
        color: #ffffff !important;
        font-weight: 700 !important;
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */

@media (prefers-color-scheme: dark) {
    /**
     * Maintain white text in dark mode as well
     */
    #sidebar .ld-item-list .learndash-complete .ld-item-title,
    .learndash-complete .ld-item-title {
        color: #ffffff !important;
    }
}
