/**
 * ═══════════════════════════════════════════════════════════════
 * Read Page Styles - WCAG 2.2 AAA Compliant
 * ═══════════════════════════════════════════════════════════════
 *
 * Modern Course Navigation Sidebar
 * Award-Winning UX/UI Design Features:
 * - Collapsible sidebar with icon rail
 * - Current location indicator
 * - Search/filter lessons
 * - Module accordion with smooth animations
 * - Mobile-first responsive design
 * - Full keyboard accessibility
 * - High contrast WCAG AAA compliance
 */

/* ===== CSS Custom Properties ===== */
.sidebar-nav {
    --sidebar-width: 320px;
    --sidebar-rail-width: 56px;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e7eb;
    --sidebar-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --sidebar-header-bg: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    --accent-primary: #2563eb;
    --accent-primary-dark: #1d4ed8;
    --accent-secondary: #0891b2;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

/* ===== Sidebar Container ===== */
.sidebar-nav {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    z-index: 1040;
    display: flex;
    transition: width var(--transition-base);
}

.sidebar-nav--collapsed {
    width: var(--sidebar-rail-width);
}

/* ===== Sidebar Toggle Button ===== */
.sidebar-toggle-btn {
    position: absolute;
    top: 1rem;
    right: -1.25rem;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--accent-primary);
    color: #ffffff;
    border: 3px solid #ffffff;
    border-radius: 50%;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
    background: var(--accent-primary-dark);
    transform: scale(1.1);
}

.sidebar-toggle-btn:focus-visible {
    outline: 3px solid var(--accent-primary);
    outline-offset: 3px;
}

/* ===== Sidebar Panel ===== */
.sidebar-panel {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    box-shadow: var(--sidebar-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform var(--transition-base), opacity var(--transition-base);
}

.sidebar-panel[hidden] {
    display: none;
}

/* ===== Sidebar Header ===== */
.sidebar-header {
    background: var(--sidebar-header-bg);
    color: #ffffff;
    padding: 1rem 1.25rem;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.sidebar-brand-icon {
    width: 2.5rem;
    height: 2.5rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    overflow: hidden;
}

.sidebar-brand-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.025em;
    opacity: 0.9;
}

.sidebar-brand-subtitle {
    display: block;
    font-size: 0.75rem;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

/* ===== School Badge ===== */
.sidebar-school-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: #ffffff;
    opacity: 0.9;
}

.sidebar-school-badge i {
    font-size: 0.875rem;
    opacity: 0.8;
}

.sidebar-school-badge span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    font-weight: 500;
}

/* ===== Quick Actions ===== */
.sidebar-actions {
    display: flex;
    gap: 0.5rem;
}

.sidebar-action-btn {
    width: 2.25rem;
    height: 2.25rem;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.sidebar-action-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.sidebar-action-btn:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* ===== Current Location Indicator ===== */
.sidebar-current-location {
    background: linear-gradient(135deg, #dbeafe 0%, #e0f2fe 100%);
    border-bottom: 1px solid var(--sidebar-border);
    padding: 0.75rem 1rem;
    flex-shrink: 0;
}

.current-location-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-primary);
    margin-bottom: 0.375rem;
}

.current-location-label i {
    font-size: 0.75rem;
}

.current-location-path {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.current-location-path i {
    font-size: 0.625rem;
    color: var(--text-muted);
}

.current-unit {
    color: var(--text-secondary);
}

.current-page {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

/* ===== Search Bar ===== */
.sidebar-search {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}

.sidebar-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.sidebar-search-wrapper > i {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    pointer-events: none;
}

.sidebar-search-input {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 2.25rem;
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: #f9fafb;
    transition: all var(--transition-fast);
}

.sidebar-search-input::placeholder {
    color: var(--text-muted);
}

.sidebar-search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.sidebar-search-clear {
    position: absolute;
    right: 0.5rem;
    width: 1.5rem;
    height: 1.5rem;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    transition: all var(--transition-fast);
}

.sidebar-search-clear:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.sidebar-search-clear[hidden] {
    display: none;
}

/* ===== Navigation Tree ===== */
.sidebar-nav-tree {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
}

/* Custom Scrollbar */
.sidebar-nav-tree::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav-tree::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav-tree::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.sidebar-nav-tree::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ===== Module Styles ===== */
.nav-module {
    border-bottom: 1px solid var(--sidebar-border);
}

.nav-module:last-child {
    border-bottom: none;
}

.nav-module--current {
    background: #fefce8;
}

.nav-module-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast);
}

.nav-module-header:hover {
    background: #f3f4f6;
}

.nav-module-header:focus-visible {
    outline: none;
    box-shadow: inset 0 0 0 2px var(--accent-primary);
}

.nav-module-indicator {
    width: 2rem;
    height: 2rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.module-number {
    font-size: 0.8125rem;
    font-weight: 700;
    color: #ffffff;
}

.nav-module-info {
    flex: 1;
    min-width: 0;
}

.nav-module-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-module-meta {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.125rem;
}

.nav-module-chevron {
    color: var(--text-muted);
    transition: transform var(--transition-base);
}

.nav-module-header.expanded .nav-module-chevron {
    transform: rotate(180deg);
}

/* ===== Module Content ===== */
.nav-module-content {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height var(--transition-base), opacity var(--transition-base);
}

.nav-module-content.expanded {
    max-height: 2000px;
    opacity: 1;
}

.nav-module-content[hidden] {
    display: none;
}

/* ===== Unit Styles ===== */
.nav-unit {
    border-top: 1px solid #f3f4f6;
}

.nav-unit--current .nav-unit-header {
    background: #eff6ff;
    border-left: 3px solid var(--accent-primary);
}

.nav-unit-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem 0.625rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    background: #f9fafb;
}

.nav-unit-header i {
    font-size: 0.875rem;
    color: var(--accent-primary);
}

.nav-unit-title {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-unit-count {
    width: 1.5rem;
    height: 1.5rem;
    background: #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===== Lessons List ===== */
.nav-lessons-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-lesson-item {
    position: relative;
}

.nav-lesson-item.highlight {
    animation: lessonHighlight 1.5s ease-out;
}

@keyframes lessonHighlight {
    0% { background: #fef3c7; }
    100% { background: transparent; }
}

.nav-lesson-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 1rem 0.625rem 2rem;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.8125rem;
    line-height: 1.4;
    transition: all var(--transition-fast);
    border-left: 3px solid transparent;
}

.nav-lesson-link:hover {
    background: #f3f4f6;
    border-left-color: #d1d5db;
}

.nav-lesson-link:focus-visible {
    outline: none;
    background: #e0f2fe;
    border-left-color: var(--accent-primary);
}

/* Active Lesson */
.nav-lesson-item--active .nav-lesson-link {
    background: linear-gradient(90deg, #dbeafe 0%, #eff6ff 100%);
    border-left-color: var(--accent-primary);
    color: var(--accent-primary-dark);
    font-weight: 600;
}

.nav-lesson-indicator {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lesson-number {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-muted);
    background: #f3f4f6;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.nav-lesson-item--active .nav-lesson-indicator i {
    color: var(--accent-primary);
    font-size: 1.125rem;
}

.nav-lesson-title {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-lesson-current-badge {
    width: 1.25rem;
    height: 1.25rem;
    background: var(--accent-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 0.625rem;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(0.95); }
}

/* ===== Sidebar Footer ===== */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 0.75rem 1rem;
    background: #f9fafb;
    flex-shrink: 0;
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 500;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    margin-bottom: 0.5rem;
}

.sidebar-footer-link:hover {
    background: #e5e7eb;
    color: var(--text-primary);
}

.sidebar-footer-link:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.sidebar-keyboard-hint {
    font-size: 0.6875rem;
    color: var(--text-muted);
    text-align: center;
}

.sidebar-keyboard-hint kbd {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    background: #e5e7eb;
    border-radius: 0.25rem;
    font-family: inherit;
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--text-secondary);
    border: 1px solid #d1d5db;
}

/* ===== Sidebar Rail (Collapsed State) ===== */
.sidebar-rail {
    width: var(--sidebar-rail-width);
    height: 100%;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    gap: 0.5rem;
    overflow-y: auto;
}

.sidebar-rail[hidden] {
    display: none;
}

.rail-item {
    width: 2.5rem;
    height: 2.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.rail-item:hover {
    background: #f3f4f6;
    border-color: var(--sidebar-border);
    color: var(--text-primary);
}

.rail-item:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

.rail-item--active {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #ffffff;
    border-color: transparent;
}

.rail-item--active:hover {
    background: linear-gradient(135deg, var(--accent-primary-dark) 0%, var(--accent-primary) 100%);
    color: #ffffff;
}

.rail-module-number {
    font-size: 0.875rem;
    font-weight: 700;
}

.rail-item--expand {
    margin-top: auto;
    background: #f3f4f6;
    border-color: var(--sidebar-border);
}

.rail-item--expand:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #ffffff;
}

/* ===== Mobile Navigation ===== */
.mobile-nav-trigger {
    position: fixed;
    bottom: 1.5rem;
    left: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: #ffffff;
    border: none;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    z-index: 1030;
    transition: all var(--transition-fast);
}

.mobile-nav-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(37, 99, 235, 0.5);
}

.mobile-nav-trigger:focus-visible {
    outline: 3px solid var(--accent-primary);
    outline-offset: 3px;
}

.mobile-nav-trigger i {
    font-size: 1.125rem;
}

/* Mobile Overlay */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 1035;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.sidebar-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

/* Mobile Sidebar Open State */
.sidebar-nav--mobile-open {
    z-index: 1045;
}

.sidebar-nav--mobile-open .sidebar-panel {
    transform: translateX(0);
}

/* ===== Main Content Area Adjustment ===== */
.main-content-area {
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition-base), max-width var(--transition-base);
    /* Override Bootstrap col-lg-9 to allow expansion */
    width: auto !important;
    max-width: calc(100% - var(--sidebar-width)) !important;
    flex: 1 1 auto !important;
}

.sidebar-nav--collapsed ~ .main-content-area {
    margin-left: var(--sidebar-rail-width);
    max-width: calc(100% - var(--sidebar-rail-width)) !important;
}

/* Reading Progress Bar */
#readingProgress {
    background: linear-gradient(90deg, #0d6efd 0%, #0a58ca 100%);
    box-shadow: 0 2px 4px rgba(13, 110, 253, 0.3);
}

/* Content Body Enhancements */
.content-body {
    line-height: 1.8;
    font-size: 1.0625rem;
    color: #212529;
}

.content-body h1,
.content-body h2,
.content-body h3,
.content-body h4,
.content-body h5,
.content-body h6 {
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

/* WCAG AAA: Override heading colors inside colored card headers */
.content-body .card-header h1,
.content-body .card-header h2,
.content-body .card-header h3,
.content-body .card-header h4,
.content-body .card-header h5,
.content-body .card-header h6 {
    color: inherit;
    margin-top: 0;
    margin-bottom: 0;
}

.content-body .card-header.bg-danger h1,
.content-body .card-header.bg-danger h2,
.content-body .card-header.bg-danger h3,
.content-body .card-header.bg-danger h4,
.content-body .card-header.bg-danger h5,
.content-body .card-header.bg-danger h6,
.content-body .card-header.bg-danger i,
.content-body .card-header.bg-danger * {
    color: #ffffff !important;
}

.content-body .card-header.bg-success h1,
.content-body .card-header.bg-success h2,
.content-body .card-header.bg-success h3,
.content-body .card-header.bg-success h4,
.content-body .card-header.bg-success h5,
.content-body .card-header.bg-success h6,
.content-body .card-header.bg-success i,
.content-body .card-header.bg-success * {
    color: #ffffff !important;
}

/* Ensure bg-danger and bg-success card headers have dark backgrounds */
.card-header.bg-danger {
    background: #991b1b !important;
    background-color: #991b1b !important;
    background-image: none !important;
    color: #ffffff !important;
}

.card-header.bg-success {
    background: #166534 !important;
    background-color: #166534 !important;
    background-image: none !important;
    color: #ffffff !important;
}

.content-body h1 { font-size: 2.25rem; }
.content-body h2 { font-size: 1.875rem; }
.content-body h3 { font-size: 1.5rem; }
.content-body h4 { font-size: 1.25rem; }
.content-body h5 { font-size: 1.125rem; }
.content-body h6 { font-size: 1rem; }

.content-body p {
    margin-bottom: 1.25rem;
}

.content-body a {
    color: #0d6efd;
    text-decoration: underline;
    font-weight: 500;
}

.content-body a:hover {
    color: #0a58ca;
    text-decoration-thickness: 2px;
}

.content-body a:focus {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

/* Code Blocks */
.content-body pre {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    padding: 1rem;
    overflow-x: auto;
    position: relative;
}

.content-body code {
    background-color: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    color: #d63384;
    font-family: 'Courier New', monospace;
}

.content-body pre code {
    background-color: transparent;
    padding: 0;
    color: #000000;
    font-weight: bold;
}

/* Blockquotes */
.content-body blockquote {
    border-left: 4px solid #0d6efd;
    padding-left: 1.5rem;
    margin: 1.5rem 0;
    font-style: italic;
    color: #212529;
    background-color: #f8f9fa;
    padding: 1rem 1rem 1rem 1.5rem;
    border-radius: 0 0.375rem 0.375rem 0;
    font-weight: 500;
}

/* Lists */
.content-body ul,
.content-body ol {
    margin-bottom: 1.25rem;
    padding-left: 2rem;
}

.content-body li {
    margin-bottom: 0.5rem;
}

/* Tables */
.content-body table {
    width: 100%;
    margin-bottom: 1.5rem;
    border-collapse: collapse;
}

.content-body th,
.content-body td {
    padding: 0.75rem;
    border: 1px solid #dee2e6;
}

.content-body th {
    background-color: #f8f9fa;
    font-weight: 700;
    text-align: left;
}

.content-body tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Images */
.content-body img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    margin: 1.5rem 0;
}

/* ===== Responsive Design ===== */

/* Large screens (992px and up) - Sidebar visible */
@media (min-width: 992px) {
    .mobile-nav-trigger {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* Tablet and below (991.98px and below) */
@media (max-width: 991.98px) {
    /* Hide desktop sidebar, show mobile trigger */
    .sidebar-nav {
        position: fixed;
        left: -100%;
        width: 100%;
        max-width: 320px;
        transition: left 0.3s ease;
    }

    .sidebar-nav--mobile-open {
        left: 0;
    }

    .sidebar-toggle-btn {
        display: none;
    }

    .sidebar-rail {
        display: none !important;
    }

    .sidebar-panel {
        width: 100%;
        max-width: 320px;
    }

    /* Main content full width on mobile */
    .main-content-area {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .content-body {
        font-size: 1rem;
    }

    .content-body h1 { font-size: 1.875rem; }
    .content-body h2 { font-size: 1.5rem; }
    .content-body h3 { font-size: 1.25rem; }
}

/* Small screens (575.98px and below) */
@media (max-width: 575.98px) {
    .sidebar-nav {
        max-width: 100%;
    }

    .sidebar-panel {
        max-width: 100%;
    }

    .mobile-nav-trigger {
        padding: 0.625rem 1rem;
        font-size: 0.8125rem;
    }

    .mobile-nav-trigger-text {
        display: none;
    }

    .sidebar-brand-subtitle {
        max-width: 140px;
    }

    .current-page {
        max-width: 120px;
    }

    .nav-lesson-link {
        padding-left: 1.5rem;
    }
}

/* ===== Print Styles ===== */
@media print {
    .sidebar-nav,
    .mobile-nav-trigger,
    .sidebar-overlay,
    #readingProgress,
    .breadcrumb,
    nav[aria-label="Page navigation"] {
        display: none !important;
    }

    .main-content-area {
        margin-left: 0 !important;
    }

    .content-body {
        font-size: 12pt;
        color: #000000;
    }

    .content-body a {
        color: #000000;
        text-decoration: underline;
    }
}

/* ===== High Contrast Mode Support ===== */
@media (prefers-contrast: high) {
    .nav-module-header:focus-visible {
        box-shadow: inset 0 0 0 3px #000000;
    }

    .nav-lesson-item--active .nav-lesson-link {
        border-left-width: 5px;
    }

    .rail-item--active {
        border: 2px solid #000000;
    }

    .content-body a {
        text-decoration-thickness: 2px;
    }
}

/* ===== Reduced Motion Support ===== */
@media (prefers-reduced-motion: reduce) {
    .sidebar-nav,
    .sidebar-panel,
    .sidebar-toggle-btn,
    .nav-module-content,
    .nav-module-chevron,
    .nav-lesson-link,
    .rail-item,
    .mobile-nav-trigger,
    .sidebar-overlay,
    #readingProgress {
        transition: none !important;
    }

    .nav-lesson-current-badge {
        animation: none !important;
    }

    .nav-lesson-item.highlight {
        animation: none !important;
        background: #fef3c7;
    }
}

/* ===== Back to Top Button ===== */
/* 
 * Vertically stacked above bookmark button in bottom-right corner:
 * - Toast notification: bottom: 14rem (224px)
 * - Back-to-top button: bottom: 9.5rem (152px) 
 * - Bookmark button: bottom: 5rem (80px) via bookmarks.css
 */
#backToTop {
    position: fixed;
    bottom: 9.5rem;
    right: 1.875rem;
    width: 3.5rem;
    height: 3.5rem;
    background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 100%);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    box-shadow: 0 0.5rem 1rem rgba(13, 110, 253, 0.3);
    cursor: pointer;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(1rem) scale(0.8);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

#backToTop.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

#backToTop:hover {
    background: linear-gradient(135deg, #0a58ca 0%, #084298 100%);
    box-shadow: 0 0.75rem 1.5rem rgba(13, 110, 253, 0.5);
    transform: translateY(-0.25rem) scale(1.05);
}

#backToTop:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 0.25rem 0.5rem rgba(13, 110, 253, 0.3);
}

#backToTop:focus {
    outline: 3px solid #0d6efd;
    outline-offset: 3px;
}

#backToTop:focus:not(:focus-visible) {
    outline: none;
}

#backToTop:focus-visible {
    outline: 3px solid #0d6efd;
    outline-offset: 3px;
}

/* Back to Top Icon Animation */
#backToTop .bi {
    transition: transform 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

#backToTop:hover .bi {
    transform: translateY(-0.125rem);
}

#backToTop:active .bi,
#backToTop:focus .bi {
    transform: translateY(0);
}

/* Mobile Responsive */
@media (max-width: 767.98px) {
    #backToTop {
        bottom: 8.25rem;
        right: 1.25rem;
        width: 3rem;
        height: 3rem;
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    #backToTop {
        bottom: 8.25rem;
        right: 1.25rem;
        width: 2.75rem;
        height: 2.75rem;
        font-size: 1.125rem;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    #backToTop,
    #backToTop .bi {
        transition: none !important;
    }
    
    #backToTop.show {
        transform: none;
    }
    
    #backToTop:hover {
        transform: none;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    #backToTop {
        border: 2px solid #ffffff;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
    }
}

/* ===== Lesson Discussion Panel ===== */
.lesson-discussion-panel {
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    overflow: hidden;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Prominent variant with dark border */
.lesson-discussion-panel--prominent {
    border: 2px solid #495057;
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15);
}

/* Discussion Header (Toggle Button) */
.lesson-discussion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.lesson-discussion-header:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.lesson-discussion-header:focus {
    outline: 3px solid #0d6efd;
    outline-offset: -3px;
}

.lesson-discussion-header:focus:not(:focus-visible) {
    outline: none;
}

.lesson-discussion-header:focus-visible {
    outline: 3px solid #0d6efd;
    outline-offset: -3px;
}

.lesson-discussion-header[aria-expanded="true"] {
    border-bottom-color: #dee2e6;
    background: linear-gradient(135deg, #e7f1ff 0%, #cfe2ff 100%);
}

/* Discussion Title */
.lesson-discussion-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #212529;
}

.lesson-discussion-title .bi-chat-dots {
    color: #0d6efd;
    font-size: 1.25rem;
}

/* Badge Counter */
.lesson-discussion-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.5rem;
    background-color: #0d6efd;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 1rem;
}

/* Toggle Text/Icon */
.lesson-discussion-toggle-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    font-size: 0.875rem;
}

.lesson-discussion-toggle-text .bi-chevron-down {
    transition: transform 0.3s ease;
}

.lesson-discussion-header[aria-expanded="true"] .lesson-discussion-toggle-text .bi-chevron-down {
    transform: rotate(180deg);
}

/* Discussion Body */
.lesson-discussion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.lesson-discussion-body:not([hidden]) {
    max-height: 2000px;
    transition: max-height 0.5s ease-in;
}

.lesson-discussion-content {
    padding: 1.5rem;
}

/* Thread List */
.lesson-threads-list {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #dee2e6;
}

.lesson-thread-item {
    display: block;
    padding: 0.875rem 1rem;
    margin-bottom: 0.5rem;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease;
}

.lesson-thread-item:hover {
    background-color: #e9ecef;
    border-color: #0d6efd;
    transform: translateX(0.25rem);
}

.lesson-thread-item:focus {
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
}

.lesson-thread-title {
    font-weight: 600;
    color: #212529;
    margin-bottom: 0.375rem;
}

.lesson-thread-title .pinned-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    margin-right: 0.5rem;
    background-color: #ffc107;
    color: #000000;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: 0.25rem;
}

.lesson-thread-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.8125rem;
    color: #6c757d;
}

.lesson-thread-meta span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Empty State */
.lesson-discussion-empty {
    text-align: center;
    padding: 2rem;
    margin-bottom: 1.5rem;
}

/* Start Discussion Section */
.lesson-start-discussion {
    background-color: #f8f9fa;
    border-radius: 0.375rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.lesson-context-preview {
    padding: 0.75rem 1rem;
    background-color: #e7f1ff;
    border-left: 3px solid #0d6efd;
    border-radius: 0 0.25rem 0.25rem 0;
    font-size: 0.875rem;
    color: #495057;
}

/* Form Styles */
.lesson-discussion-form .form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Actions Section */
.lesson-discussion-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
}

/* Form Message */
#discussionFormMessage:not(:empty) {
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
}

#discussionFormMessage.alert-success {
    background-color: #d1e7dd;
    border: 1px solid #badbcc;
    color: #0f5132;
}

#discussionFormMessage.alert-danger {
    background-color: #f8d7da;
    border: 1px solid #f5c2c7;
    color: #842029;
}

/* Responsive Adjustments */
@media (max-width: 767.98px) {
    .lesson-discussion-header {
        padding: 0.875rem 1rem;
    }

    .lesson-discussion-title {
        font-size: 1rem;
    }

    .lesson-discussion-content {
        padding: 1rem;
    }

    .lesson-thread-meta {
        gap: 0.5rem;
    }

    .lesson-discussion-actions {
        flex-direction: column;
    }

    .lesson-discussion-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    .lesson-discussion-body,
    .lesson-discussion-toggle-text .bi-chevron-down,
    .lesson-thread-item {
        transition: none !important;
    }
}

/* High Contrast Mode for Discussion Panel */
@media (prefers-contrast: high) {
    .lesson-discussion-panel {
        border-width: 2px;
    }

    .lesson-thread-item:hover {
        border-width: 2px;
    }

    .lesson-discussion-badge {
        border: 1px solid #ffffff;
    }
}

/* Print Styles for Discussion Panel */
@media print {
    .lesson-discussion-panel {
        display: none !important;
    }
}

/* ===== Floating Discuss Button ===== */
/*
 * Positioned in the floating button stack:
 * - Discuss button: bottom: 14rem (this) - TOP
 * - Back-to-top: bottom: 9.5rem - MIDDLE
 * - Bookmark FAB: bottom: 5rem (80px) - BOTTOM
 */
.floating-discuss-btn {
    position: fixed !important;
    bottom: 14rem !important;
    right: 1.875rem !important;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    background: linear-gradient(135deg, #0d6efd 0%, #0b5ed7 100%);
    color: #ffffff !important;
    border: none;
    border-radius: 50%;
    box-shadow: 0 0.5rem 1.5rem rgba(13, 110, 253, 0.4);
    cursor: pointer;
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
    transition: all 0.3s ease;
    text-decoration: none !important;
}

.floating-discuss-btn.hidden {
    opacity: 0;
    visibility: hidden;
    transform: scale(0.8) translateY(1rem);
    pointer-events: none;
}

/* Legacy support for visible class */
.floating-discuss-btn.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.floating-discuss-btn:hover {
    background: linear-gradient(135deg, #0b5ed7 0%, #0a58ca 100%);
    box-shadow: 0 0.5rem 2rem rgba(13, 110, 253, 0.5);
    transform: scale(1.05) translateY(0);
}

.floating-discuss-btn:focus {
    outline: 3px solid #0d6efd;
    outline-offset: 3px;
}

.floating-discuss-btn:focus:not(:focus-visible) {
    outline: none;
}

.floating-discuss-btn:focus-visible {
    outline: 3px solid #0d6efd;
    outline-offset: 3px;
}

.floating-discuss-btn:active {
    transform: scale(0.95) translateY(0);
}

.floating-discuss-btn i {
    font-size: 1.5rem;
}

/* Floating button badge */
.floating-discuss-badge {
    position: absolute;
    top: -0.25rem;
    right: -0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    background-color: #dc3545;
    color: #ffffff;
    font-size: 0.6875rem;
    font-weight: 700;
    border-radius: 1rem;
    border: 2px solid #ffffff;
}

/* Responsive adjustments for floating button */
@media (max-width: 767.98px) {
    .floating-discuss-btn {
        width: 3rem;
        height: 3rem;
        bottom: 12.5rem !important;
        right: 1rem !important;
    }

    .floating-discuss-btn i {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .floating-discuss-btn {
        width: 2.75rem;
        height: 2.75rem;
        bottom: 12.5rem !important;
        right: 1rem !important;
    }

    .floating-discuss-btn i {
        font-size: 1.125rem;
    }
}

/* Reduced motion for floating button */
@media (prefers-reduced-motion: reduce) {
    .floating-discuss-btn {
        transition: opacity 0.15s ease, visibility 0.15s ease;
        transform: scale(1) translateY(0) !important;
    }
}

/* High contrast mode for floating button */
@media (prefers-contrast: high) {
    .floating-discuss-btn {
        border: 2px solid #ffffff;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
    }

    .floating-discuss-badge {
        border-width: 3px;
    }
}

/* Print - hide floating button */
@media print {
    .floating-discuss-btn {
        display: none !important;
    }
}

/* ===== Floating Feedback Button ===== */
.floating-feedback-btn {
    position: fixed !important;
    bottom: 19rem !important;
    right: 1.875rem !important;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff !important;
    border: none;
    border-radius: 50%;
    box-shadow: 0 0.5rem 1.5rem rgba(16, 185, 129, 0.4);
    cursor: pointer;
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
    transition: all 0.3s ease;
}

.floating-feedback-btn:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 0.5rem 2rem rgba(16, 185, 129, 0.5);
    transform: scale(1.05) translateY(0);
}

.floating-feedback-btn:focus {
    outline: 3px solid #10b981;
    outline-offset: 3px;
}

.floating-feedback-btn:focus:not(:focus-visible) {
    outline: none;
}

.floating-feedback-btn:focus-visible {
    outline: 3px solid #10b981;
    outline-offset: 3px;
}

.floating-feedback-btn:active {
    transform: scale(0.95) translateY(0);
}

.floating-feedback-btn i {
    font-size: 1.5rem;
}

/* Responsive adjustments for floating feedback button */
@media (max-width: 767.98px) {
    .floating-feedback-btn {
        width: 3rem;
        height: 3rem;
        bottom: 17rem !important;
        right: 1rem !important;
    }

    .floating-feedback-btn i {
        font-size: 1.25rem;
    }
}

@media (max-width: 575.98px) {
    .floating-feedback-btn {
        width: 2.75rem;
        height: 2.75rem;
        bottom: 17rem !important;
        right: 1rem !important;
    }

    .floating-feedback-btn i {
        font-size: 1.125rem;
    }
}

/* Reduced motion for floating feedback button */
@media (prefers-reduced-motion: reduce) {
    .floating-feedback-btn {
        transition: opacity 0.15s ease, visibility 0.15s ease;
        transform: scale(1) translateY(0) !important;
    }
}

/* High contrast mode for floating feedback button */
@media (prefers-contrast: high) {
    .floating-feedback-btn {
        border: 2px solid #ffffff;
        box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
    }
}

/* Print - hide floating feedback button */
@media print {
    .floating-feedback-btn {
        display: none !important;
    }
}