/* ==========================================================================
   BiliCourse Web Stylesheet - Apple HIG Inspired Dark Design
   ========================================================================== */

:root {
  --bg-primary: #0d0e12;
  --bg-secondary: #16181f;
  --bg-tertiary: #1f222c;
  --bg-card: rgba(26, 29, 38, 0.75);
  --bg-glass: rgba(30, 34, 46, 0.65);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-subtle: rgba(255, 255, 255, 0.05);

  --text-primary: #f5f5f7;
  --text-secondary: #9da1b0;
  --text-muted: #656978;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-subtle: rgba(59, 130, 246, 0.18);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Glassmorphism */
.glass {
  background: var(--bg-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(13, 14, 18, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

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

.brand-logo {
  font-size: 24px;
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.4px;
  background: linear-gradient(135deg, #fff 40%, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.06);
  padding: 4px;
  border-radius: var(--radius-full);
  gap: 2px;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-btn:hover {
  color: var(--text-primary);
}

.nav-btn.active {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

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

/* Main Content */
.main-content {
  flex: 1;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-pane.active {
  display: block;
}

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

/* Hero Continue Watching Card */
.hero-card {
  display: flex;
  gap: 24px;
  padding: 20px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(59, 130, 246, 0.3);
  box-shadow: 0 10px 30px rgba(37, 99, 235, 0.15);
}

.hero-cover-wrap {
  position: relative;
  width: 320px;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: var(--bg-tertiary);
}

.hero-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1;
}

.hero-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 4px;
}

.hero-course {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  line-height: 1.3;
}

.hero-lesson {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.progress-container {
  margin-bottom: 16px;
  max-width: 500px;
}

.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.hero-btn {
  align-self: flex-start;
  padding: 10px 22px;
  font-size: 15px;
}

/* Split Row (Countdown & Timetable) */
.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.card {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.card-header h3 {
  font-size: 17px;
  font-weight: 600;
}

.date-badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.status-indicator {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 600;
}

/* Countdown List */
.countdown-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.countdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.cd-title-wrap strong {
  display: block;
  font-size: 15px;
  font-weight: 600;
}

.cd-title-wrap span {
  font-size: 12px;
  color: var(--text-muted);
}

.cd-days-box {
  text-align: right;
}

.cd-days {
  font-size: 24px;
  font-weight: 800;
  color: #ff9f0a;
  letter-spacing: -1px;
}

.cd-unit {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 2px;
}

/* Today Slots List */
.today-slots-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.today-slot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  font-size: 14px;
}

.today-slot-row.active-period {
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid var(--accent);
}

.slot-period-time {
  font-size: 12px;
  color: var(--text-muted);
  width: 90px;
}

.slot-period-title {
  font-weight: 500;
  flex: 1;
}

/* Subject Badges */
.badge-subject {
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.sub-chinese { background: #ef4444; }
.sub-math { background: #f97316; }
.sub-english { background: #3b82f6; }
.sub-physics { background: #6366f1; }
.sub-chemistry { background: #06b6d4; }
.sub-biology { background: #10b981; }
.sub-pe { background: #a855f7; }
.sub-test { background: #ec4899; }
.sub-other { background: #64748b; }

/* Course Grid */
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.course-card {
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(255, 255, 255, 0.2);
}

.course-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.course-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.course-card:hover .course-cover {
  transform: scale(1.03);
}

.badge-platform {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  color: #fff;
}

.badge-platform.bili { background: rgba(251, 114, 153, 0.85); }
.badge-platform.youdao { background: rgba(37, 99, 235, 0.85); }

.course-content {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.course-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.tag-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
}

.course-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-card-meta {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* Toolbar & Filter Bar */
.courses-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  margin-bottom: 16px;
  gap: 16px;
  flex-wrap: wrap;
}

.platform-segmented {
  display: flex;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  padding: 3px;
}

.segment-btn {
  padding: 6px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s ease;
}

.segment-btn.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  min-width: 280px;
}

.search-wrap input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 13px;
  width: 100%;
  outline: none;
}

.tag-groups-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.filter-pill {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.filter-pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Schedule Controls & Timetable */
.schedule-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  margin-bottom: 20px;
}

.timetable-view-wrap {
  overflow-x: auto;
}

.timetable-table {
  min-width: 760px;
  padding: 16px;
}

.timetable-header-row {
  display: grid;
  grid-template-columns: 100px repeat(5, 1fr);
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  text-align: center;
  color: var(--text-secondary);
}

.col-period { text-align: left; padding-left: 8px; }

.timetable-row {
  display: grid;
  grid-template-columns: 100px repeat(5, 1fr);
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
}

.period-info {
  font-size: 13px;
  padding-left: 8px;
}

.period-name { font-weight: 600; color: #fff; }
.period-time { font-size: 11px; color: var(--text-muted); }

.slot-cell {
  text-align: center;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Buttons & Inputs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.btn-secondary { background: rgba(255, 255, 255, 0.1); color: #fff; }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.16); }

.btn-danger { background: rgba(239, 68, 68, 0.2); color: #ef4444; }
.btn-danger:hover { background: #ef4444; color: #fff; }

.btn-link { background: transparent; color: var(--accent); padding: 0; }
.btn-link:hover { text-decoration: underline; }

.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-full);
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-secondary);
}
.btn-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.16); }

.btn-block { width: 100%; }

/* Modal & Drawers */
.modal-overlay, .drawer-overlay, .player-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card, .auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 30px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.25s ease-out;
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.auth-card {
  text-align: center;
}

.auth-icon {
  width: 72px;
  height: 72px;
  background: var(--accent-subtle);
  color: var(--accent);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.auth-card h2 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
}

.auth-card .subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.input-group input, .form-group input, .form-group textarea, .setting-item-block textarea, .setting-item-block input {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: #fff;
  font-size: 14px;
  outline: none;
  margin-bottom: 14px;
  font-family: inherit;
}

.input-group input:focus, .form-group input:focus, .form-group textarea:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.1);
}

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 14px;
}

.hidden { display: none !important; }

/* Course Drawer */
.drawer-content {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 540px;
  max-width: 90vw;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  padding: 24px;
  overflow-y: auto;
  animation: slideLeft 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideLeft {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.drawer-header .close-btn {
  align-self: flex-end;
}

.lessons-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lesson-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.2s ease;
}

.lesson-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--border-color);
}

.lesson-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.lesson-idx {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  width: 24px;
}

.lesson-title {
  font-size: 14px;
  font-weight: 500;
  color: #fff;
}

/* Video Player Modal */
.player-overlay {
  flex-direction: column;
  padding: 20px;
  background: rgba(0, 0, 0, 0.9);
}

.player-header {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.player-body {
  width: 100%;
  max-width: 1200px;
  height: 80vh;
  display: flex;
  gap: 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-color);
}

.video-wrapper {
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  max-height: 80vh;
}

.player-playlist-drawer {
  width: 320px;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.playlist-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.playlist-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.playlist-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
}

.playlist-item:hover { background: rgba(255, 255, 255, 0.08); }
.playlist-item.active { background: var(--accent-subtle); color: var(--accent); font-weight: 600; }

.select-btn {
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 13px;
  cursor: pointer;
}

/* Settings & Switches */
.settings-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.accounts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.account-card { padding: 16px; }
.account-header { display: flex; align-items: center; gap: 14px; }
.avatar { width: 48px; height: 48px; border-radius: var(--radius-full); object-fit: cover; }
.account-details h4 { font-size: 16px; font-weight: 600; }

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.setting-label strong { display: block; font-size: 15px; }
.setting-label span { font-size: 12px; color: var(--text-muted); }

.setting-item-block {
  margin-top: 16px;
}

.setting-item-block label { display: block; margin-bottom: 6px; font-size: 14px; }

/* Switch Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.16);
  transition: .3s;
  border-radius: 24px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider { background-color: var(--accent); }
input:checked + .slider:before { transform: translateX(20px); }

/* Mobile Adaptations */
@media (max-width: 768px) {
  .app-header { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .split-row { grid-template-columns: 1fr; }
  .hero-card { flex-direction: column; }
  .hero-cover-wrap { width: 100%; }
  .accounts-row { grid-template-columns: 1fr; }
  .player-body { flex-direction: column; height: 90vh; }
  .player-playlist-drawer { width: 100%; height: 200px; }
  .main-content { padding: 16px 12px; }
}
