/* Library Layout Styles */
.library-page {
    padding: 30px 0 60px;
    background: linear-gradient(135deg, #f5f7fb 0%, #eef2ff 100%);
    min-height: 80vh;
}

.library-container {
    display: flex;
    min-height: 760px;
    background-color: #fff;
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.12);
    margin: 0 auto;
    max-width: 1200px;
    overflow: hidden;
}

/* Sidebar Styles */
.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    padding: 40px 10px;
    border-right: 1px solid rgba(255,255,255,0.08);
    box-shadow: inset -8px 0 20px rgba(15,23,42,0.35);
}

.sidebar-header {
    margin-bottom: 24px;
    padding: 0 10px;
}

.back-link {
    display: inline-block;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 12px;
    transition: color 0.2s ease;
}

.back-link:hover {
    color: rgba(255, 255, 255, 0.95);
}

.sidebar-title {
    margin: 0;
    font-size: 1.2rem;
    color: #fff;
    font-weight: 600;
    line-height: 1.3;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 10px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    position: relative;
}

.sidebar-nav-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
}

.sidebar-nav-item.active {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #fff;
    box-shadow: 0 4px 12px rgba(217, 119, 6, 0.4);
}

.sidebar-nav-item.active:hover {
    background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
}

.nav-icon {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    stroke-width: 2;
}

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

.sidebar-nav-item .lesson-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar-nav-item.active .lesson-number {
    background: rgba(255, 255, 255, 0.25);
}

/* Main Content Styles */
.main-content {
    flex-grow: 1;
    padding: 40px 48px;
    background: #f8fafc;
}

.card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 12px 30px rgba(15,23,42,0.08);
    padding: 24px;
    margin-bottom: 24px;
}

.lesson-header h1 {
    margin: 8px 0 12px;
    font-size: 2rem;
    color: #0f172a;
}

.lesson-breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 0.9rem;
    color: #64748b;
}

.lesson-breadcrumb a {
    color: #475569;
    text-decoration: none;
    font-weight: 500;
}

.lesson-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.lesson-chip {
    background: rgba(59,130,246,0.12);
    color: #1d4ed8;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Library Welcome Page */
.library-welcome h1 {
    margin-bottom: 10px;
    color: #333;
}

.library-welcome p {
    color: #666;
    margin-bottom: 30px;
}

.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.course-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}

.course-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.course-card a {
    color: inherit;
    text-decoration: none;
}

.course-image, .course-image-placeholder {
    height: 160px;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.course-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.course-info {
    padding: 15px;
}

.course-info h3 {
    margin: 0 0 10px 0;
    color: #333;
}

.course-info p {
    color: #666;
    font-size: 0.9rem;
    margin: 0;
    line-height: 1.4;
}

/* Course Page */
.course-header {
    margin-bottom: 30px;
}

.course-header h1 {
    margin-bottom: 10px;
    color: #333;
}

.course-description {
    color: #666;
    line-height: 1.6;
}

.lesson-list {
    margin-bottom: 30px;
}

.lesson-list h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 1.3rem;
}

.lesson-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
}

.lesson-list li a {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
    color: #333;
    text-decoration: none;
    transition: background-color 0.2s;
}

.lesson-list li:last-child a {
    border-bottom: none;
}

.lesson-list li a:hover {
    background-color: #f5f5f5;
}

.lesson-list li.active a {
    background-color: #f0f7ff;
    color: #0055a4;
    font-weight: 500;
}

.lesson-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: #eee;
    border-radius: 50%;
    margin-right: 12px;
    font-size: 0.85rem;
}

.lesson-preview {
    background-color: #f9f9f9;
    border-radius: 6px;
    padding: 20px;
    margin-top: 20px;
}

.lesson-preview h3 {
    margin-top: 0;
    color: #333;
}

.button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    margin-top: 15px;
    transition: background-color 0.2s;
}

.button.primary {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
}

.button.primary:hover {
    opacity: 0.9;
}

.button.secondary {
    background-color: transparent;
    color: #1d4ed8;
    border: 1px solid rgba(37,99,235,0.4);
}

.button.secondary:hover {
    background-color: rgba(37,99,235,0.08);
}

/* Lesson Page */
.lesson-container {
    display: flex;
}

.lesson-navigation {
    width: 240px;
    border-right: 1px solid #e0e0e0;
    padding-right: 20px;
    margin-right: 30px;
}

.lesson-navigation h2 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
    font-size: 1.3rem;
}

.lesson-content {
    flex-grow: 1;
}

.lesson-content h1 {
    margin-top: 0;
    color: #333;
}

.video-card {
    padding: 0;
    max-width: 888px; /* 500px height * 16/9 = 888.89px */
    margin-left: auto;
    margin-right: auto;
}

.video-frame {
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(15,23,42,0.08);
    background: #000;
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    max-height: 500px;
}

.video-frame video,
.video-frame .video-js {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.video-js .vjs-control-bar {
    background: rgba(15,23,42,0.85);
    font-size: 1rem;
}

.video-js .vjs-play-progress,
.video-js .vjs-volume-level {
    background: linear-gradient(90deg, #38bdf8 0%, #6366f1 100%);
}

.video-js .vjs-slider {
    background: rgba(255,255,255,0.3);
}

.lesson-text {
    line-height: 1.8;
    color: #1f2937;
    font-size: 1.05rem;
}

/* Markdown Content Styling */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    line-height: 1.3;
    color: #0f172a;
}

.markdown-content h1 { font-size: 2rem; }
.markdown-content h2 { font-size: 1.75rem; }
.markdown-content h3 { font-size: 1.5rem; }
.markdown-content h4 { font-size: 1.25rem; }
.markdown-content h5 { font-size: 1.1rem; }
.markdown-content h6 { font-size: 1rem; }

.markdown-content p {
    margin-bottom: 1.25em;
}

.markdown-content a {
    color: #2563eb;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.markdown-content a:hover {
    color: #1d4ed8;
}

.markdown-content ul,
.markdown-content ol {
    margin-bottom: 1.25em;
    padding-left: 2em;
}

.markdown-content li {
    margin-bottom: 0.5em;
}

.markdown-content code {
    background: #f1f5f9;
    padding: 0.2em 0.4em;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 0.9em;
    color: #dc2626;
}

.markdown-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 1.25em;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 1.25em;
}

.markdown-content pre code {
    background: transparent;
    padding: 0;
    color: inherit;
    font-size: 0.95em;
}

.markdown-content blockquote {
    border-left: 4px solid #d97706;
    padding-left: 1em;
    margin-left: 0;
    margin-bottom: 1.25em;
    color: #64748b;
    font-style: italic;
}

.markdown-content hr {
    border: none;
    border-top: 2px solid #e2e8f0;
    margin: 2em 0;
}

.markdown-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 1em 0;
}

.markdown-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.25em;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #e2e8f0;
    padding: 0.75em;
    text-align: left;
}

.markdown-content th {
    background: #f8fafc;
    font-weight: 600;
}

/* Lesson Links */
.lesson-links {
    margin-top: 30px;
}

.lesson-links h3 {
    margin-top: 0;
    margin-bottom: 16px;
    color: #0f172a;
    font-size: 1.3rem;
}

.links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.links-list li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    text-decoration: none;
    color: #2563eb;
    transition: all 0.2s ease;
}

.links-list li a:hover {
    background: #eff6ff;
    border-color: #2563eb;
    transform: translateX(4px);
}

.links-list li a svg {
    flex-shrink: 0;
    color: #64748b;
}

.links-list li a:hover svg {
    color: #2563eb;
}

.links-list li a span {
    font-weight: 500;
}

.lesson-navigation-buttons {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.button {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    margin-top: 15px;
    transition: background-color 0.2s;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .library-page {
        background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    }
    
    .library-container {
        background-color: #1e293b;
        box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
    }
    
    .main-content {
        background: #0f172a;
    }
    
    .card {
        background: #1e293b;
        box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.08);
    }
    
    .lesson-header h1 {
        color: #f1f5f9;
    }
    
    .lesson-breadcrumb {
        color: #94a3b8;
    }
    
    .lesson-breadcrumb a {
        color: #cbd5e1;
    }
    
    .lesson-chip {
        background: rgba(59, 130, 246, 0.2);
        color: #93c5fd;
    }
    
    .library-welcome h1 {
        color: #f1f5f9;
    }
    
    .library-welcome p {
        color: #cbd5e1;
    }
    
    .course-card {
        background: #1e293b;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .course-card:hover {
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    }
    
    .course-image-placeholder {
        background-color: #334155;
    }
    
    .course-info h3 {
        color: #f1f5f9;
    }
    
    .course-info p {
        color: #cbd5e1;
    }
    
    .course-header h1 {
        color: #f1f5f9;
    }
    
    .course-description {
        color: #cbd5e1;
    }
    
    .lesson-list h2 {
        color: #f1f5f9;
    }
    
    .lesson-list ul {
        border: 1px solid rgba(255, 255, 255, 0.1);
        background: #1e293b;
    }
    
    .lesson-list li a {
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        color: #e2e8f0;
    }
    
    .lesson-list li a:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
    
    .lesson-list li.active a {
        background-color: rgba(217, 119, 6, 0.15);
        color: #d97706;
    }
    
    .lesson-number {
        background-color: #334155;
        color: #e2e8f0;
    }
    
    .lesson-preview {
        background-color: #1e293b;
        border: 1px solid rgba(255, 255, 255, 0.08);
    }
    
    .lesson-preview h3 {
        color: #f1f5f9;
    }
    
    .button.secondary {
        color: #60a5fa;
        border: 1px solid rgba(96, 165, 250, 0.4);
    }
    
    .button.secondary:hover {
        background-color: rgba(96, 165, 250, 0.15);
    }
    
    .lesson-navigation {
        border-right: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .lesson-navigation h2 {
        color: #f1f5f9;
    }
    
    .lesson-content h1 {
        color: #f1f5f9;
    }
    
    .video-frame {
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .lesson-text {
        color: #e2e8f0;
    }
    
    .markdown-content h1,
    .markdown-content h2,
    .markdown-content h3,
    .markdown-content h4,
    .markdown-content h5,
    .markdown-content h6 {
        color: #f1f5f9;
    }
    
    .markdown-content a {
        color: #60a5fa;
    }
    
    .markdown-content a:hover {
        color: #93c5fd;
    }
    
    .markdown-content code {
        background: #334155;
        color: #fca5a5;
    }
    
    .markdown-content pre {
        background: #0f172a;
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .markdown-content blockquote {
        border-left-color: #d97706;
        color: #94a3b8;
    }
    
    .markdown-content hr {
        border-top-color: rgba(255, 255, 255, 0.1);
    }
    
    .markdown-content th,
    .markdown-content td {
        border-color: rgba(255, 255, 255, 0.1);
    }
    
    .markdown-content th {
        background: #1e293b;
    }
    
    .lesson-links h3 {
        color: #f1f5f9;
    }
    
    .links-list li a {
        background: #1e293b;
        border-color: rgba(255, 255, 255, 0.1);
        color: #60a5fa;
    }
    
    .links-list li a:hover {
        background: #334155;
        border-color: #60a5fa;
    }
    
    .links-list li a svg {
        color: #94a3b8;
    }
    
    .links-list li a:hover svg {
        color: #60a5fa;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .library-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        border-radius: 6px 6px 0 0;
    }
    
    .lesson-container {
        flex-direction: column;
    }
    
    .lesson-navigation {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        padding-right: 0;
        padding-bottom: 20px;
        margin-right: 0;
        margin-bottom: 20px;
    }
}

@media (max-width: 768px) and (prefers-color-scheme: dark) {
    .sidebar {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .lesson-navigation {
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }
}
