/**
 * BuddyBoss Theme Compatibility Styles
 * Version: 1.0.0
 */

/* ==========================================================================
   BuddyBoss Layout Adjustments
   ========================================================================== */

/* Account for BuddyBoss left sidebar */
body.buddyboss-theme #content {
    position: relative;
}

/* Toolbar positioning with sidebar */
body.buddyboss-theme .ald-toolbar-bottom-left,
body.buddyboss-theme .ald-toolbar-top-left {
    left: 280px; /* BuddyBoss sidebar width + margin */
    transition: left 0.3s ease;
}

/* When sidebar is collapsed */
body.buddyboss-theme.lm-collapsed .ald-toolbar-bottom-left,
body.buddyboss-theme.lm-collapsed .ald-toolbar-top-left {
    left: 80px; /* Collapsed sidebar width */
}

/* Mobile - sidebar hidden */
@media (max-width: 999px) {
    body.buddyboss-theme .ald-toolbar-bottom-left,
    body.buddyboss-theme .ald-toolbar-top-left {
        left: 20px !important;
    }
}

/* ==========================================================================
   BuddyBoss Header Integration
   ========================================================================== */

/* Avoid sticky header overlap */
body.buddyboss-theme.bb-sticky-header .ald-toolbar-top-left,
body.buddyboss-theme.bb-sticky-header .ald-toolbar-top-right {
    top: 90px; /* Below BuddyBoss sticky header */
}

/* When mobile header is visible */
@media (max-width: 999px) {
    body.buddyboss-theme .ald-toolbar-top-left,
    body.buddyboss-theme .ald-toolbar-top-right {
        top: 70px; /* Below mobile header */
    }
}

/* ==========================================================================
   BuddyBoss Dark Mode Compatibility
   ========================================================================== */

/* Override dark mode when high contrast is enabled */
body.buddyboss-theme.bb-dark-theme.ald-contrast-high {
    --bb-body-background-color: #ffffff !important;
    --bb-text-color: #000000 !important;
}

body.buddyboss-theme.bb-dark-theme.ald-contrast-high * {
    color: #000000 !important;
}

body.buddyboss-theme.bb-dark-theme.ald-contrast-high a {
    color: #0000ee !important;
}

/* Dark mode + our dark mode = normal mode */
body.buddyboss-theme.bb-dark-theme.ald-contrast-dark {
    filter: none; /* Don't double-invert */
}

/* ==========================================================================
   LearnDash in BuddyBoss
   ========================================================================== */

/* Course progress bar */
body.buddyboss-theme .bb-progress-wrap {
    position: relative;
}

body.buddyboss-theme .bb-progress-wrap:focus-within {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* Lesson list items */
body.buddyboss-theme .bb-lesson-item:focus,
body.buddyboss-theme .bb-topic-item:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* Quiz questions in BuddyBoss */
body.buddyboss-theme .wpProQuiz_question:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 4px;
    background: rgba(0, 102, 204, 0.05);
}

/* Assignment upload area */
body.buddyboss-theme .learndash_assignment_form:focus-within {
    outline: 2px solid var(--ald-focus-color);
    outline-offset: 4px;
    border-radius: 4px;
}

/* ==========================================================================
   BuddyBoss Sidebar Navigation
   ========================================================================== */

/* Enhanced focus states for sidebar links */
body.buddyboss-theme #left-panel-inner a:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: -2px; /* Inside border for contained look */
    background: rgba(0, 102, 204, 0.1);
}

/* Active/current item in sidebar */
body.buddyboss-theme #left-panel-inner .current-menu-item a:focus {
    outline-color: var(--ald-focus-color);
}

/* ==========================================================================
   BuddyBoss Course Sidebar
   ========================================================================== */

/* Right sidebar in courses */
body.buddyboss-theme .bb-course-sidebar {
    position: relative;
}

/* Ensure toolbar doesn't overlap course sidebar on large screens */
@media (min-width: 1200px) {
    body.buddyboss-theme .ald-toolbar-bottom-right,
    body.buddyboss-theme .ald-toolbar-top-right {
        right: 340px; /* Account for course sidebar */
    }
    
    /* When sidebar is closed */
    body.buddyboss-theme.lm-course-sidebar-closed .ald-toolbar-bottom-right,
    body.buddyboss-theme.lm-course-sidebar-closed .ald-toolbar-top-right {
        right: 20px;
    }
}

/* ==========================================================================
   BuddyBoss Buttons
   ========================================================================== */

/* Primary buttons */
body.buddyboss-theme .bb-primary-button:focus,
body.buddyboss-theme button.bb-primary-button:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* Mark complete button */
body.buddyboss-theme .learndash_mark_complete_button:focus,
body.buddyboss-theme .learndash_mark_incomplete_button:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* ==========================================================================
   BuddyBoss Modal Dialogs
   ========================================================================== */

/* Ensure our modals appear above BuddyBoss modals */
.ald-modal {
    z-index: 999999 !important; /* Higher than BuddyBoss modal (z-index: 9999) */
}

body.buddyboss-theme .bb-modal-overlay {
    z-index: 999998; /* Just below our accessibility modal */
}

/* ==========================================================================
   BuddyBoss Media Gallery
   ========================================================================== */

/* Focus states for media items */
body.buddyboss-theme .bb-media-container .bb-photo-thumb:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* ==========================================================================
   BuddyBoss Activity Stream
   ========================================================================== */

/* Activity items */
body.buddyboss-theme #buddypress .activity-list li:focus-within {
    outline: 2px solid var(--ald-focus-color);
    outline-offset: 4px;
    border-radius: 4px;
}

/* ==========================================================================
   BuddyBoss Search
   ========================================================================== */

/* Search input in header */
body.buddyboss-theme .header-search-wrap .search-form-input:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Toolbar Panel Adjustments for BuddyBoss
   ========================================================================== */

/* Ensure panel is readable over BuddyBoss backgrounds */
body.buddyboss-theme .ald-toolbar-panel {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); /* Stronger shadow */
}

/* Light mode adjustments */
body.buddyboss-theme:not(.bb-dark-theme) .ald-toolbar-panel {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Contrast Mode Fixes for BuddyBoss
   ========================================================================== */

/* High contrast with BuddyBoss elements */
body.buddyboss-theme.ald-contrast-high .bb-card,
body.buddyboss-theme.ald-contrast-high .bb-panel {
    background: #ffffff !important;
    border-color: #000000 !important;
}

body.buddyboss-theme.ald-contrast-high .bb-primary-button {
    background: #000000 !important;
    color: #ffffff !important;
    border-color: #000000 !important;
}

/* Inverted mode - preserve BuddyBoss images */
body.buddyboss-theme.ald-contrast-inverted .bb-user-avatar img,
body.buddyboss-theme.ald-contrast-inverted .bb-course-avatar img {
    filter: invert(1) hue-rotate(180deg); /* Re-invert to normal */
}

/* ==========================================================================
   Assignment Page Specific Fixes
   ========================================================================== */

/* Fix for assignment upload critical error */
body.buddyboss-theme .learndash_assignment_form {
    position: relative;
    min-height: 200px;
}

/* File upload button */
body.buddyboss-theme .learndash_assignment_form input[type="file"]:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* Assignment submit button */
body.buddyboss-theme .learndash_assignment_form input[type="submit"]:focus {
    outline: var(--ald-focus-width) solid var(--ald-focus-color);
    outline-offset: 2px;
}

/* ==========================================================================
   Font Size Adjustments for BuddyBoss
   ========================================================================== */

/* Don't scale BuddyBoss navigation when font size changes */
body.buddyboss-theme.ald-preferences-active #left-panel-inner * {
    font-size: 14px !important; /* Keep navigation readable */
}

/* Scale main content only */
body.buddyboss-theme.ald-preferences-active #buddyboss-content * {
    font-size: calc(1em * var(--ald-font-size) / 100) !important;
}

/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */

@media (max-width: 768px) {
    /* Full-width toolbar on mobile */
    body.buddyboss-theme .ald-toolbar {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
    }
    
    /* Toolbar toggle in bottom right */
    body.buddyboss-theme .ald-toolbar-toggle {
        position: absolute;
        right: 20px;
        bottom: 20px;
    }
    
    /* Panel slides up from bottom */
    body.buddyboss-theme .ald-toolbar-panel {
        position: fixed;
        top: auto !important;
        bottom: 70px !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 12px 12px 0 0;
    }
}

/* ==========================================================================
   Print Compatibility
   ========================================================================== */

@media print {
    /* Hide BuddyBoss sidebar and our toolbar when printing */
    body.buddyboss-theme #left-panel,
    body.buddyboss-theme .ald-toolbar {
        display: none !important;
    }
    
    /* Full width content for printing */
    body.buddyboss-theme #buddyboss-content {
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
}
