/* ============================================================
   eduPlayer — 视频课程学习平台
   设计方向：克制、聚焦、温暖
   签名元素：侧边栏课程进度指示线 + 聚焦态播放区
   ============================================================ */

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  color: #1e2130;
  background: #f0f2f5;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: #4f6ef6;
  text-decoration: none;
  transition: color 0.15s;
}
a:hover {
  color: #3d5bd9;
}

img {
  max-width: 100%;
  vertical-align: middle;
}

input,
button {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
}

/* ---- Focus visible ---- */
:focus-visible {
  outline: 2px solid #4f6ef6;
  outline-offset: 2px;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
  background: linear-gradient(135deg, #eef0f5 0%, #e3e8f0 50%, #eef0f5 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 8px 32px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* 卡片顶部色条 — 签名元素 */
.login-card::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #4f6ef6, #7c8cf8, #a0b0ff);
}

.login-card-header {
  padding: 2.5rem 2.5rem 1rem;
  text-align: center;
}

.login-card-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1e2130;
  letter-spacing: -0.01em;
}

.login-card-header p {
  margin-top: 0.4rem;
  font-size: 0.875rem;
  color: #9ca3af;
}

.login-card-body {
  padding: 0 2.5rem 2.5rem;
}

/* 表单行 */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #4b5563;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.form-group input[type="text"],
.form-group input[type="password"] {
  width: 100%;
  height: 44px;
  padding: 0 0.875rem;
  font-size: 0.9375rem;
  color: #1e2130;
  background: #f8f9fb;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: #4f6ef6;
  box-shadow: 0 0 0 3px rgba(79, 110, 246, 0.12);
  background: #fff;
}

/* 验证码行 */
.captcha-row {
  display: flex;
  gap: 0.75rem;
}

.captcha-row input {
  flex: 1;
}

.captcha-img-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.captcha-img-wrap img {
  height: 44px;
  width: auto;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
}

.captcha-refresh {
  font-size: 0.75rem;
  color: #4f6ef6;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.captcha-refresh:hover {
  color: #3d5bd9;
}

/* 登录按钮 */
.btn-login {
  width: 100%;
  height: 46px;
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: #4f6ef6;
  border: none;
  border-radius: 6px;
  letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s;
}
.btn-login:hover {
  background: #3d5bd9;
}
.btn-login:active {
  transform: scale(0.98);
}

/* ============================================================
   MAIN PAGE — Layout
   ============================================================ */

.main-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- Header ---- */
.main-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 1.5rem;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: #1e2130;
}

.header-logo .logo-dot {
  width: 28px;
  height: 28px;
  background: #4f6ef6;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 800;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-user {
  font-size: 0.875rem;
  color: #6b7280;
}

.btn-logout {
  padding: 0.4rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #6b7280;
  background: transparent;
  border: 1px solid #d1d5db;
  border-radius: 5px;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-logout:hover {
  color: #ef4444;
  border-color: #ef4444;
  background: #fef2f2;
}

/* 管理后台链接 */
.btn-tools {
  padding: 0.4rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: #4f6ef6;
  background: transparent;
  border: 1px solid #4f6ef6;
  border-radius: 5px;
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-tools:hover {
  color: #fff;
  background: #4f6ef6;
}

/* 汉堡菜单按钮（移动端） */
.menu-toggle {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #4b5563;
  padding: 0;
}

/* ---- Body: Sidebar + Content ---- */
.main-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 280px;
  flex-shrink: 0;
  background: #1b1f2e;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 1.25rem 1.25rem 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7394;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0 0.75rem 1rem;
  /* 美化滚动条 */
  scrollbar-width: thin;
  scrollbar-color: #2d3348 transparent;
}
.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: #2d3348;
  border-radius: 10px;
}

/* ---- 课程目录树 ---- */
.course-tree {
  list-style: none;
}

/* 分类标题 */
.tree-category {
  margin-top: 0.5rem;
}

.tree-category-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.625rem 0.625rem 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #a8b0c4;
  cursor: pointer;
  user-select: none;
  transition: color 0.15s;
  border-radius: 5px;
}
.tree-category-header:hover {
  color: #d0d6e4;
}

.tree-category-header .arrow {
  font-size: 0.625rem;
  transition: transform 0.2s;
  display: inline-block;
  color: #5b6380;
}
.tree-category.expanded > .tree-category-header .arrow {
  transform: rotate(90deg);
}

/* 课时列表 */
.tree-lessons {
  list-style: none;
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}
.tree-category.expanded .tree-lessons {
  max-height: 600px; /* 足够容纳所有课程 */
}

.tree-lesson {
  position: relative;
}

.tree-lesson a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem 0.5rem 1.5rem;
  font-size: 0.8125rem;
  color: #8890a8;
  text-decoration: none;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
  position: relative;
}

/* 课时左侧小指示线 */
.tree-lesson a::before {
  content: "";
  width: 3px;
  height: 0;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  background: #f0a040;
  border-radius: 0 2px 2px 0;
  transition: height 0.2s ease;
}

.tree-lesson a:hover {
  color: #c8d0e0;
  background: #252b3d;
}
.tree-lesson a:hover::before {
  height: 16px;
}

.tree-lesson.active a {
  color: #fff;
  background: #252b3d;
  font-weight: 600;
}
.tree-lesson.active a::before {
  height: 20px;
  background: #f0a040;
}

.tree-lesson .lesson-icon {
  font-size: 0.75rem;
  opacity: 0.6;
  flex-shrink: 0;
}
.tree-lesson.active .lesson-icon {
  opacity: 1;
  color: #f0a040;
}

/* ---- Content (视频播放区) ---- */
.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #f0f2f5;
}

.video-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.video-wrapper {
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.12);
}

/* DPlayer 容器填满 wrapper */
.dplayer-container {
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.dplayer-container .dplayer {
  width: 100%;
  height: 100%;
}

/* 禁止视频元素被拖拽 */
.dplayer-container video {
  pointer-events: auto; /* 保留控件点击，但阻止拖拽 */
  user-select: none;
  -webkit-user-select: none;
}

/* 视频为空时的占位 */
.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 4rem 2rem;
  color: #9ca3af;
}
.video-placeholder .placeholder-icon {
  font-size: 3.5rem;
  opacity: 0.4;
}
.video-placeholder p {
  font-size: 0.9375rem;
}

/* ── 文档下载区域 ── */
.doc-download-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem 2rem;
  text-align: center;
  background: #fafbfc;
  height: 100%;
}

.doc-download-area .doc-icon {
  font-size: 3.5rem;
  opacity: 0.5;
}

.doc-download-area .doc-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: #1e2130;
}

.doc-download-area .doc-meta {
  font-size: 0.8125rem;
  color: #9ca3af;
}

.btn-download {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.75rem;
  margin-top: 0.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #d97706;
  background: #fffbeb;
  border: 1.5px solid #fcd34d;
  border-radius: 6px;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn-download:hover {
  color: #b45309;
  background: #fef3c7;
  border-color: #f59e0b;
}
.btn-download:active {
  transform: scale(0.97);
}

.doc-hint {
  font-size: 0.75rem;
  color: #c0c7d0;
  margin-top: 0.25rem;
}

/* ── 侧边栏文档类型条目 ── */
.tree-lesson.doc-lesson .lesson-icon {
  color: #d97706;
  opacity: 0.8;
}
.tree-lesson.doc-lesson.active .lesson-icon {
  color: #f0a040;
  opacity: 1;
}

/* 当前播放课程标题 */
.video-info-bar {
  padding: 0 2rem 1.5rem;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}
.video-info-bar .current-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #4b5563;
}
.video-info-bar .current-title span {
  color: #4f6ef6;
}

/* ---- 侧边栏遮罩（移动端） ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 150;
}

/* ============================================================
   RESPONSIVE — 平板 (≤ 1024px)
   ============================================================ */

@media (max-width: 1024px) {
  .sidebar {
    width: 260px;
  }
  .video-container {
    padding: 1.25rem;
  }
}

/* ============================================================
   RESPONSIVE — 手机 (≤ 768px)
   ============================================================ */

@media (max-width: 768px) {
  /* ---- Login ---- */
  .login-card-header {
    padding: 2rem 1.5rem 0.75rem;
  }
  .login-card-body {
    padding: 0 1.5rem 2rem;
  }
  .login-card {
    border-radius: 6px;
  }

  /* ---- Main Layout ---- */
  .main-header {
    padding: 0 1rem;
  }
  .menu-toggle {
    display: flex;
  }

  /* 侧边栏 - 滑出模式 */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding-top: 56px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 2px 0 24px rgba(0, 0, 0, 0.25);
  }

  .sidebar-overlay.active {
    display: block;
  }

  /* 视频区 */
  .video-container {
    padding: 1rem;
  }
  .video-info-bar {
    padding: 0 1rem 1rem;
  }
  .video-wrapper {
    border-radius: 6px;
  }
  .doc-download-area {
    padding: 2rem 1.25rem;
  }
  .doc-download-area .doc-icon {
    font-size: 2.5rem;
  }
  .btn-download {
    padding: 0.5rem 1.25rem;
    font-size: 0.875rem;
  }
}

/* ============================================================
   RESPONSIVE — 小手机 (≤ 480px)
   ============================================================ */

@media (max-width: 480px) {
  .login-page {
    padding: 1rem;
  }
  .login-card-header h1 {
    font-size: 1.25rem;
  }
  .captcha-row {
    flex-direction: column;
    gap: 0.5rem;
  }
  .video-container {
    padding: 0.5rem;
  }
  .header-logo {
    font-size: 0.9375rem;
  }
}
