/**
 * Combined stylesheet for lesson view: sidebar and navigation.
 * Cross-browser compatible W3Schools-style lesson navigation
 *
 * --- REFACTORED FOR MODERN CSS BEST PRACTICES ---
 * - Uses CSS Custom Properties for easy theming and consistency.
 * - Employs CSS Logical Properties for robust, automatic RTL support.
 * - Simplified selectors and removed outdated vendor prefixes.
 * - Improved organization and accessibility considerations.
 *
 * Browser Support: Chrome 60+, Firefox 55+, Safari 12+, Edge 79+
 */

:root {
    /* Colors */
    --clr-accent: #04AA6D;
    --clr-accent-hover: #059862;
    --clr-accent-light: #e7f4e8;
    --clr-danger: #e74c3c;
    --clr-text-main: #000;
    --clr-text-subtle: #444;
    --clr-text-light: #666;
    --clr-border: #e0e0e0;
    --clr-bg-sidebar: #f1f1f1;
    --clr-bg-hover: #e0e0e0;
    --clr-bg-active: #ffffff;
    --clr-white: #ffffff;

    /* Sizing & Layout */
    --header-height: 100px; /* Adjust to your site's header height */
    --sidebar-width: 280px;
    --sidebar-width-md: 260px;
    --sidebar-width-sm: 240px;

    /* Transitions */
    --transition-speed: 0.3s;
    --transition-timing: ease;

    /* Borders */
    --border-radius-sm: 3px;
    --border-radius-md: 4px;
}


/* ==========================================================================
   Base Layout
   ========================================================================== */

.lesson-page-container {
    display: flex;
    min-height: calc(100vh - var(--header-height));
    position: relative;
}

.site-main {
    flex: 1;
    padding: 20px 30px;
    /* Prevents content from being hidden by the slide-in sidebar on mobile */
    overflow-x: hidden;
}


/* ==========================================================================
   Sidebar
   ========================================================================== */

.lessons-sidebar {
    width: var(--sidebar-width);
    background-color: var(--clr-bg-sidebar);
    padding: 20px 0;
    border-inline-end: 1px solid var(--clr-border);
    overflow-y: auto;
    flex: 0 0 auto;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: transform var(--transition-speed) var(--transition-timing);
    z-index: 10;
    -webkit-overflow-scrolling: touch; /* For smooth scrolling on iOS */
}

/* Custom scrollbar styling */
.lessons-sidebar::-webkit-scrollbar {
    width: 6px;
}
.lessons-sidebar::-webkit-scrollbar-track {
    background: var(--clr-bg-sidebar);
}
.lessons-sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: var(--border-radius-sm);
}
.lessons-sidebar::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Sidebar toggle button for mobile
 * HTML suggestion: <button class="sidebar-toggle" aria-label="Toggle navigation" aria-expanded="false" aria-controls="lessons-sidebar">
 */
.sidebar-toggle {
    display: none; /* Hidden by default, shown in media query */
    position: fixed;
    top: 15px;
    inset-inline-end: 15px; /* Use logical property for RTL support */
    z-index: 1000; /* Higher than sidebar */
    background-color: var(--clr-accent);
    color: var(--clr-white);
    border: none;
    border-radius: var(--border-radius-md);
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background-color var(--transition-speed) var(--transition-timing), transform var(--transition-speed) var(--transition-timing);
    -webkit-tap-highlight-color: transparent; /* Improve touch experience */
}

.sidebar-toggle:hover {
    background-color: var(--clr-accent-hover);
    transform: scale(1.05);
}

.sidebar-toggle.is-active {
    background-color: var(--clr-danger);
}

/* Hamburger Icon Animation */
.sidebar-toggle .bar {
    display: block; /* Make sure it's a block-level element */
    width: 20px; /* Define width for centering */
    height: 3px;
    background-color: var(--clr-white);
    transition: all var(--transition-speed) var(--transition-timing);
    margin: 4px auto; /* Center the bars */
}

.sidebar-toggle.is-active .bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.sidebar-toggle.is-active .bar:nth-child(2) {
    opacity: 0;
}
.sidebar-toggle.is-active .bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}


/* ==========================================================================
   Sidebar Content & Menus
   ========================================================================== */

.lessons-sidebar .widget {
    margin-bottom: 20px;
}

.lessons-sidebar .widget-title {
    color: var(--clr-accent);
    padding: 0 20px;
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

/* Main language navigation */
.languages-menu,
.lessons-submenu {
    list-style-type: none;
    padding: 0;
    margin: 0;
}

.language-item {
    margin-bottom: 2px;
}

.language-toggle {
    display: block;
    padding: 10px 20px;
    color: var(--clr-text-main);
    text-decoration: none;
    transition: background-color 0.2s, border-color 0.2s;
    font-weight: 500;
    border-inline-end: 4px solid transparent; /* Logical property */
}

.language-toggle:hover,
.language-item.active > .language-toggle {
    background-color: var(--clr-bg-hover);
    border-inline-end-color: var(--clr-accent);
}

.language-icon {
    display: inline-block;
    margin-inline-start: 8px; /* Logical property */
    vertical-align: middle;
    font-size: 20px;
    color: var(--clr-accent);
}

/* Sub-menu for individual lessons */
.lessons-submenu {
    display: none;
    background-color: var(--clr-bg-active);
}

.lessons-submenu.is-expanded {
    display: block;
}

.lesson-item a {
    display: block;
    padding: 8px 10px 8px 20px;
    color: var(--clr-text-main);
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s, border-color 0.2s;
    border-inline-end: 4px solid transparent; /* Logical property */
    margin-inline-end: 20px; /* Logical property */
}

.lesson-item a:hover,
.lesson-item.is-active a {
    background-color: var(--clr-accent-light);
    border-inline-end-color: var(--clr-accent);
}

.lesson-icon {
    display: inline-block;
    margin-inline-start: 8px; /* Logical property */
    vertical-align: middle;
    font-size: 16px;
    color: #757575;
}

.lesson-item.is-active .lesson-icon {
    color: var(--clr-accent);
}


/* ==========================================================================
   Lesson Navigation (Prev/Next)
   ========================================================================== */

.improved-lesson-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin: 30px 0;
}

.nav-prev, .nav-next {
    flex: 1; /* Allows buttons to share space equally */
}

.prev-lesson-link, .next-lesson-link {
    display: block;
    padding: 15px 20px;
    background-color: var(--clr-bg-sidebar);
    border-radius: var(--border-radius-md);
    transition: background-color var(--transition-speed) var(--transition-timing);
    text-decoration: none;
    color: var(--clr-text-subtle);
    border: 1px solid var(--clr-border);
}

.prev-lesson-link:hover, .next-lesson-link:hover {
    background-color: var(--clr-bg-hover);
}

.nav-label {
    display: block;
    font-size: 0.8rem;
    color: var(--clr-accent);
    margin-bottom: 5px;
}

.lesson-title {
    display: block;
    font-weight: bold;
    font-size: 1.1rem;
}

/* Arrow styling using transform for easy flipping in RTL */
.nav-arrow {
    display: inline-block;
    font-weight: bold;
    color: var(--clr-accent);
    transition: transform 0.2s;
}

/* LTR default arrows */
.nav-prev .nav-arrow { margin-inline-end: 8px; }
.nav-next .nav-arrow { margin-inline-start: 8px; }

/* In RTL, the browser will automatically reverse flexbox and text order.
   We just need to flip the arrow direction visually. */
html[dir="rtl"] .nav-prev .nav-arrow { transform: scaleX(-1); }
html[dir="rtl"] .nav-next .nav-arrow { transform: scaleX(-1); }

/* Suggestion: Use unicode arrows for better semantics: ← and → or SVG icons */

.disabled-nav {
    opacity: 0.4;
    pointer-events: none; /* Prevents clicking on disabled nav */
}

/* ==========================================================================
   Responsive Styles
   ========================================================================== */

@media screen and (max-width: 992px) {
    .lessons-sidebar {
        position: fixed;
        inset-inline-start: 0; /* Use logical property */
        top: 0;
        transform: translateX(-100%);
        width: var(--sidebar-width);
        height: 100vh;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
        z-index: 999;
    }
    
    /* RTL-specific transform */
    html[dir="rtl"] .lessons-sidebar {
        transform: translateX(100%);
    }

    .lessons-sidebar.is-open {
        transform: translateX(0);
    }
    
    .sidebar-toggle {
        display: flex; /* Use flex to easily center icon bars */
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }
    
    .site-main {
        padding-top: 60px; /* Space for the toggle button */
    }
}

@media screen and (max-width: 768px) {
    .sidebar-toggle {
        inset-inline-start: 15px; /* Move toggle to the start on mobile */
        inset-inline-end: auto;
    }
    
    .lessons-sidebar {
        width: var(--sidebar-width-md);
    }
    
    .lessons-sidebar .widget-title {
        font-size: 16px;
        padding: 14px 18px;
    }
    
    .lessons-sidebar li a {
        padding: 10px 18px;
        font-size: 14px;
    }

    .improved-lesson-navigation {
        flex-direction: column;
    }
    
    .site-main {
        padding: 60px 20px 30px;
    }
}

@media screen and (max-width: 480px) {
    .sidebar-toggle {
        top: 10px;
        inset-inline-start: 10px;
        width: 35px;
        height: 35px;
    }
    
    .lessons-sidebar {
        width: var(--sidebar-width-sm);
    }
    
    .site-main {
        padding-inline: 15px;
    }
}
/* ==========================================================================
   Breadcrumbs & Progress Indicators
   ========================================================================== */

/* Breadcrumbs (for page context) */
.lesson-breadcrumb {
    font-size: 0.9rem;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 1px solid var(--clr-border);
}

.breadcrumb-home,
.breadcrumb-language,
.breadcrumb-current {
    display: inline-block;
}

.breadcrumb-separator {
    padding-inline: 5px; /* Use logical property */
    color: #999;
}

.breadcrumb-current {
    color: var(--clr-accent);
    font-weight: bold;
}

.breadcrumb-icon {
    margin-inline-end: 5px; /* Use logical property */
}

/* Lesson Progress Bar */
.lesson-progress-container {
    height: 10px;
    background-color: var(--clr-bg-sidebar);
    border-radius: 5px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.lesson-progress-bar {
    height: 100%;
    background-color: var(--clr-accent);
    border-radius: 5px;
    /* The 'width' property will be set via inline style or JS */
    transition: width 0.5s var(--transition-timing);
}

.lesson-progress-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--clr-text-light);
    margin-top: 5px;
}


/* ==========================================================================
   Content Styles (Within Responsive Media Queries)
   ========================================================================== */

/*
 * NOTE: These styles were originally inside your other media queries.
 * It's often cleaner to keep content styles separate or grouped logically.
 * Add these inside the appropriate `@media` blocks in the main stylesheet.
*/

@media screen and (max-width: 768px) {
    /* Main page heading style */
    .lesson-title-heading { /* Renamed to avoid conflict with .lesson-title in nav buttons */
        font-size: 36px;
        margin: 0 0 15px;
        font-weight: 700;
    }

    .lesson-content {
        padding: 20px;
        margin-bottom: 20px;
        /* Example: add a background and border */
        background-color: var(--clr-bg-active);
        border: 1px solid var(--clr-border);
        border-radius: var(--border-radius-md);
    }
}

@media screen and (max-width: 480px) {
    .lesson-title-heading {
        font-size: 24px;
    }

    .lesson-excerpt {
        font-size: 18px;
        margin-bottom: 20px;
        color: var(--clr-text-subtle);
    }

    .lesson-content {
        padding: 15px;
    }

    .lesson-meta {
        display: flex;
        flex-wrap: wrap;
        gap: 25px;
        font-size: 14px;
        margin-top: 25px;
    }
}