/* ==========================================
   华信在线学习平台 - 自定义样式
   移动端优先，响应式设计
   ========================================== */

/* ---------- 全局变量 ---------- */
:root {
  --primary: #4a6cf7;
  --primary-dark: #3651d5;
  --primary-light: #e8edfe;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --dark: #1e293b;
  --gray: #64748b;
  --gray-light: #94a3b8;
  --border: #e2e8f0;
  --bg: #f8fafc;
  --card-shadow: 0 2px 12px rgba(0,0,0,0.06);
  --card-hover-shadow: 0 8px 30px rgba(0,0,0,0.1);
  --radius: 12px;
}

/* ---------- 基础 ---------- */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: #334155;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ==========================================
   导航栏 - 移动端优先
   ========================================== */
.navbar-main {
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  padding: 0;
  min-height: 52px;
}
.navbar-main .container {
  padding-left: 12px;
  padding-right: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

/* ---- Logo ---- */
.navbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary) !important;
  padding: 8px 0;
  margin-right: auto;
  text-decoration: none;
  white-space: nowrap;
}
.navbar-brand:hover { color: var(--primary-dark) !important; }
.nav-logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #4a6cf7, #6c8cff);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  flex-shrink: 0;
}
.nav-logo-img {
  max-height: 30px;
  max-width: 100px;
  object-fit: contain;
}
.nav-brand-text {
  display: inline;
}

/* ---- 移动端右侧操作区 ---- */
.nav-mobile-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* 移动端头像按钮 */
.nav-mobile-avatar {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-mobile-avatar .nav-avatar {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border: 2px solid var(--border);
}

/* 头像占位圆（无头像时） */
.nav-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  border: 2px solid var(--border);
}
.nav-avatar-fallback-lg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: var(--primary);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}
.nav-avatar-lg {
  width: 44px;
  height: 44px;
  object-fit: cover;
  flex-shrink: 0;
}

/* 汉堡按钮 */
.navbar-toggler {
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  flex-shrink: 0;
}
.navbar-toggler:focus {
  box-shadow: 0 0 0 2px rgba(74,108,247,0.25);
}
.navbar-toggler-icon {
  width: 20px;
  height: 20px;
  background-size: 20px;
}

/* ---- 折叠菜单 ---- */
.navbar-collapse {
  flex-basis: 100%;
  border-top: 1px solid var(--border);
  padding: 8px 0;
}

/* 移动端用户信息条 */
.nav-mobile-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  margin-bottom: 4px;
  border-bottom: 1px solid #f1f5f9;
}
.nav-mobile-user-text {
  display: flex;
  flex-direction: column;
}
.nav-mobile-user-text strong {
  font-size: 0.95rem;
  color: var(--dark);
  line-height: 1.3;
}
.nav-mobile-user-text small {
  font-size: 0.75rem;
  color: var(--gray-light);
  line-height: 1.3;
}

/* 导航链接 - 移动端 */
.nav-link {
  font-weight: 500;
  color: var(--dark) !important;
  padding: 10px 4px !important;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover {
  color: var(--primary) !important;
  background: var(--primary-light);
}
.nav-link.active {
  color: var(--primary) !important;
  font-weight: 600;
}
.nav-link i { opacity: 0.7; }

/* 桌面端用户头像 */
.nav-avatar {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border: 2px solid var(--border);
}

/* 桌面端下拉 */
.dropdown-menu {
  border: none;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  padding: 6px;
  font-size: 0.9rem;
}
.dropdown-item {
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 500;
  transition: background 0.15s;
}
.dropdown-item:hover { background: var(--primary-light); }
.dropdown-divider { margin: 4px 0; }

/* ---- 桌面端（≥992px） ---- */
@media (min-width: 992px) {
  .navbar-main {
    padding: 4px 0;
    min-height: 56px;
  }
  .navbar-main .container {
    padding-left: 16px;
    padding-right: 16px;
  }
  .navbar-brand {
    font-size: 1.2rem;
    margin-right: 24px;
  }
  .nav-logo-icon {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }
  .nav-mobile-actions {
    display: none; /* 桌面端隐藏移动端头像 */
  }
  .nav-mobile-user-info {
    display: none; /* 桌面端隐藏用户信息条 */
  }
  .navbar-collapse {
    display: flex !important;
    flex-basis: auto;
    border-top: none;
    padding: 0;
    flex-grow: 1;
  }
  .nav-link {
    padding: 8px 14px !important;
    font-size: 0.88rem;
    border-radius: 8px;
  }
  .nav-link:hover {
    background: transparent;
    color: var(--primary) !important;
  }
  .nav-link.active {
    background: var(--primary-light);
  }
  .navbar-nav {
    flex-direction: row;
  }
}

/* 大屏 */
@media (min-width: 1200px) {
  .nav-brand-text { font-size: 1.15rem; }
  .nav-link { font-size: 0.9rem; padding: 8px 16px !important; }
}

.btn-primary {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  font-weight: 500;
  border-radius: 8px;
}

.btn-primary:hover {
  background-color: var(--primary-dark) !important;
  border-color: var(--primary-dark) !important;
}

.btn-outline-primary {
  color: var(--primary) !important;
  border-color: var(--primary) !important;
  border-radius: 8px;
}

.btn-outline-primary:hover {
  background-color: var(--primary) !important;
  color: #fff !important;
}

/* ---------- 首页 Hero ---------- */
.hero-section {
  background: linear-gradient(135deg, #4a6cf7 0%, #6c8cff 50%, #8db5ff 100%);
  padding: 60px 0;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.hero-section::after {
  content: '';
  position: absolute;
  bottom: -30%;
  left: -5%;
  width: 300px;
  height: 300px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.hero-section h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 16px;
}

.hero-section p {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 500px;
}

.hero-stats { display: flex; gap: 40px; margin-top: 30px; }

.hero-stat { text-align: center; }

.hero-stat .num {
  font-size: 2rem;
  font-weight: 800;
  display: block;
}

.hero-stat .label {
  font-size: 0.85rem;
  opacity: 0.8;
}

/* ---------- 卡片 ---------- */
.card {
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition: transform 0.3s, box-shadow 0.3s;
  background: #fff;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--card-hover-shadow);
}

.card-img-top {
  height: 180px;
  object-fit: cover;
}

/* 课程卡片 */
.course-card .card-img-top {
  background: linear-gradient(135deg, #667eea, #764ba2);
  height: 180px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 3rem;
}
.course-card .card-img-top img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.course-card:hover .card-img-top img {
  transform: scale(1.05);
}

.course-card .card-body { padding: 1.25rem; }

.course-card .card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-meta {
  font-size: 0.8rem;
  color: var(--gray-light);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.course-price {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--danger);
}

.course-price .free {
  color: var(--success);
}

.course-price .original {
  font-size: 0.8rem;
  color: var(--gray-light);
  text-decoration: line-through;
  font-weight: 400;
  margin-left: 6px;
}

/* ---------- 分类标签 ---------- */
.category-tag {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 500;
}

/* ---------- 登录/注册页面 ---------- */
.auth-container {
  min-height: calc(100vh - 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 100%);
}

.auth-box {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.08);
  padding: 40px;
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-header h3 {
  font-weight: 700;
  color: var(--dark);
}

.auth-header p { color: var(--gray-light); font-size: 0.9rem; }

.form-control {
  border: 1.5px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74,108,247,0.1);
}

.form-label { font-weight: 500; color: var(--dark); font-size: 0.9rem; }

/* 验证码输入组 */
.captcha-group { display: flex; gap: 10px; }

.captcha-group .form-control { flex: 1; }

.captcha-img {
  height: 44px;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: opacity 0.2s;
}

.captcha-img:hover { opacity: 0.8; }

/* 短信验证码 */
.sms-group { display: flex; gap: 10px; }

.sms-group .form-control { flex: 1; }

.btn-sms {
  min-width: 120px;
  font-size: 0.85rem;
  border-radius: 10px;
  white-space: nowrap;
}

/* 登录切换标签 */
.auth-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.auth-tab {
  flex: 1;
  text-align: center;
  padding: 10px;
  cursor: pointer;
  font-weight: 600;
  color: var(--gray-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ---------- 仪表盘 ---------- */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--card-shadow);
}

.stat-icon {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #fff;
}

.stat-icon.blue { background: linear-gradient(135deg, #4a6cf7, #6c8cff); }
.stat-icon.green { background: linear-gradient(135deg, #10b981, #34d399); }
.stat-icon.orange { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #a78bfa); }

.stat-info .num { font-size: 1.5rem; font-weight: 700; }
.stat-info .label { font-size: 0.82rem; color: var(--gray-light); }

/* ---------- 课程详情 ---------- */
.course-detail-header {
  background: linear-gradient(135deg, #1e293b, #334155);
  color: #fff;
  padding: 40px 0;
}

.course-detail-header h2 {
  font-weight: 700;
  margin-bottom: 10px;
}

.course-detail-info {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  font-size: 0.9rem;
  opacity: 0.85;
}

.lesson-list a {
  color: inherit;
  text-decoration: none;
}

.lesson-list a:hover {
  text-decoration: none;
}

.lesson-list .lesson-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s;
  cursor: pointer;
}

.lesson-item:hover { background: var(--bg); }

.lesson-item .lesson-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  margin-right: 14px;
  flex-shrink: 0;
}

.lesson-item .lesson-info { flex: 1; }

.lesson-item .lesson-title {
  font-weight: 500;
  font-size: 0.95rem;
}

.lesson-item .lesson-meta {
  font-size: 0.78rem;
  color: var(--gray-light);
}

.lesson-item .lesson-badge { flex-shrink: 0; }

/* ==========================================
   学习页面 - 移动端优先播放器
   ========================================== */

/* 学习页面 body */
.learn-page-body {
  background: #000;
  overflow-x: hidden;
}

/* 顶部迷你导航栏（移动端黑底白字浮在视频上，PC 端白底黑字独立导航） */
.learn-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 52px;
  background: rgba(0,0,0,0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.learn-topbar-left,
.learn-topbar-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* 返回按钮（下拉触发器） */
.learn-back-dropdown {
  position: relative;
}

.learn-back-btn {
  height: 36px;
  padding: 0 10px 0 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  border: none;
  background: rgba(255,255,255,0.1);
  border-radius: 18px;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.learn-back-btn:hover { background: rgba(255,255,255,0.2); color: #fff; }
.learn-back-btn:focus { outline: none; }

.learn-back-text {
  font-size: 0.88rem;
}

.learn-back-caret {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-left: 2px;
  transition: transform 0.2s;
}
.learn-back-btn[aria-expanded="true"] .learn-back-caret {
  transform: rotate(180deg);
}

/* 下拉菜单 */
.learn-back-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 180px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
  list-style: none;
  margin: 0;
  padding: 6px 0;
  z-index: 110;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity 0.18s, transform 0.18s, visibility 0.18s;
  border: 1px solid rgba(0,0,0,0.06);
}
.learn-back-menu.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.learn-back-menu li {
  list-style: none;
  margin: 0;
  padding: 0;
}
.learn-back-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  color: #333;
  font-size: 0.88rem;
  text-decoration: none;
  transition: background 0.15s;
}
.learn-back-menu a:hover {
  background: #f3f6fb;
  color: #1e88e5;
}
.learn-back-menu a i {
  width: 18px;
  text-align: center;
  font-size: 0.92rem;
}
.learn-back-divider {
  height: 1px;
  background: #eef0f3;
  margin: 4px 0;
  padding: 0;
}

.learn-topbar-title {
  flex: 1;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 52px;
  min-width: 0;
  padding: 0 4px;
}

.learn-toc-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.05rem;
  background: none;
  border: none;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
  transition: background 0.2s;
}
.learn-toc-btn:hover { background: rgba(255,255,255,0.15); }

/* 主布局容器 */
.learn-wrapper {
  padding-top: 52px;
  min-height: 100vh;
  background: #000;
}

/* 播放器区域 */
.learn-player-section {
  background: #000;
  position: relative;
}

/* 无视频空状态 */
.player-empty {
  width: 100%;
  aspect-ratio: 16/9;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #1a1a2e;
}
.player-empty i { font-size: 4rem; opacity: 0.4; margin-bottom: 12px; }
.player-empty p { font-size: 1.1rem; margin-bottom: 4px; }
.player-empty small { font-size: 0.8rem; opacity: 0.5; }

/* ===== 播放器容器 ===== */
.player-container {
  position: relative;
  width: 100%;
  background: #000;
  overflow: hidden;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  /* 桌面端保持 16:9 */
  aspect-ratio: 16/9;
}

/* 移动端：视频占满屏幕宽度，高度自动 */
@media (max-width: 768px) {
  .player-container {
    aspect-ratio: auto;
  }
  .player-video {
    width: 100%;
    height: auto;
    max-height: 56vw;
  }
}

/* 水印 */
.player-watermark {
  position: absolute;
  top: 12px;
  right: 16px;
  z-index: 5;
  color: rgba(255,255,255,0.25);
  font-size: 11px;
  pointer-events: none;
  user-select: none;
  letter-spacing: 0.5px;
}

/* 视频元素 */
.player-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* 隐藏原生控制栏 */
.player-video::-webkit-media-controls { display: none !important; }
.player-video::-webkit-media-controls-enclosure { display: none !important; }
.player-video::-webkit-media-controls-panel { display: none !important; }

/* 中央大播放按钮 */
.player-big-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  width: 64px;
  height: 64px;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(4px);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, background 0.2s;
}
.player-big-play i {
  color: #fff;
  font-size: 1.6rem;
  margin-left: 3px;
}
.player-big-play:hover {
  background: rgba(255,255,255,0.3);
  transform: translate(-50%, -50%) scale(1.08);
}
.player-big-play:active {
  transform: translate(-50%, -50%) scale(0.95);
}
.player-big-play.hidden {
  opacity: 0;
  pointer-events: none;
}

/* 加载动画 */
.player-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 视频错误提示 */
.player-error {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.85);
}
.player-error-content {
  text-align: center;
  color: #fff;
  padding: 24px;
}
.player-error-content i {
  font-size: 3rem;
  color: #ff4444;
  margin-bottom: 12px;
  display: block;
}
.player-error-content p {
  font-size: 0.95rem;
  opacity: 0.9;
  margin-bottom: 8px;
}

/* ===== 自定义控制栏 ===== */
.player-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 48px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* 桌面端 hover 显示，移动端常驻 */
@media (hover: hover) and (pointer: fine) {
  .player-container:hover .player-controls,
  .player-container.fullscreen .player-controls {
    opacity: 1;
  }
}

@media (hover: none) and (pointer: coarse) {
  .player-controls { opacity: 1; }
}

.player-controls.visible { opacity: 1; }

/* 控制按钮 */
.player-ctrl-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: #fff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.player-ctrl-btn:hover { background: rgba(255,255,255,0.2); }
.player-ctrl-btn:active { background: rgba(255,255,255,0.35); }

/* 时间显示 */
.player-time-current,
.player-time-total {
  color: #fff;
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  min-width: 38px;
  text-align: center;
  line-height: 1;
}
.player-time-total { opacity: 0.7; }

/* 进度条容器 */
.player-progress {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  cursor: pointer;
  position: relative;
  min-width: 40px;
  transition: height 0.15s;
}
.player-progress:hover {
  height: 6px;
}
.player-progress:active {
  height: 6px;
}

/* 缓冲进度 */
.player-progress-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255,255,255,0.35);
  border-radius: 2px;
  width: 0%;
}

/* 播放进度 */
.player-progress-filled {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: #ff0000;
  border-radius: 2px;
  width: 0%;
  z-index: 1;
}

/* 进度拖拽手柄 */
.player-progress-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: #ff0000;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  left: 0%;
  z-index: 2;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.player-progress:hover .player-progress-thumb,
.player-progress:active .player-progress-thumb {
  opacity: 1;
}

/* ===== 全屏模式 ===== */
.player-container.fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 9999;
  aspect-ratio: auto !important;
}
.player-container.fullscreen .player-video {
  object-fit: contain;
  width: 100%;
  height: 100%;
}
.player-container.fullscreen .player-controls {
  height: 56px;
  padding: 0 20px;
  bottom: env(safe-area-inset-bottom);
}
.player-container.fullscreen .player-big-play {
  width: 80px;
  height: 80px;
}
.player-container.fullscreen .player-big-play i { font-size: 2rem; }

/* ---- CSS 伪全屏（降级方案：requestFullscreen 不支持时使用）---- */
.player-container.pseudo-fs {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  z-index: 99999 !important;
  aspect-ratio: auto !important;
  max-width: none !important;
  border-radius: 0 !important;
}
.player-container.pseudo-fs .player-video {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  max-height: none !important;
}

/* ===== 内容区域 ===== */
.learn-content-section {
  background: #fff;
  border-radius: 16px 16px 0 0;
  margin-top: -8px;
  position: relative;
  z-index: 5;
  padding: 20px 16px;
  min-height: 40vh;
}

/* 当前课时头部 */
.lesson-header-bar {
  margin-bottom: 16px;
}
.lesson-current-label {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
}
.lesson-current-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 12px;
  line-height: 1.4;
}
.lesson-current-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* 课时描述卡片 */
.lesson-desc-card {
  background: #f8fafc;
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--gray);
  line-height: 1.7;
  border-left: 3px solid var(--primary);
}

/* 课时正文 */
.lesson-content-body {
  font-size: 0.95rem;
  line-height: 1.8;
  color: #334155;
  margin-bottom: 20px;
}
.lesson-content-body img {
  max-width: 100%;
  border-radius: 8px;
}

/* 课时导航 */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.lesson-nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #f8fafc;
  border-radius: 12px;
  color: var(--dark);
  text-decoration: none;
  font-size: 0.85rem;
  flex: 1;
  max-width: 48%;
  transition: background 0.2s;
}
.lesson-nav-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.lesson-nav-btn small {
  display: block;
  font-size: 0.7rem;
  color: var(--gray-light);
  margin-bottom: 2px;
}
.lesson-nav-btn strong {
  display: block;
  font-size: 0.85rem;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.lesson-nav-btn.next {
  text-align: right;
  justify-content: flex-end;
}

/* ===== 课时侧边栏（右侧滑出） ===== */
.lesson-sidebar {
  position: fixed;
  top: 0;
  right: -100%;
  width: 85%;
  max-width: 380px;
  height: 100vh;
  height: 100dvh;
  background: #fff;
  z-index: 200;
  box-shadow: -4px 0 20px rgba(0,0,0,0.15);
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}
.lesson-sidebar.open {
  right: 0;
}

.sidebar-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--dark);
}
.sidebar-count {
  font-size: 0.8rem;
  color: var(--gray-light);
  margin-left: 8px;
}
.sidebar-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  border: none;
  background: #f1f5f9;
  border-radius: 50%;
  color: var(--gray);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.sidebar-close:hover { background: #e2e8f0; }

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.sidebar-lesson-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
  color: var(--dark);
  text-decoration: none;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.15s;
}
.sidebar-lesson-item:hover { background: #f8fafc; }
.sidebar-lesson-item.active { background: var(--primary-light); }

.sidebar-lesson-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f1f5f9;
  color: var(--gray);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.sidebar-lesson-num.done {
  background: #d1fae5;
  color: #10b981;
}

.sidebar-lesson-info { flex: 1; min-width: 0; }
.sidebar-lesson-title {
  font-size: 0.88rem;
  font-weight: 500;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-lesson-meta {
  font-size: 0.72rem;
  color: var(--gray-light);
  margin-top: 2px;
}

/* ===== 桌面端布局（>768px） ===== */
@media (min-width: 769px) {
  .learn-page-body {
    background: #f4f6f9;
  }

  /* PC 端顶部栏：白底黑字 + 阴影，独立于视频之上 */
  .learn-topbar {
    display: flex;
    background: #ffffff;
    border-bottom: 1px solid #e4e7ed;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .learn-back-btn {
    background: #f0f3f7;
    color: #2c3e50;
  }
  .learn-back-btn:hover { background: #e4e9f0; color: #1e88e5; }

  .learn-topbar-title {
    color: #2c3e50;
    font-size: 0.98rem;
    font-weight: 600;
  }

  .learn-toc-btn {
    color: #2c3e50;
    background: transparent;
  }
  .learn-toc-btn:hover { background: #f0f3f7; }

  /* PC 端：主容器不要 padding-top 顶位，sidebar 自带固定定位 */
  .learn-wrapper {
    display: block;
    padding-top: 52px;
    min-height: calc(100vh - 52px);
    background: #f4f6f9;
  }

  .learn-player-section {
    flex: 1;
    background: #f4f6f9;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
  }

  .player-container {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    max-width: 100%;
  }

  .player-empty {
    border-radius: 12px;
  }

  .learn-content-section {
    margin-top: 0;
    border-radius: 12px;
    padding: 20px 24px;
    max-height: none;
    overflow-y: auto;
  }

  /* 桌面端侧边栏：固定在右侧常驻显示 */
  .lesson-sidebar {
    position: fixed;
    top: 52px;
    right: 0;
    bottom: 0;
    width: 320px;
    height: auto;
    max-height: calc(100vh - 52px);
    max-width: none;
    box-shadow: -2px 0 8px rgba(0,0,0,0.04);
    z-index: 50;
    border-left: 1px solid #e4e7ed;
    background: #fff;
    transition: none;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
  }
  .lesson-sidebar.open {
    right: 0;
  }
  /* 课时列表区可滚动 */
  .lesson-sidebar .sidebar-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }
  .sidebar-overlay { display: none !important; }
  .sidebar-close { display: none; }
  .learn-toc-btn { display: none; }

  /* PC 端：右侧 sidebar 占据空间，player-section 自动留出宽度 */
  .learn-player-section {
    margin-right: 320px;
  }
  .learn-content-section {
    margin-right: 320px;
  }
}

/* ===== 章节手风琴样式 ===== */
.sidebar-chapter {
  border-bottom: 1px solid #f0f2f5;
}
.sidebar-chapter-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #f8fafc;
  border: none;
  cursor: pointer;
  text-align: left;
  font-size: 0.88rem;
  font-weight: 600;
  color: #2c3e50;
  transition: background 0.15s;
}
.sidebar-chapter-header:hover { background: #eef2f7; }
.sidebar-chapter-caret {
  font-size: 0.7rem;
  color: #94a3b8;
  transition: transform 0.2s;
  flex-shrink: 0;
  width: 12px;
  text-align: center;
}
.sidebar-chapter.open .sidebar-chapter-caret {
  transform: rotate(90deg);
}
.sidebar-chapter-title {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-chapter-count {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 500;
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 10px;
  flex-shrink: 0;
}
.sidebar-chapter.open .sidebar-chapter-count {
  background: #dbeafe;
  color: #1e88e5;
}
.sidebar-chapter-body {
  display: none;
  background: #fff;
}
.sidebar-chapter.open .sidebar-chapter-body {
  display: block;
}

/* ---------- 响应式优化 ---------- */
@media (max-width: 768px) {
  .hero-section { padding: 40px 0; }
  .hero-section h1 { font-size: 1.7rem; }
  .hero-stats { gap: 20px; }
  .hero-stat .num { font-size: 1.4rem; }

  .auth-box { padding: 24px; margin: 10px; }

  .dashboard-stats { grid-template-columns: repeat(2, 1fr); }

  .course-detail-header { padding: 24px 0; }

  .learn-wrapper { flex-direction: column; }
  /* 移动端：移除 PC 端为侧栏预留的右边距 */
  .learn-player-section { margin-right: 0 !important; }
  .learn-content-section { margin-right: 0 !important; }
  .lesson-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 85%;
    max-width: 380px;
    height: 100dvh;
    max-height: 100dvh;
    z-index: 200;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-direction: column;
  }
  .lesson-sidebar.open { right: 0; }
  .lesson-sidebar .sidebar-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
  }

  .card-img-top { height: 140px; }
  .course-card .card-img-top { height: 140px; }

  .course-detail-info { gap: 10px; }
}

@media (max-width: 480px) {
  .hero-section h1 { font-size: 1.4rem; }
  .hero-stats { gap: 12px; flex-wrap: wrap; }
  .dashboard-stats { grid-template-columns: 1fr; }
  .auth-tab { font-size: 0.9rem; padding: 8px; }
  .btn-sms { min-width: 100px; font-size: 0.8rem; }

  /* 管理后台移动端优化 */
  .table-responsive { font-size: 0.78rem; }
  .table-responsive th, .table-responsive td { padding: 6px 8px; }
  .btn-xs { padding: 2px 6px !important; font-size: 0.68rem !important; }
  /* 课程卡片移动端优化 */
  .course-card .card-img-top { height: 120px !important; }
  .course-card .card-body { padding: 0.75rem; }
  .course-card .card-title { font-size: 0.9rem; -webkit-line-clamp: 2; }
  .course-meta { font-size: 0.72rem; gap: 6px; }
  .category-tag { font-size: 0.68rem; padding: 2px 8px; }

  /* 学习中心移动端优化 */
  .stat-card { padding: 12px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 1.1rem; border-radius: 8px; }
  .stat-info .num { font-size: 1.15rem; }
  .stat-info .label { font-size: 0.72rem; }

  /* 弹窗移动端优化 */
  .modal-dialog { margin: 8px; max-width: calc(100% - 16px); }
  .modal-body { padding: 12px; }
  .modal-header, .modal-footer { padding: 10px 12px; }

  /* 筛选栏移动端优化 */
  .form-label.small { font-size: 0.75rem; }
  .form-control-sm, .form-select-sm { font-size: 0.82rem; padding: 5px 8px; }

  /* 学习页面移动端微调 */
  .player-controls { height: 44px; padding: 0 8px; gap: 6px; }
  .player-ctrl-btn { width: 32px; height: 32px; font-size: 0.9rem; }
  .player-time-current,
  .player-time-total { font-size: 0.68rem; min-width: 32px; }
  .player-big-play { width: 52px; height: 52px; }
  .player-big-play i { font-size: 1.3rem; }
  .learn-content-section { padding: 14px 12px; border-radius: 12px 12px 0 0; }
  .lesson-current-title { font-size: 1.05rem; }
  .lesson-nav-btn { padding: 8px 10px; }
  .lesson-nav-btn strong { font-size: 0.78rem; }
  .player-watermark { font-size: 9px; top: 8px; right: 10px; }
}

/* ---------- 加载动画 ---------- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 工具类 ---------- */
.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--dark);
}

.badge-level {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* Toast 消息 */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
}

/* 课程搜索 */
.search-box {
  position: relative;
}

.search-box input {
  padding-left: 40px;
  border-radius: 50px;
  border: 2px solid var(--border);
  height: 48px;
  font-size: 0.95rem;
}

.search-box i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-light);
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state i {
  font-size: 4rem;
  color: var(--gray-light);
  margin-bottom: 16px;
}

.empty-state p {
  color: var(--gray-light);
  font-size: 1rem;
}

/* ---------- 管理后台增强 ---------- */
.btn-xs {
  padding: 3px 8px !important;
  font-size: 0.72rem !important;
  border-radius: 5px !important;
  line-height: 1.4 !important;
}
