/**
 * Collapsible Sections for LearnDash - Frontend Styles
 * 
 * @package CollapsibleSectionsLearnDash
 * @version 1.0
 */

.swrcsfl-section-item {
    border: 2px solid #e2e7ed;
    border-radius: 6px;
    margin: 1em 0;
    background: rgba(146,164,183,.05);
    position: relative; /* Allow proper positioning for child elements */
    z-index: 1; /* Base z-index for section items */
}

.swrcsfl-section-toggle-btn {
    background: transparent;
    color: var(--bb-headings-color); /* Match exact LearnDash section heading color */
    padding: 20px;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    text-decoration: none;
    font-family: inherit;
    font-size: 16px; /* Match exact LearnDash default section heading font size */
    font-weight: 800;
    transition: opacity 0.3s ease;
    margin: 0;
    border-radius: 6px;
    letter-spacing: 0.6px; /* Match LearnDash section heading letter-spacing */
    text-transform: capitalize; /* Less aggressive than uppercase per client request */
}

.swrcsfl-section-toggle-btn:hover {
    color: var(--bb-headings-color); /* Match exact LearnDash section heading color */
    opacity: 0.85;
}

.swrcsfl-section-toggle-btn:focus {
    outline: none;
    opacity: 0.75;
}

.swrcsfl-section-left {
    display: flex;
    align-items: center;
    flex: 1;
}

.swrcsfl-toggle-icon {
    /* Smart approach - arrow-right/arrow-down, no rotation needed */
    background: #093b7d; /* Default LearnDash blue background - will be overridden by dynamic CSS */
    color: #a3a5a9; /* LearnDash white icon */
    border-radius: 100%; /* LearnDash circular shape */
    width: 18px; /* LearnDash exact size */
    height: 18px; /* LearnDash exact size */
    flex: 0 0 18px; /* LearnDash flex sizing */
    padding: 2px; /* LearnDash padding */
    line-height: 1; /* Clean line height for dashicons */
    text-align: center;
    font-weight: bold; /* LearnDash font weight */
    transition: color 0.3s ease, background 0.3s ease; /* Smooth transitions, no transform needed */
    margin-right: 0.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px; /* Icon font-size instead of width/height approach */
}

.swrcsfl-toggle-text {
    padding-left: 0.5em;
    flex: 1;
    text-align: left;
    font-weight: 500;
    font-size: 16px; /* Match exact LearnDash default section heading font size */
    color: var(--bb-headings-color); /* Match exact LearnDash section heading color */
    letter-spacing: 0.6px; /* Match LearnDash section heading letter-spacing */
    text-transform: capitalize; /* Less aggressive than uppercase per client request */
}

/* Expanded state - No rotation needed, JavaScript will change icon class */
/* .swrcsfl-section-toggle-btn.expanded .swrcsfl-toggle-icon - handled by JavaScript */

/* Section content styling */
.swrcsfl-section-content {
    margin-left: 26px;
    border-left: 2px solid #e2e7ed;
    padding-left: 20px;
    margin-bottom: 20px;
    overflow: visible; /* Allow tooltips to show outside container */
    transition: all 0.3s ease;
    background-color: #ffffff; /* Default background - will be overridden by dynamic CSS */
}

.ld-section-wrapper {
    margin-bottom: 20px;
}

.swrcsfl-section-heading-wrapper {
    margin-bottom: 0;
}

/* Ensure proper spacing for lessons within sections */
.swrcsfl-section-content .ld-item-list-item {
    margin: 1em 0;
}

/* Remove extra borders from nested lessons */
.swrcsfl-section-content .ld-item-list-item {
    border-left: none;
    margin-left: 0;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .swrcsfl-section-toggle-btn {
        text-align: left;
        padding: 15px;
    }
    
    .swrcsfl-toggle-text {
        font-size: 14px; /* Slightly smaller on mobile but still readable */
    }
}

/* Course page specific styles - only show toggle icons on course pages */
body.single-sfwd-courses .swrcsfl-toggle-icon {
    display: flex;
}

/* Hide toggle icons on non-course pages */
body:not(.single-sfwd-courses) .swrcsfl-toggle-icon {
    display: none !important;
}

/* TOOLTIP VISIBILITY FIX: Ensure tooltips display properly above section containers */
.swrcsfl-section-content .ld-item-list-item {
    position: relative; /* Allow proper positioning for tooltips */
    z-index: 10; /* Higher z-index for lesson items to show tooltips */
}

/* Ensure tooltips have highest z-index */
.swrcsfl-section-content .ld-item-list-item .tooltip,
.swrcsfl-section-content .ld-item-list-item [class*="tooltip"],
.swrcsfl-section-content .ld-item-list-item .ld-status-tooltip,
.swrcsfl-section-content .ld-item-list-item [data-tooltip],
.swrcsfl-section-content .ld-item-list-item .bb-tooltip {
    z-index: 9999 !important; /* Highest z-index for all tooltip types */
    position: relative !important; /* Ensure proper positioning */
}

/* Fix for BuddyBoss/LearnDash specific tooltip containers */
.ld-item-list-item-preview .ld-status-tooltip,
.ld-item-list-item .ld-status-tooltip {
    z-index: 9999 !important;
    position: absolute !important;
}

/* ========================================
   MODERN UI STYLES (LearnDash 4.16.0+)
   ======================================== */

/* Modern UI Section Wrapper */
.swrcsfl-modern-section-wrapper {
    margin-bottom: 1rem;
}

/* Modern UI Section Toggle Button */
.swrcsfl-modern-section-toggle-btn {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    user-select: none;
    margin-bottom: 0.5rem;
}

.swrcsfl-modern-section-toggle-btn:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.swrcsfl-modern-section-toggle-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Modern UI Toggle Icon */
.swrcsfl-modern-section-toggle-btn .swrcsfl-toggle-icon {
    margin-right: 0.5rem;
    font-size: 16px;
    transition: transform 0.2s ease;
    color: #6c757d;
}

/* Ensure default state shows arrow-right (collapsed) */
.swrcsfl-modern-section-toggle-btn:not(.expanded) .swrcsfl-toggle-icon {
    /* Default state - should show arrow-right */
}

.swrcsfl-modern-section-toggle-btn.expanded .swrcsfl-toggle-icon {
    /* Expanded state - should show arrow-down */
}

/* Modern UI Section Title */
.swrcsfl-modern-section-toggle-btn .swrcsfl-modern-section-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: #495057;
    margin: 0;
    padding-bottom: 18px;
}

/* Modern UI Section Content */
.swrcsfl-modern-section-content {
    margin-left: 1.5rem;
    padding-left: 1rem;
    border-left: 2px solid #e9ecef;
    display: none; /* Hidden by default */
}

.swrcsfl-modern-section-content.expanded {
    display: block;
}

/* Modern UI Lesson Items within Sections */
.swrcsfl-modern-section-content .ld-accordion__item {
    margin-bottom: 0.5rem;
}

.swrcsfl-modern-section-content .ld-accordion__item:last-child {
    margin-bottom: 0;
}

/* Responsive adjustments for Modern UI */
@media (max-width: 768px) {
    .swrcsfl-modern-section-toggle-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .swrcsfl-modern-section-content {
        margin-left: 1rem;
        padding-left: 0.75rem;
    }
    
    .swrcsfl-modern-section-toggle-btn .swrcsfl-modern-section-title {
        font-size: 1rem;
    }
}

/* Integration with LearnDash Modern UI theme colors */
.ld-accordion--course .swrcsfl-modern-section-toggle-btn {
    background: var(--ld-color-background-secondary, #f8f9fa);
    border-color: var(--ld-color-border, #e9ecef);
}

.ld-accordion--course .swrcsfl-modern-section-toggle-btn:hover {
    background: var(--ld-color-background-tertiary, #e9ecef);
}

.ld-accordion--course .swrcsfl-modern-section-content {
    border-left-color: var(--ld-color-border, #e9ecef);
}

/* Dark mode support for Modern UI */
@media (prefers-color-scheme: dark) {
    .swrcsfl-modern-section-toggle-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .swrcsfl-modern-section-toggle-btn:hover {
        background: #4a5568;
        border-color: #718096;
    }
    
    .swrcsfl-modern-section-toggle-btn .swrcsfl-modern-section-title {
        color: #e2e8f0;
    }
    
    .swrcsfl-modern-section-toggle-btn .swrcsfl-toggle-icon {
        color: #a0aec0;
    }
    
    .swrcsfl-modern-section-content {
        border-left-color: #4a5568;
    }
}