/* ===================================================================
   LESSON VIEWER STYLES
   Course navigation sidebar + main content layout
   =================================================================== */

/* ===== MAIN LAYOUT ===== */
.lesson-viewer {
    display: flex;
    min-height: 100vh;
    background: #f5f7fa;
    position: relative;
}

/* Sidebar: fixed narrow width, never grows */
.course-nav-sidebar {
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    flex-shrink: 0;
    overflow-x: hidden;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
}

/* Content: takes ALL remaining space */
.lesson-main {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

.lesson-viewer.sidebar-collapsed .course-nav-sidebar {
    width: 0;
    min-width: 0;
    max-width: 0;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Sidebar Toggle Button */
.sidebar-toggle-btn {
    position: fixed;
    top: 12px;
    left: 252px;
    z-index: 1050;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    background: #fff;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s;
    font-size: 1rem;
}

.sidebar-toggle-btn:hover {
    background: #f0f0f0;
    color: #0d6efd;
}

.sidebar-collapsed .sidebar-toggle-btn {
    left: 12px;
}

@media (max-width: 1200px) {
    .course-nav-sidebar {
        width: 220px;
        min-width: 220px;
        max-width: 220px;
    }
}

@media (max-width: 992px) {
    /* On mobile, sidebar is an overlay that slides in from the left */
    .course-nav-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px !important;
        min-width: 280px !important;
        max-width: 85vw !important;
        height: 100vh;
        z-index: 1040;
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
        transition: transform 0.3s ease, opacity 0.3s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }

    /* When sidebar is NOT collapsed on mobile, show it as overlay */
    .lesson-viewer:not(.sidebar-collapsed) .course-nav-sidebar {
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

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

/* Mobile overlay backdrop when sidebar is open */
@media (max-width: 992px) {
    .lesson-viewer:not(.sidebar-collapsed)::after {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 1035;
    }
}

/* ===== COURSE NAVIGATION SIDEBAR ===== */
.course-nav-sidebar {
    background: #fff;
    border-right: 1px solid #e0e0e0;
    height: 100vh;
    position: sticky;
    top: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1.25rem;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
}

.back-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #6c757d;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0;
    margin-bottom: 0.75rem;
}

.back-btn:hover {
    color: #0d6efd;
}

.course-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 0.75rem 0;
    line-height: 1.4;
}

.progress-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.progress-info .progress {
    background: #e9ecef;
    border-radius: 3px;
}

.progress-info small {
    font-size: 0.75rem;
}

/* ===== MODULES NAVIGATION ===== */
.modules-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.module-section {
    border-bottom: 1px solid #f0f0f0;
}

.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-color 0.15s;
}

.module-header:hover {
    background: #f8f9fa;
}

.module-icon {
    font-size: 1rem;
    color: #6c757d;
}

.module-title {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 600;
    color: #333;
}

.expand-icon {
    color: #adb5bd;
    font-size: 0.75rem;
}

/* ===== LESSONS LIST ===== */
.lessons-list {
    list-style: none;
    margin: 0;
    padding: 0 0 0.5rem 0;
    background: #fafafa;
}

.lesson-item {
    border-left: 3px solid transparent;
}

.lesson-item.current {
    background: #e7f1ff;
    border-left-color: #0d6efd;
}

.lesson-item.completed .lesson-link {
    color: #6c757d;
}

.lesson-link {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.625rem 1rem 0.625rem 1.5rem;
    color: #333;
    text-decoration: none;
    font-size: 0.8125rem;
    line-height: 1.4;
    transition: background-color 0.15s;
}

.lesson-link:hover {
    background: #f0f0f0;
    color: #0d6efd;
}

.lesson-status {
    flex-shrink: 0;
    font-size: 0.875rem;
    margin-top: 0.1rem;
}

.lesson-title-nav {
    flex: 1;
}

/* ===== SIDEBAR SIMULATION BUTTON ===== */
.sidebar-simulation {
    padding: 1rem;
    border-top: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
}

.btn-simulation-sidebar {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.btn-simulation-sidebar:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    color: #fff;
}

.btn-simulation-sidebar i {
    font-size: 1.25rem;
}

/* ===== MAIN CONTENT AREA ===== */
.lesson-main {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #0a0c10;
    overflow: hidden;
}

.lesson-header {
    padding: 0.3rem 1rem;
    background: #1a1a2e;
    color: #fff;
    border-bottom: 2px solid #FF6B00;
    flex-shrink: 0;
}

.lesson-header .header-content {
    max-width: 100%;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.lesson-header .lesson-title {
    font-size: 1.15rem;
    font-weight: 600;
    margin: 0;
    color: #fff;
}

.lesson-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    opacity: 0.9;
}

.completed-badge {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ===== LESSON CONTENT AREA ===== */
.lesson-content-area {
    flex: 1;
    padding: 1rem;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

.lesson-content-area .sanitized-content {
    max-width: 100%;
}

.empty-content {
    text-align: center;
    padding: 4rem 2rem;
}

/* ===== LESSON IFRAME (for HTML file lessons) ===== */
.lesson-iframe {
    width: 100%;
    height: 100%;
    flex: 1;
    border: none;
    border-radius: 0;
    background: #0a0c10;
}

/* Hide header and maximize space for iframe lessons */
.lesson-content-area:has(.lesson-iframe) {
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== SIMULATION SECTION ===== */
.simulation-section {
    padding: 0 2.5rem 2rem;
}

.simulation-card {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 12px;
    color: #fff;
    max-width: 900px;
}

.simulation-icon {
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
}

.simulation-info {
    flex: 1;
}

.simulation-info h5 {
    margin: 0 0 0.25rem 0;
    font-weight: 600;
}

.simulation-info p {
    margin: 0 0 0.75rem 0;
    opacity: 0.8;
    font-size: 0.875rem;
}

.simulation-badges {
    display: flex;
    gap: 0.5rem;
}

.btn-simulation {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.btn-simulation:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
    color: #fff;
}

/* ===== FOOTER NAVIGATION ===== */
.lesson-footer {
    padding: 0.5rem 1rem;
    background: #1a1a2e;
    border-top: 1px solid #2a2a4a;
    flex-shrink: 0;
}

.footer-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 900px;
}

.nav-left, .nav-center, .nav-right {
    display: flex;
    align-items: center;
}

.nav-left {
    min-width: 120px;
}

.nav-right {
    min-width: 120px;
    justify-content: flex-end;
}

/* ===== IMAGE LIGHTBOX ===== */
.image-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: zoom-out;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lightbox-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1.25rem;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 90vh;
    cursor: default;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ===== INTERACTIVE IMAGES IN CONTENT ===== */
.lesson-content-area img,
.sanitized-content img {
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}

.lesson-content-area img:hover,
.sanitized-content img:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Image in model viewer should not have hover effect */
model-viewer img,
.model-viewer-container img {
    cursor: default;
    transform: none !important;
    box-shadow: none !important;
}

/* ===== DARK THEME (DOGGING COURSES) ===== */
.lesson-viewer.dogging-dark-theme {
    background: #1a1a2e;
}

.dogging-dark-theme .course-nav-sidebar {
    background: #16213e;
    border-right-color: #2a2a4a;
}

.dogging-dark-theme .sidebar-header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-bottom-color: #2a2a4a;
}

.dogging-dark-theme .course-title,
.dogging-dark-theme .module-title {
    color: #e0e0e0;
}

.dogging-dark-theme .back-btn {
    color: #adb5bd;
}

.dogging-dark-theme .module-header:hover {
    background: rgba(255, 255, 255, 0.05);
}

.dogging-dark-theme .lessons-list {
    background: rgba(0, 0, 0, 0.2);
}

.dogging-dark-theme .lesson-item.current {
    background: rgba(245, 158, 11, 0.2);
    border-left-color: #f59e0b;
}

.dogging-dark-theme .lesson-link {
    color: #e0e0e0;
}

.dogging-dark-theme .lesson-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #f59e0b;
}

.dogging-dark-theme .module-section {
    border-bottom-color: #2a2a4a;
}

.dogging-dark-theme .lesson-main {
    background: #1a1a2e;
}

.dogging-dark-theme .lesson-header {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

.dogging-dark-theme .lesson-content-area {
    color: #e0e0e0;
}

.dogging-dark-theme .lesson-footer {
    background: #16213e;
    border-top-color: #2a2a4a;
}

.dogging-dark-theme .sidebar-simulation {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-top-color: #2a2a4a;
}

/* ===== RESPONSIVE ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .lesson-header {
        padding: 1.5rem;
    }

    .lesson-header .lesson-title {
        font-size: 1.5rem;
    }

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

    .simulation-section {
        padding: 0 1.5rem 1.5rem;
    }

    .simulation-card {
        flex-direction: column;
        text-align: center;
    }

    .simulation-badges {
        justify-content: center;
    }

    .lesson-footer {
        padding: 1rem 1.5rem;
    }

    .footer-nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-left, .nav-center, .nav-right {
        width: 100%;
        justify-content: center;
    }
}
