/* ===================================================================
 * viewer.css — 课程观看页样式
 * 桌面端参考腾讯云课程页排版（视频区 + 章节侧栏 + Tabs）。
 * 断点：1024 / 768 / 480，移动端用 single-column，并把章节变为底部抽屉。
 * =================================================================== */

:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #1f2329;
  --ink-soft: #5b6470;
  --ink-faint: #8a94a3;
  --brand: #1e6cff;
  --brand-soft: #e8f0ff;
  --border: #e5e9f0;
  --shadow: 0 6px 18px rgba(20, 30, 50, 0.06);
  --radius: 10px;
}

* { box-sizing: border-box; }
/* 确保 hidden 属性生效，防止 display:flex/grid 等覆盖 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif; -webkit-font-smoothing: antialiased; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ----------------------- 顶部导航 ----------------------- */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--panel); border-bottom: 1px solid var(--border); }
.topbar__inner { max-width: 1280px; margin: 0 auto; height: 56px; padding: 0 20px; display: flex; align-items: center; gap: 28px; position: relative; }
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; height: 32px; }
.brand__logo { width: 32px; height: 32px; border-radius: 50%; object-fit: contain; flex-shrink: 0; }
.brand__name { display: inline-flex; align-items: center; height: 32px; line-height: 32px; }
.topnav { display: inline-flex; align-items: center; gap: 22px; font-size: 16px; color: var(--ink-soft); height: 32px; }
.topnav a { display: inline-flex; align-items: center; height: 32px; transition: color .15s; }
.topnav a:hover { color: var(--brand); }
.admin-link { position: absolute; right: 20px; top: 50%; transform: translateY(-50%); font-size: 13px; padding: 7px 12px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); }
.user-center-btn {
  position: absolute; right: 20px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: #1e6cff;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none; transition: all .15s;
}
.user-center-btn:hover { background: #1859d6; transform: translateY(-50%) scale(1.08); }

/* ----------------------- 页面容器 ----------------------- */
.page { max-width: 1280px; margin: 0 auto; padding: 18px 20px 60px; }

/* ----------------------- 视频主区 ----------------------- */
.player-section { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.player-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; padding: 22px; }
@media (max-width: 1024px) { .player-grid { grid-template-columns: 1fr; } .page { padding: 14px 12px 80px; } }

.player-main { min-width: 0; }

.player-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #0b1220; border-radius: var(--radius); overflow: hidden; }
.player-frame video { width: 100%; height: 100%; display: block; object-fit: contain; background: #000; }
.player-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #cdd5e0; text-align: center; padding: 24px; }
.player-empty.is-hidden { display: none; }
.player-empty__icon { font-size: 48px; margin-bottom: 14px; opacity: .85; }
.player-empty__title { font-size: 16px; font-weight: 600; color: #fff; }
.player-empty__hint { margin-top: 6px; font-size: 13px; max-width: 320px; }

.course-meta { padding: 16px 0 8px; }
.course-meta__title { font-size: 22px; font-weight: 700; margin: 0 0 10px; line-height: 1.35; }
.course-meta__row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 14px; color: var(--ink-soft); }
.course-meta__dot { color: var(--ink-faint); }
.course-meta__rating { color: #ff8a00; font-weight: 600; }

/* ----------------------- Tabs ----------------------- */
.tabs { display: flex; gap: 0; margin-top: 8px; border-bottom: 1px solid var(--border); }
.tab { padding: 14px 26px; font-size: 15px; color: var(--ink-soft); position: relative; }
.tab.is-active { color: var(--brand); font-weight: 600; }
.tab.is-active::after { content: ''; position: absolute; left: 20px; right: 20px; bottom: -1px; height: 2px; background: var(--brand); border-radius: 2px; }
.tab-panel { display: none; padding: 16px 4px 8px; }
.tab-panel.is-active { display: block; }
.panel__h2 { font-size: 16px; font-weight: 700; margin: 18px 0 10px; }
.panel__lead { color: var(--ink-soft); margin: 0 0 12px; line-height: 1.65; }
.panel__rich { color: var(--ink); white-space: pre-wrap; line-height: 1.75; }

/* ----------------------- 图片海报画廊 ----------------------- */
.course-gallery-wrap {
  margin: 22px 0 6px;
  padding: 18px 20px 20px;
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.course-gallery-wrap .panel__h2 { margin: 0 0 14px; }
.course-gallery-wrap .course-gallery { margin: 0; }
.course-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; margin: 18px 0 4px; }
.course-gallery__item { margin: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #f3f5f8; cursor: zoom-in; transition: box-shadow .15s, transform .15s; }
.course-gallery__item:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.course-gallery__item img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }

.lightbox { position: fixed; inset: 0; background: rgba(10,16,28,.85); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
@media (max-width: 480px) { .course-gallery { grid-template-columns: repeat(2, 1fr); gap: 10px; } }

/* ----------------------- 机构卡片 ----------------------- */
.institution { display: flex; gap: 14px; background: #f7f9fc; border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; align-items: center; }
.institution__avatar { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #1e6cff, #5aa1ff); color: #fff; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.institution__name { font-weight: 700; }
.institution__desc { color: var(--ink-soft); font-size: 14px; margin-top: 4px; }

/* ----------------------- 评论 ----------------------- */
.review-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.review { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.review__avatar { width: 40px; height: 40px; border-radius: 50%; background: #eef2f7; display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--ink-soft); flex-shrink: 0; }
.review__head { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 14px; color: var(--ink); }
.review__star { color: #ff8a00; }
.review__body p { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }

/* ----------------------- 相关推荐 ----------------------- */
.recommend-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.recommend-card { background: #f7f9fc; border-radius: var(--radius); padding: 14px; }
.recommend-card__title { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.recommend-card__meta { font-size: 12px; color: var(--ink-faint); }

/* ----------------------- 章节侧栏 ----------------------- */
.chapter-pane { background: #fafbfd; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; height: fit-content; position: sticky; top: 76px; }
.chapter-pane__head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 12px; }
.chapter-pane__title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.chapter-pane__index { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.chapter-pane__toggle { color: var(--ink-soft); padding: 4px; border-radius: 6px; }
.chapter-pane__toggle:hover { background: #eef2f7; }

.chapter-list { list-style: none; margin: 0; padding: 0; max-height: 540px; overflow-y: auto; }
.chapter-list::-webkit-scrollbar { width: 6px; }
.chapter-list::-webkit-scrollbar-thumb { background: #d6dde6; border-radius: 3px; }
.chapter-item { display: flex; align-items: center; gap: 10px; padding: 12px 10px; border-radius: 8px; cursor: pointer; transition: background .15s; }
.chapter-item:hover { background: #eef3fb; }
.chapter-item.is-active { background: var(--brand-soft); color: var(--brand); }
.chapter-item.is-active .chapter-item__title { font-weight: 600; }
.chapter-item__num { font-weight: 600; color: var(--ink-soft); min-width: 30px; }
.chapter-item.is-active .chapter-item__num { color: var(--brand); }
.chapter-item__title { flex: 1; font-size: 14px; line-height: 1.4; }
.chapter-item__duration { font-size: 12px; color: var(--ink-faint); margin-left: auto; }
.chapter-item__dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #cbd2dc; flex-shrink: 0; }
.chapter-item.is-active .chapter-item__dot { border-color: var(--brand); background: var(--brand); box-shadow: 0 0 0 3px rgba(30,108,255,.18); }

/* ----------------------- 底部相关课程 ----------------------- */
.related-section { margin-top: 32px; background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }
.related-section__h2 { font-size: 18px; margin: 0 0 16px; }
.related-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.related-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: #fff; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.related-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.related-card__cover { width: 100%; aspect-ratio: 16/9; background: linear-gradient(135deg, #1e6cff, #74a8ff); position: relative; }
.related-card__cover img { width: 100%; height: 100%; object-fit: cover; }
.related-card__cover-fallback { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.85); font-size: 14px; font-weight: 600; padding: 16px; text-align: center; }
.related-card__body { padding: 12px 14px 14px; }
.related-card__title { font-size: 14px; font-weight: 600; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.related-card__meta { margin-top: 8px; font-size: 12px; color: var(--ink-faint); display: flex; gap: 8px; }

/* 页脚样式由主站 styles.css 提供 */

/* ----------------------- 移动端 ----------------------- */
.mobile-chapters-btn { display: none; }
@media (max-width: 1024px) {
  .topnav { display: none; }
  .mobile-chapters-btn {
    display: flex; align-items: center; gap: 6px; position: fixed; right: 16px; bottom: 24px;
    padding: 12px 18px; border-radius: 999px; background: var(--brand); color: #fff;
    box-shadow: 0 8px 24px rgba(30,108,255,.35); z-index: 25; font-size: 14px;
  }
  .chapter-pane { display: none; }
}

.mobile-chapters-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; }
.mobile-chapters-drawer { position: fixed; left: 0; right: 0; bottom: 0; max-height: 80vh; background: #fff; border-radius: 16px 16px 0 0; z-index: 41; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .25s; }
/* 修复 hidden 被 display:flex 覆盖 */
.mobile-chapters-drawer[hidden] { display: none; }
.mobile-chapters-drawer:not([hidden]) { transform: translateY(0); }
.mobile-chapters-drawer__head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.mobile-chapters-drawer__head button { font-size: 18px; padding: 4px 8px; border-radius: 6px; }
.chapter-list--mobile { max-height: 70vh; padding: 8px 12px 18px; }

@media (max-width: 768px) {
  .course-meta__title { font-size: 18px; }
  .tabs { overflow-x: auto; }
  .tab { padding: 12px 18px; font-size: 14px; }
  .related-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .related-card__body { padding: 10px 12px; }
  .related-section { padding: 16px; }
}

@media (max-width: 480px) {
  .topbar__inner { padding: 0 12px; gap: 12px; }
  .admin-link { padding: 6px 10px; font-size: 12px; }
  .page { padding: 10px 10px 80px; }
  .player-grid { padding: 12px; gap: 12px; }
  .institution { padding: 12px; }
  .related-grid { grid-template-columns: 1fr; }
}

/* ----------------------- 未购买锁定遮罩 ----------------------- */
.player-locked {
  position: absolute; inset: 0; z-index: 5;
  background: rgba(11, 18, 32, 0.92);
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  text-align: center; padding: 48px 24px 24px; color: #fff;
}
.player-locked[hidden] { display: none; }
.player-locked__icon { font-size: 42px; margin-bottom: 14px; }
.player-locked__title { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.player-locked__hint { font-size: 14px; color: #a0aec0; max-width: 360px; line-height: 1.6; margin-bottom: 22px; }
.player-locked__actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }

/* 遮罩内购买/兑换按钮 — 醒目样式，类似课程卡片的立即试看 */
.player-locked__actions .btn {
  min-width: 150px;
  padding: 12px 28px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all .2s ease;
  white-space: nowrap;
}
.player-locked__actions .btn--primary {
  background: linear-gradient(135deg, #1e6cff 0%, #4a90ff 100%);
  color: #fff;
  box-shadow: 0 8px 20px rgba(30, 108, 255, 0.35);
}
.player-locked__actions .btn--primary:hover {
  background: linear-gradient(135deg, #1859d6 0%, #3a7ef0 100%);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(30, 108, 255, 0.40);
}
.player-locked__actions .btn--ghost {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
}
.player-locked__actions .btn--ghost:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: #fff;
}

/* ----------------------- 解锁弹窗 ----------------------- */
.modal { position: fixed; inset: 0; background: rgba(20, 30, 50, .55); z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__panel { background: #fff; border-radius: 10px; padding: 24px; width: min(420px, 92vw); box-shadow: 0 24px 48px rgba(0,0,0,.18); }
.modal__panel h3 { margin: 0 0 10px; font-size: 16px; color: #1f2329; }
.modal__panel p { margin: 0 0 18px; color: #5b6470; font-size: 14px; line-height: 1.6; white-space: pre-line; }
.modal__actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 14px; font-weight: 500; border: 1px solid transparent; transition: all .15s; cursor: pointer; }
.modal .btn--primary { background: #1e6cff; color: #fff; border-color: #1e6cff; }
.modal .btn--primary:hover { background: #1859d6; }
.modal .btn--ghost { background: transparent; color: #5b6470; border-color: #e5e9f0; }
.modal .btn--ghost:hover { color: #1e6cff; border-color: #1e6cff; }
.modal .btn--lg { padding: 12px 24px; font-size: 15px; }


/* ----------------------- 移动端锁定遮罩（必须放在 player-locked 之后才能覆盖） ----------------------- */
@media (max-width: 480px) {
  .player-locked { justify-content: center; padding: 12px 14px; }
  .player-locked__icon { font-size: 22px; margin-bottom: 4px; }
  .player-locked__title { font-size: 13px; margin-bottom: 2px; }
  .player-locked__hint { font-size: 11px; line-height: 1.4; margin-bottom: 8px; max-width: 100%; }
  .player-locked__actions { flex-direction: row; gap: 8px; width: 100%; max-width: none; }
  .player-locked__actions .btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 8px;
  }
}
