/* ==========================================================================
   LectureStream - 现代化深色沉浸式流媒体播放器样式
   ========================================================================== */

:root {
  --bg-primary: #07090e;
  --bg-surface: #0f1422;
  --bg-surface-hover: #182035;
  --bg-card: #131b2e;
  --border-color: #1e293b;
  --border-focus: #3b82f6;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --brand-blue: #3b82f6;
  --brand-blue-hover: #2563eb;
  --brand-glow: rgba(59, 130, 246, 0.25);

  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.12);
  --accent-amber: #f59e0b;
  --accent-amber-bg: rgba(245, 158, 11, 0.12);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --header-height: 60px;
  --sidebar-width: 380px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: -webkit-fill-available;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #27354f;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3b4e72;
}

/* ==========================================================================
   1. 顶部导航栏 (Header)
   ========================================================================== */
.app-header {
  height: var(--header-height);
  padding: var(--safe-top) 24px 0 24px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 40;
  flex-shrink: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-box {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.logo-icon {
  width: 26px;
  height: 26px;
  color: var(--brand-blue);
  filter: drop-shadow(0 0 8px var(--brand-glow));
}

.logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.course-stats {
  display: flex;
  align-items: center;
}

.stat-badge {
  font-size: 0.78rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: #1a233a;
  border: 1px solid #283758;
  color: #93c5fd;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 开关组件 */
.toggle-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.toggle-control input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background-color: #242f48;
  border-radius: 999px;
  position: relative;
  transition: background-color 0.25s ease;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.25s ease;
}

.toggle-control input:checked + .toggle-slider {
  background-color: var(--brand-blue);
}

.toggle-control input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

.icon-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-main);
  border-color: #3b4e72;
}

.mobile-only {
  display: none;
}

/* ==========================================================================
   2. 主工作区布局 (Main Layout)
   ========================================================================== */
.main-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  height: calc(100vh - var(--header-height));
  overflow: hidden;
}

/* 左侧播放器工作区 */
.player-wrapper {
  display: flex;
  flex-direction: column;
  background-color: #030509;
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
}

.player-container-box {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  position: relative;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  flex-shrink: 0;
}

#artplayer-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, #111827 0%, #030712 100%);
  color: var(--text-dim);
  text-align: center;
}

.placeholder-content svg {
  margin-bottom: 14px;
  color: #3b82f6;
  opacity: 0.6;
}

.placeholder-content p {
  font-size: 0.95rem;
}

/* 播放器下方信息栏 */
.current-meta {
  padding: 20px 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  background: var(--bg-primary);
  border-top: 1px solid #141b2b;
}

.meta-main {
  flex: 1;
  min-width: 0;
}

.current-title {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 10px;
  color: var(--text-main);
  word-break: break-all;
}

.meta-sub {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.meta-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.sync-indicator {
  font-size: 0.78rem;
  color: var(--accent-green);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sync-indicator::before {
  content: "";
  width: 6px;
  height: 6px;
  background: var(--accent-green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--accent-green);
}

.sync-indicator.syncing {
  color: #38bdf8;
}
.sync-indicator.syncing::before {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.3; }
  to { opacity: 1; }
}

.meta-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.action-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.action-btn:hover {
  background: var(--bg-surface-hover);
  border-color: #3b4e72;
}

.action-btn.text-only {
  background: transparent;
  border: none;
  color: var(--text-muted);
}
.action-btn.text-only:hover {
  color: var(--brand-blue);
}

/* ==========================================================================
   3. 右侧课程目录 (Playlist Sidebar)
   ========================================================================== */
.playlist-sidebar {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-surface);
  height: 100%;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.video-count-badge {
  font-size: 0.75rem;
  background: #1a2238;
  color: #93c5fd;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

/* 搜索框 */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-dim);
}

.search-box input {
  width: 100%;
  height: 36px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0 32px 0 34px;
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--brand-glow);
}

.clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.1rem;
  cursor: pointer;
}

/* 过滤 Tab */
.filter-tabs {
  display: flex;
  gap: 6px;
  background: #090d16;
  padding: 3px;
  border-radius: var(--radius-sm);
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 5px 0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.tab-btn:hover {
  color: var(--text-muted);
}

.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 600;
}

/* 视频列表滚动区 */
.video-list-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px;
  -webkit-overflow-scrolling: touch;
}

.video-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 视频项卡片 */
.video-item {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.video-item:hover {
  background: var(--bg-surface-hover);
  border-color: #3b4e72;
  transform: translateY(-1px);
}

.video-item.active {
  background: #142344;
  border-color: var(--brand-blue);
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.2);
}

.video-item-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.item-index {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  min-width: 20px;
  margin-top: 2px;
}

.video-item.active .item-index {
  color: #60a5fa;
}

.item-title {
  flex: 1;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.35;
  word-break: break-all;
}

.item-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-completed {
  background: var(--accent-green-bg);
  color: var(--accent-green);
}

.badge-studying {
  background: var(--brand-glow);
  color: #60a5fa;
}

.badge-unstarted {
  background: #1f2937;
  color: #94a3b8;
}

.video-item-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--text-dim);
  margin-top: 6px;
}

/* 进度条槽 */
.progress-track {
  width: 100%;
  height: 4px;
  background-color: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-fill {
  height: 100%;
  background: var(--brand-blue);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-fill.completed {
  background: var(--accent-green);
}

/* 正在播放的呼吸指示 */
.now-playing-wave {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  margin-left: 6px;
}
.now-playing-wave span {
  width: 2px;
  background-color: #60a5fa;
  animation: wave 1s infinite ease-in-out;
}
.now-playing-wave span:nth-child(1) { height: 6px; animation-delay: 0.1s; }
.now-playing-wave span:nth-child(2) { height: 12px; animation-delay: 0.3s; }
.now-playing-wave span:nth-child(3) { height: 8px; animation-delay: 0.2s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.4); }
  50% { transform: scaleY(1); }
}

/* 状态加载/为空 */
.loading-state,
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.88rem;
  text-align: center;
  gap: 12px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #1e293b;
  border-top-color: var(--brand-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ==========================================================================
   4. 模态弹窗 (Modals)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.modal-overlay.show {
  display: flex;
  opacity: 1;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  transform: translateY(20px);
  transition: transform 0.25s ease;
}

.modal-overlay.show .modal-card {
  transform: translateY(0);
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title-box {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--brand-blue);
}

.modal-title-box h3 {
  font-size: 1.05rem;
  color: var(--text-main);
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
}
.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 20px 24px;
}

.modal-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 16px;
}

.modal-desc code {
  background: #1e293b;
  padding: 2px 6px;
  border-radius: 4px;
  color: #93c5fd;
  font-size: 0.82rem;
}

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group input {
  width: 100%;
  height: 44px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 44px 0 14px;
  color: var(--text-main);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.input-group input:focus {
  border-color: var(--border-focus);
}

.btn-toggle-eye {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1rem;
}

.error-tip {
  margin-top: 8px;
  font-size: 0.8rem;
  color: #ef4444;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background: #090e1a;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.modal-btn {
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.modal-btn.secondary {
  background: transparent;
  color: var(--text-muted);
}
.modal-btn.secondary:hover {
  color: #ef4444;
}

.modal-btn.primary {
  background: var(--brand-blue);
  color: #ffffff;
}
.modal-btn.primary:hover {
  background: var(--brand-blue-hover);
}

/* 快捷键帮助弹窗内表格 */
.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.help-section h4 {
  font-size: 0.92rem;
  color: #93c5fd;
  margin-bottom: 12px;
}

.help-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.help-section li {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  color: var(--text-main);
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 4px;
  box-shadow: 0 1px 1px rgba(0,0,0,0.4);
}

/* ==========================================================================
   5. Toast 轻量提示条
   ========================================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid #334155;
  color: var(--text-main);
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 0.88rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==========================================================================
   6. 移动端与响应式适配 (Mobile & Tablet)
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 320px;
  }
}

@media (max-width: 768px) {
  .app-header {
    padding: var(--safe-top) 14px 0 14px;
  }
  .course-stats {
    display: none;
  }
  .mobile-only {
    display: flex;
  }

  .main-layout {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
  }

  .player-wrapper {
    flex: none;
    border-right: none;
  }

  .current-meta {
    padding: 14px 16px;
    flex-direction: column;
    gap: 12px;
  }
  .meta-actions {
    width: 100%;
    justify-content: space-between;
  }

  .playlist-sidebar {
    flex: 1;
    height: auto;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }

  /* 移动端全屏抽屉模式 (点击目录按钮切换) */
  .playlist-sidebar.drawer-mode {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    background: var(--bg-surface);
  }
}
