* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: radial-gradient(1200px 600px at 20% 10%, #7aa2ff 0%, #667eea 30%, #5a55aa 65%, #3b2e5a 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

header {
    background: linear-gradient(145deg, #ffffff, #f6f7ff);
    padding: 30px;
    border-radius: 18px;
    box-shadow: 0 30px 60px rgba(60,50,120,0.25), 0 6px 14px rgba(60,50,120,0.15);
    margin-bottom: 30px;
    position: relative;
}

header:after {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: -8px;
    height: 10px;
    border-radius: 12px;
    background: linear-gradient(90deg, rgba(102,126,234,0.7), rgba(118,75,162,0.7));
    filter: blur(6px);
    opacity: 0.8;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.home-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #f1f5f9;
    color: #1f2937;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.95em;
}

.home-link:hover {
    background: #e2e8f0;
}

.header-menu .menu-button {
    padding: 8px 14px;
    background: #f8fafc;
    color: #1f2937;
    border: 1px solid #e2e8f0;
    font-size: 0.95em;
}

h1 {
    color: #ffffff;
    font-size: 2.8em;
    margin-bottom: 10px;
    text-shadow: 0 8px 20px rgba(0,0,0,0.25), 0 2px 6px rgba(102,126,234,0.5);
}

.subtitle {
    color: #666;
    font-size: 1.1em;
}

.stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    background: rgba(255,255,255,0.9);
    padding: 12px 25px;
    border-radius: 12px;
    box-shadow: 0 18px 35px rgba(0,0,0,0.18);
    margin: 20px 0;
    flex-wrap: wrap;
    backdrop-filter: blur(6px);
}

.stats span {
    color: #64748b;
    font-size: 0.95em;
}

.stats strong {
    color: #667eea;
    font-size: 1.2em;
    margin-right: 4px;
}

.controls {
    background: linear-gradient(145deg, #ffffff, #f6f7ff);
    padding: 25px;
    border-radius: 14px;
    box-shadow: 0 22px 40px rgba(0,0,0,0.18);
    margin-bottom: 30px;
}

.search-bar {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-bar input[type="text"] {
    flex: 1;
    min-width: 300px;
}

input[type="text"] {
    padding: 12px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Menu-style dropdowns */
.menu { position: relative; }
.menu-button {
    padding: 12px 16px;
    background: linear-gradient(180deg, #fdfefe, #eef2ff);
    color: #1f2937;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0,0,0,0.12);
}
.menu-button:hover { background: #eef2f7; }
.menu-dropdown {
    position: absolute;
    top: 110%;
    left: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    min-width: 220px;
    display: none;
    z-index: 10;
}
.menu.open .menu-dropdown { display: block; }
.menu-dropdown .menu-item {
    padding: 10px 12px;
    cursor: pointer;
}
.menu-dropdown .menu-item:hover { background: #f9fafb; }

button {
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s;
}

button:hover {
    background: #764ba2;
    transform: translateY(-2px);
}

button:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
}

/* Vertical grouped list */
.category-section { 
    margin-bottom: 25px; 
    position: relative;
}
.category-header {
    background: linear-gradient(145deg, #ffffff, #f8f9ff);
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 16px;
    color: #1f2741;
    margin-bottom: 12px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 10px 24px rgba(0,0,0,0.12);
}
.courses-list { display: flex; flex-direction: column; gap: 20px; }
.category-row-wrapper {
    position: relative;
}
.category-row {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    perspective: 1200px;
}
.category-row::-webkit-scrollbar { height: 10px; }
.category-row::-webkit-scrollbar-thumb { background: #c7d2fe; border-radius: 6px; }
.category-row::-webkit-scrollbar-track { background: #eef2ff; }
.category-row .course-card { min-width: 340px; scroll-snap-align: start; }

.nav-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: radial-gradient(circle at 30% 30%, #ffffff 0%, #f3f6ff 70%);
    border: 2px solid #d5dcff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 12px 26px rgba(0,0,0,0.18), 0 4px 8px rgba(102,126,234,0.25);
    transition: all 0.2s;
}
.nav-arrow:hover {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: transparent;
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 18px 40px rgba(102,126,234,0.45);
}
.nav-arrow.left { left: -15px; }
.nav-arrow.right { right: -15px; }
.nav-arrow:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.nav-arrow:disabled:hover {
    background: rgba(255,255,255,0.95);
    color: inherit;
    border-color: #e2e8f0;
}

.course-card {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 22px 50px rgba(0,0,0,0.22), 0 8px 18px rgba(102,126,234,0.12);
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.35s ease, filter 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(102,126,234,0.18);
    position: relative;
    transform: perspective(900px) rotateX(0deg) rotateY(0deg) translateZ(0);
}

.course-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
    transform: scaleX(0);
    transition: transform 0.3s ease;
}

.course-card:hover::before {
    transform: scaleX(1);
}

.course-card:hover {
    transform: perspective(900px) rotateX(2.5deg) rotateY(-2.5deg) translateZ(6px) scale(1.02);
    box-shadow: 0 30px 70px rgba(0,0,0,0.28), 0 18px 30px rgba(102,126,234,0.28);
    border-color: rgba(102,126,234,0.45);
    filter: drop-shadow(0 0 8px rgba(118,75,162,0.25));
}

.course-thumbnail {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #667eea;
}

.course-content {
    padding: 20px;
}

.course-title {
    font-size: 1.3em;
    color: #2d3748;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-author {
    color: #718096;
    font-size: 0.9em;
    margin-bottom: 15px;
}

.course-tags {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.tag {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.85em;
    font-weight: 500;
}

.tag-category {
    background: #e6f2ff;
    color: #0066cc;
}

.tag-language {
    background: #fff0e6;
    color: #cc6600;
}

.course-meta {
    display: flex;
    justify-content: space-between;
    color: #718096;
    font-size: 0.9em;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.page-info {
    color: #666;
    font-weight: 500;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    max-width: 1400px;
    margin: 30px auto;
    border-radius: 20px;
    position: relative;
    box-shadow: 0 25px 60px rgba(0,0,0,0.3),
                0 10px 20px rgba(102,126,234,0.2);
    transform: translateY(0);
    animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    padding: 25px 30px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 20px 20px 0 0;
    color: white;
    box-shadow: 0 4px 15px rgba(102,126,234,0.3);
}

.modal-header h2 {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.modal-header p {
    color: rgba(255,255,255,0.9);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    color: rgba(255,255,255,0.9);
    cursor: pointer;
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.3);
    padding: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.close-btn:hover {
    background: rgba(255,255,255,0.25);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.modal-body {
    padding: 0;
    background: #fafbfc;
}

.split-layout {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 0;
    height: 70vh;
    align-items: stretch;
}

.video-section {
    padding: 30px;
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border-radius: 0 0 0 20px;
    height: 100%;
}

.lessons-section {
    background: linear-gradient(145deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 0 0 20px 0;
    display: flex;
    flex-direction: column;
    box-shadow: inset 5px 0 15px rgba(0,0,0,0.1);
    height: 100%;
    overflow: hidden; /* prevent exceeding video height */
}

.lessons-header {
    margin-bottom: 20px;
}

.lessons-header h3 {
    color: white;
    font-size: 1.3em;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
    margin: 0;
}

.lessons-scroll {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    height: calc(100% - 48px); /* match video height minus header inside lessons */
}

.lessons-scroll::-webkit-scrollbar {
    width: 8px;
}

.lessons-scroll::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
}

.lessons-scroll::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 10px;
}

.lessons-scroll::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.5);
}

.video-container {
    position: relative;
    height: 100%;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 30px 70px rgba(0,0,0,0.28), 0 12px 24px rgba(102,126,234,0.18);
    transform: translateZ(0);
    transition: all 0.3s ease;
}

.video-container:hover {
    box-shadow: 0 40px 90px rgba(0,0,0,0.35), 0 20px 40px rgba(102,126,234,0.28);
    transform: translateY(-4px) translateZ(8px);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 15px;
}

.lesson-item {
    padding: 16px;
    background: linear-gradient(145deg, rgba(255,255,255,0.18), rgba(255,255,255,0.12));
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 14px;
    margin-bottom: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    color: white;
    box-shadow: 0 10px 24px rgba(0,0,0,0.2);
    transform: translateX(0);
}

.lesson-item:hover {
    background: rgba(255,255,255,0.28);
    border-color: rgba(255,255,255,0.5);
    transform: translateX(6px) scale(1.03);
    box-shadow: 0 18px 35px rgba(0,0,0,0.25);
}

.lesson-item.active {
    background: linear-gradient(135deg, rgba(255,255,255,0.3), rgba(255,255,255,0.2));
    border: 2px solid rgba(255,255,255,0.65);
    box-shadow: 0 22px 50px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.35);
    transform: translateX(10px) scale(1.04);
}

.lesson-title {
    font-weight: 500;
    flex: 1;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.lesson-duration {
    color: rgba(255,255,255,0.8);
    font-size: 0.85em;
    margin-left: 15px;
    background: rgba(255,255,255,0.1);
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
}

.lesson-item.active .lesson-duration {
    background: rgba(255,255,255,0.25);
    color: white;
}

.open-youtube-btn {
    background: linear-gradient(145deg, #ff2828, #c90e0e);
    color: white;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8em;
    margin-left: 10px;
    display: none;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    font-weight: 600;
    transition: all 0.3s ease;
}

.lesson-item.active .open-youtube-btn {
    display: inline-block;
}

.open-youtube-btn:hover {
    background: linear-gradient(135deg, #ff3333, #ff0000);
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(255,0,0,0.3);
}

.video-error {
    background: #fff5f5;
    border: 2px solid #fc8181;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    margin-bottom: 20px;
}

.video-error h4 {
    color: #c53030;
    margin-bottom: 10px;
}

.video-error p {
    color: #744210;
    margin-bottom: 15px;
}

.video-error button {
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

.loading {
    text-align: center;
    padding: 60px;
    color: white;
    font-size: 1.2em;
}

.no-results {
    background: white;
    padding: 60px;
    text-align: center;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.no-results h3 {
    color: #667eea;
    margin-bottom: 10px;
}

@media (max-width: 1024px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
    
    .video-section {
        border-radius: 0;
    }
    
    .lessons-section {
        border-radius: 0 0 20px 20px;
        min-height: 400px;
    }
}

@media (max-width: 768px) {
    .search-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-bar input[type="text"] {
        min-width: 100%;
    }

    h1 {
        font-size: 1.8em;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .stats {
        gap: 15px;
        font-size: 0.9em;
    }

    .nav-arrow {
        width: 35px;
        height: 35px;
    }
    
    .modal-content {
        margin: 10px;
        max-width: 100%;
    }
}
