:root {
    --sidebar-width: 320px;
    --sidebar-bg: #0f172a;
    --sidebar-text: #94a3b8;
    --sidebar-active: #ffffff;
    --sidebar-hover: #1e293b;
    --primary-color: #3b82f6;
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --card-bg: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg-color); color: var(--text-color); overflow: hidden; }

.app-container { display: flex; height: 100vh; }

/* Sidebar */
.sidebar { width: var(--sidebar-width); background-color: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; height: 100%; z-index: 100; transition: transform 0.3s ease; box-shadow: 2px 0 10px rgba(0,0,0,0.1); }
.sidebar-header { padding: 25px 20px; border-bottom: 1px solid rgba(255,255,255,0.05); display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; padding: 2px; }
.sidebar-header h2 { color: #fff; font-size: 1.25rem; font-weight: 600; line-height: 1.2; }
.sidebar-content { flex: 1; overflow-y: auto; padding: 20px 0; }
.sidebar-content::-webkit-scrollbar { width: 6px; }
.sidebar-content::-webkit-scrollbar-thumb { background: #334155; border-radius: 10px; }

/* Tree */
ul.tree { list-style: none; margin: 0; padding: 0; }
ul.tree ul { display: none; padding-left: 20px; }
ul.tree ul.active { display: block; animation: slideDown 0.3s ease-out forwards; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-5px); } to { opacity: 1; transform: translateY(0); } }

.tree-node { padding: 12px 25px; cursor: pointer; display: flex; align-items: center; transition: all 0.2s ease; user-select: none; border-left: 3px solid transparent; }
.tree-node:hover { background-color: var(--sidebar-hover); color: var(--sidebar-active); }
.tree-node i.icon-left { width: 20px; text-align: center; margin-right: 12px; font-size: 1.1rem; }
.tree-node i.icon-toggle { width: 15px; margin-left: auto; font-size: 0.8rem; transition: transform 0.3s ease; }
.tree-node.expanded i.icon-toggle { transform: rotate(90deg); }
.tree-node.active-category { font-weight: 600; color: #fff; background-color: var(--sidebar-hover); border-left-color: var(--primary-color); }

/* Main */
.main-content { flex: 1; display: flex; flex-direction: column; height: 100%; overflow: hidden; }
.top-nav { background: #fff; padding: 18px 30px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); display: flex; align-items: center; z-index: 10; }
#mobile-menu-toggle { display: none; background: none; border: none; font-size: 1.25rem; cursor: pointer; margin-right: 20px; color: var(--text-color); }
.breadcrumb { font-weight: 500; color: #64748b; font-size: 0.95rem; }

.content-area { flex: 1; overflow-y: auto; padding: 30px; position: relative; scroll-behavior: smooth; }

/* Carousel */
.carousel-container { position: relative; width: 100%; max-width: 1200px; margin: 0 auto 40px auto; border-radius: 16px; overflow: hidden; box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
.carousel-track { display: flex; transition: transform 0.5s ease-in-out; height: 350px; }
.carousel-slide { min-width: 100%; height: 100%; }
.carousel-slide img { width: 100%; height: 100%; object-fit: cover; }
.carousel-btn { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,0.8); border: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 1.2rem; display: flex; align-items: center; justify-content: center; transition: all 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.1); z-index: 2; }
.carousel-btn:hover { background: #fff; transform: translateY(-50%) scale(1.1); color: var(--primary-color); }
.prev-btn { left: 15px; }
.next-btn { right: 15px; }
.carousel-dots { position: absolute; bottom: 15px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; z-index: 2; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: rgba(255,255,255,0.5); cursor: pointer; transition: all 0.3s; }
.dot.active { background: #fff; transform: scale(1.2); }

/* Library Grid */
.library-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; max-width: 1200px; margin: 0 auto 40px auto; }
.library-card { background: var(--card-bg); border-radius: 12px; padding: 25px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); cursor: pointer; transition: all 0.3s ease; display: flex; flex-direction: column; justify-content: center; border: 1px solid #e2e8f0; }
.library-card:hover { transform: translateY(-5px); box-shadow: 0 12px 24px rgba(0,0,0,0.1); border-color: var(--primary-color); }
.library-card-icon { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 15px; }
.library-card-title { font-size: 1.3rem; font-weight: 600; color: #1e293b; margin-bottom: 8px; }
.library-card-count { color: #64748b; font-size: 0.95rem; display: flex; align-items: center; gap: 6px; }

/* Odd number of items: last child spans full width */
.library-grid > .library-card:nth-child(odd):last-child { grid-column: 1 / -1; }

/* Video Grid */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 25px; max-width: 1400px; margin: 0 auto; }
.video-card { background: var(--card-bg); border-radius: 12px; overflow: hidden; box-shadow: 0 4px 6px rgba(0,0,0,0.05); cursor: pointer; transition: all 0.3s ease; position: relative; }
.video-card:hover { transform: translateY(-6px); box-shadow: 0 12px 24px rgba(0,0,0,0.1); }

.thumb-wrapper { position: relative; width: 100%; height: 180px; }
.video-thumb { width: 100%; height: 100%; object-fit: cover; }
.play-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s; }
.play-overlay i { font-size: 4rem; color: rgba(255,255,255,0.9); text-shadow: 0 4px 10px rgba(0,0,0,0.5); transform: scale(0.8); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.video-card:hover .play-overlay { opacity: 1; }
.video-card:hover .play-overlay i { transform: scale(1); }

.video-card-body { padding: 20px; }
.video-card-title { font-size: 1.1rem; font-weight: 600; margin-bottom: 8px; color: #1e293b; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.video-card-date { font-size: 0.85rem; color: #94a3b8; display: flex; align-items: center; gap: 5px; }

/* Player */
.btn-back { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: none; padding: 10px 20px; border-radius: 30px; cursor: pointer; margin-bottom: 25px; font-weight: 600; font-size: 0.95rem; color: #475569; box-shadow: 0 2px 5px rgba(0,0,0,0.05); transition: all 0.2s; }
.btn-back:hover { color: var(--primary-color); transform: translateX(-3px); box-shadow: 0 4px 8px rgba(0,0,0,0.1); }

.player-card { max-width: 1000px; margin: 0 auto; cursor: default; }
.player-card:hover { transform: none; box-shadow: 0 4px 6px rgba(0,0,0,0.05); }

.video-wrapper { width: 100%; background: #000; position: relative; padding-top: 56.25%; border-radius: 12px 12px 0 0; overflow: hidden; }
#player { position: absolute; top: 0; left: 0; width: 100%; height: 100%; outline: none; }
.video-info { padding: 30px; }
.video-info h1 { margin-bottom: 12px; font-size: 1.7rem; color: #0f172a; font-weight: 700; }
.video-info p { line-height: 1.6; color: #475569; white-space: pre-wrap; font-size: 1rem; }

/* States */
.loader-msg { text-align: center; padding: 60px 20px; color: #64748b; font-size: 1.1rem; }
.loader-msg i { color: var(--primary-color); margin-bottom: 15px; }
.empty-msg { text-align: center; grid-column: 1/-1; padding: 60px 20px; color: #94a3b8; }
.empty-msg i { font-size: 3.5rem; color: #cbd5e1; margin-bottom: 20px; display: block; }
.empty-msg p { font-size: 1.1rem; }

/* Transitions & Skeletons */
.library-card, .video-card { transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s; }
.library-card:active, .video-card:active { transform: scale(0.98); }

.skeleton-box {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.new-badge {
    position: absolute; top: -10px; right: -10px;
    background: #ef4444; color: #fff; padding: 4px 10px;
    border-radius: 12px; font-size: 0.70rem; font-weight: 600;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.3);
    animation: pulse 2s infinite; pointer-events: none; z-index: 10;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.library-card, .video-thumb-container { position: relative; } /* needed for badge positioning */

/* Responsive */
@media (max-width: 1024px) {
    .carousel-track { height: 280px; }
}
@media (max-width: 768px) {
    .sidebar { position: fixed; left: -100%; }
    .sidebar.open { left: 0; box-shadow: 10px 0 25px rgba(0,0,0,0.3); }
    #mobile-menu-toggle { display: block; }
    .content-area { padding: 20px; }
    .carousel-track { height: 200px; }
    .video-info h1 { font-size: 1.4rem; }
    .library-grid { grid-template-columns: 1fr; }
    .library-grid > .library-card:nth-child(odd):last-child { grid-column: auto; }
}
