/* 基础重置与全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #0ea5e9;
    --gradient-start: #0ea5e9;
    --gradient-end: #8b5cf6;
    --dark-bg: #0f172a;
    --darker-bg: #0a1120;
    --content-bg: rgba(15, 23, 42, 0.9);
    --text-light: #f1f5f9;
    --text-gray: #94a3b8;
    --warning: #ef4444;
    --success: #10b981;
    --border-radius: 15px;
    --box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

body {
    min-height: 100vh;
    background: var(--dark-bg);
    background: linear-gradient(135deg, var(--darker-bg) 0%, var(--dark-bg) 100%);
    color: var(--text-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    padding-bottom: 2rem;
    overflow-x: hidden;
}

/* 头部样式 */
header {
    background: rgba(15, 23, 42, 0.95);
    padding: 1.8rem 2.5rem;
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    box-shadow: 0 4px 20px rgba(14, 165, 233, 0.3);
    position: relative;
    overflow: hidden;
    margin-bottom: 2rem;
}

header::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(14, 165, 233, 0.1) 0%, transparent 70%);
    z-index: -1;
}

h1 {
    font-size: 2.8rem;
    margin-bottom: 1.2rem;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    color: transparent;
    display: inline-flex;
    align-items: center;
    gap: 1rem;
}

.tagline {
    color: var(--text-gray);
    max-width: 800px;
    margin: 0 auto;
    font-size: 1.2rem;
    background: rgba(30, 41, 59, 0.5);
    padding: 0.8rem 1.5rem;
    border-radius: 8px;
    display: inline-block;
    margin-bottom: 1rem;
}

.security-badge {
    margin-top: 1rem;
    color: #86efac;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.2rem;
    background: rgba(6, 78, 59, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(6, 78, 59, 0.6);
}

/* 主内容区 */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2.5rem;
}

/* 左侧目录 */
.directory {
    flex: 1;
    min-width: 320px;
    background: var(--content-bg);
    border-radius: var(--border-radius);
    padding: 1.8rem;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(56, 189, 248, 0.2);
    max-height: 90vh;
    overflow-y: auto;
    position: sticky;
    top: 1rem;
}

.directory h2 {
    font-size: 1.8rem;
    margin-bottom: 1.8rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.tree {
    list-style: none;
    padding-left: 0;
}

.tree li {
    margin: 1rem 0;
    position: relative;
}

.subject, .unit, .lesson {
    padding: 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    border: 1px solid rgba(100, 116, 139, 0.3);
    background: rgba(30, 41, 59, 0.7);
}

.subject {
    font-size: 1.25rem;
}

.unit {
    padding-left: 1.5rem;
    font-size: 1.15rem;
}

.lesson {
    padding: 0.8rem 1rem 0.8rem 3.5rem;
    font-size: 1.05rem;
}

.subject:hover, .unit:hover, .lesson:hover {
    background: rgba(56, 189, 248, 0.2);
    transform: translateX(5px);
}

.subject.active, .unit.active, .lesson.active {
    background: rgba(14, 165, 233, 0.3);
    border-left: 5px solid var(--primary-color);
    box-shadow: 0 5px 15px rgba(14, 165, 233, 0.2);
}

.node-toggle {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    color: var(--text-gray);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.node-toggle:hover {
    background: rgba(56, 189, 248, 0.2);
}

.node-toggle i {
    transition: transform 0.3s ease;
}

.node-toggle.expanded i {
    transform: rotate(90deg);
}

.subtree {
    list-style: none;
    padding-left: 2rem;
    margin-top: 0.5rem;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.5s ease;
}

.subtree.expanded {
    max-height: 2000px;
}

/* 视频播放器部分 */
.video-player-container {
    flex: 2;
    min-width: 65%;
}

.video-player {
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.7);
    position: relative;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.video-player video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    outline: none;
}

.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--primary-color);
    font-size: 1.5rem;
    text-align: center;
    z-index: 10;
    display: none;
    background: rgba(0, 0, 0, 0.7);
    padding: 2rem 3rem;
    border-radius: 10px;
}

.protocol-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    z-index: 10;
    display: none;
}

.protocol-indicator.https {
    background: rgba(139, 92, 246, 0.8);
}

.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--warning);
    background: rgba(0, 0, 0, 0.85);
    padding: 2rem;
    border-radius: 10px;
    text-align: center;
    z-index: 10;
    display: none;
    max-width: 90%;
    width: 400px;
}

.error-message i {
    font-size: 2.5rem;
    margin-bottom: 1.5rem;
    display: block;
}

/* 视频信息区 */
.video-info {
    background: var(--content-bg);
    border-radius: var(--border-radius);
    padding: 1.8rem;
    margin-top: 1.5rem;
    box-shadow: var(--box-shadow);
    border: 1px solid rgba(56, 189, 248, 0.2);
}

.video-info h2 {
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

.lesson-path {
    color: var(--text-gray);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
    background: rgba(30, 41, 59, 0.6);
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    display: block;
}

.video-info p {
    color: var(--text-light);
    font-size: 1.1rem;
    margin: 1.5rem 0;
    background: rgba(30, 41, 59, 0.5);
    padding: 1.2rem;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

/* 进度条 */
.progress-container {
    margin-top: 1.5rem;
    background: rgba(30, 41, 59, 0.6);
    padding: 1.2rem;
    border-radius: 10px;
}

.progress-label {
    margin-bottom: 1rem;
    color: var(--text-gray);
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
}

.progress-bar {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    border-radius: 5px;
    width: 35%;
    position: relative;
}

.progress::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.3));
}

/* 安全提示 */
.security-notice {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 1rem;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* 控制按钮 */
.controls {
    margin-top: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.btn {
    padding: 0.9rem 1.8rem;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(14, 165, 233, 0.4);
    font-size: 1.05rem;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 180px;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(14, 165, 233, 0.6);
}

.btn:active {
    transform: translateY(1px);
}

.no-download {
    background: linear-gradient(90deg, #ef4444, #f97316);
}

.btn.small {
    padding: 0.5rem 1rem;
    min-width: auto;
    font-size: 0.9rem;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-gray);
    margin-top: 3rem;
    border-top: 1px solid #334155;
    background: var(--content-bg);
    font-size: 1.1rem;
}

footer p {
    max-width: 800px;
    margin: 0 auto;
}

.copyright {
    color: var(--primary-color);
    margin-top: 1rem;
    font-weight: bold;
}

/* 动画 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* 响应式设计 */
@media (max-width: 1100px) {
    .container {
        flex-direction: column;
    }

    .directory {
        position: static;
        max-height: none;
    }

    h1 {
        font-size: 2.2rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1.5rem 1.2rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .tagline {
        font-size: 1.05rem;
    }

    .directory, .video-player-container {
        padding: 1.2rem;
    }

    .controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}