/* ========= COURSE PAGE LAYOUT ========= */
.course-page {
  padding-top: var(--header-height);
  min-height: 100vh;
}

.course-layout {
  display: grid;
  grid-template-columns: 1fr var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
}

/* ========= VIDEO PLAYER AREA ========= */
.player-area {
  padding: 1.5rem;
}

.video-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-xl);
}

.video-wrapper video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.video-wrapper.theater-mode {
  border-radius: 0;
  max-width: none;
}

/* ========= CUSTOM CONTROLS ========= */
.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  padding: 3rem 0 0.75rem;
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: 10;
}

.video-wrapper:hover .video-controls,
.video-wrapper.controls-visible .video-controls {
  opacity: 1;
}

/* Progress Bar */
.progress-container {
  position: relative;
  width: calc(100% - 1.5rem);
  margin-left: 0.75rem;
  margin-right: 0.75rem;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 0;
  cursor: pointer;
  margin-bottom: 0.75rem;
  transition: height 0.15s ease, margin 0.15s ease;
  z-index: 2;
}

.progress-container:hover {
  height: 7px;
}

.progress-buffered {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-full);
  transition: width 0.3s ease;
}

.progress-filled {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #6366f1, #3b82f6, #06b6d4);
  background-size: 300% 100%;
  animation: progressShimmer 4s ease infinite;
  border-radius: 0;
  transition: width 0.1s linear;
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.5), 0 0 4px rgba(59, 130, 246, 0.3);
}

@keyframes progressShimmer {
  0% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }

  100% {
    background-position: 0% 50%;
  }
}

.progress-thumb {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), left 0.1s linear;
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.35), 0 2px 10px rgba(0, 0, 0, 0.5);
  z-index: 3;
  left: 0%;
}

.progress-container:hover .progress-thumb {
  transform: translate(-50%, -50%) scale(1);
}

.progress-tooltip {
  position: absolute;
  bottom: 22px;
  background: rgba(15, 15, 25, 0.95);
  color: white;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  pointer-events: none;
  transform: translateX(-50%);
  display: none;
  white-space: nowrap;
  border: 1px solid rgba(139, 92, 246, 0.3);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.progress-container:hover .progress-tooltip {
  display: block;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.75rem;
}

.controls-left,
.controls-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ctrl-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  color: rgba(255, 255, 255, 0.85);
  position: relative;
}

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

.ctrl-btn:active {
  transform: scale(0.92);
}

.ctrl-btn svg {
  width: 22px;
  height: 22px;
}

.ctrl-btn.small svg {
  width: 18px;
  height: 18px;
}

/* Volume */
.volume-control {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.volume-slider-wrap {
  width: 0;
  overflow: hidden;
  transition: width var(--transition-base);
}

.volume-control:hover .volume-slider-wrap {
  width: 90px;
}

.volume-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  transition: height 0.15s ease;
}

.volume-control:hover .volume-slider {
  height: 5px;
}

.volume-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3), 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  margin-top: -5px;
}

.volume-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.5), 0 2px 10px rgba(0, 0, 0, 0.5);
}

.volume-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3), 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Filled portion of volume slider (WebKit) */
.volume-slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, #8b5cf6, #3b82f6);
}

/* Time Display */
.time-display {
  font-size: 0.82rem;
  color: rgba(255, 255, 255, 0.75);
  font-family: var(--font-mono);
  font-weight: 500;
  margin: 0 0.5rem;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

/* Speed & Quality Menus */
.dropdown-menu {
  position: absolute;
  bottom: 100%;
  right: 0;
  background: rgba(20, 20, 30, 0.95);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.5rem 0;
  min-width: 140px;
  display: none;
  z-index: 20;
  box-shadow: var(--shadow-xl);
}

.dropdown-menu.visible {
  display: block;
}

.dropdown-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  cursor: pointer;
  white-space: nowrap;
}

.dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.dropdown-item.active {
  color: var(--accent-primary-light);
  font-weight: 600;
}

.dropdown-item.active::after {
  content: '✓';
  margin-left: 0.5rem;
  font-weight: bold;
}

.dropdown-label {
  padding: 6px 16px 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.speed-value,
.quality-value {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-primary-light);
  margin-left: 0.25rem;
}

/* Big Play Button */
.big-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background: rgba(139, 92, 246, 0.85);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all var(--transition-base);
  box-shadow: 0 8px 30px rgba(139, 92, 246, 0.4);
  cursor: pointer;
}

.big-play-btn:hover {
  transform: translate(-50%, -50%) scale(1.1);
  background: rgba(139, 92, 246, 1);
}

.big-play-btn svg {
  width: 36px;
  height: 36px;
  color: white;
  margin-left: 4px;
}

.big-play-btn.hidden {
  display: none;
}

/* Loading spinner */
.video-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 4;
  display: none;
}

.video-loading.visible {
  display: block;
}

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

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

/* ========= VIDEO INFO ========= */
.video-info {
  padding: 1.5rem 0;
}

.video-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.video-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.video-meta span {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* ========= PLAYLIST SIDEBAR ========= */
.playlist-sidebar {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
}

.playlist-header {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.playlist-header h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.playlist-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.playlist-progress {
  margin-top: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.progress-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: var(--radius-full);
  transition: width var(--transition-base);
}

.progress-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.playlist-content {
  flex: 1;
  overflow-y: auto;
}

/* Module/Section */
.module-section {
  border-bottom: 1px solid var(--border-subtle);
}

.module-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.module-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.module-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.module-header .chevron {
  transition: transform var(--transition-base);
  color: var(--text-dim);
}

.module-header .chevron.rotated {
  transform: rotate(180deg);
}

.module-count {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 500;
}

.module-videos {
  display: none;
}

.module-videos.expanded {
  display: block;
}

/* Video Item */
.video-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem 0.75rem 1.5rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.video-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.video-item.active {
  background: rgba(139, 92, 246, 0.1);
  border-left: 3px solid var(--accent-primary);
}

.video-item.watched .video-item-index {
  color: var(--accent-green);
}

.video-item-index {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 24px;
}

.video-item-info {
  flex: 1;
  min-width: 0;
}

.video-item-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-item-duration {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.video-item-status {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}

.video-item.watched .video-item-status {
  color: var(--accent-green);
}

.video-item.active .video-item-title {
  color: var(--accent-primary-light);
}

.now-playing-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-primary);
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
}

/* ========= FULLSCREEN ========= */
.video-wrapper:fullscreen {
  border-radius: 0;
}

.video-wrapper:fullscreen .video-controls {
  padding: 4rem 1.5rem 1rem;
}

.video-wrapper:-webkit-full-screen {
  border-radius: 0;
}

/* Theater mode */
body.theater-mode .course-layout {
  grid-template-columns: 1fr;
}

body.theater-mode .playlist-sidebar {
  position: fixed;
  right: 0;
  top: var(--header-height);
  width: var(--sidebar-width);
  z-index: 100;
  transform: translateX(100%);
  transition: transform var(--transition-base);
}

body.theater-mode .playlist-sidebar.visible {
  transform: translateX(0);
}

/* ========= RESPONSIVE ========= */

/* Tablet - stack layout */
@media (max-width: 1024px) {
  .course-layout {
    grid-template-columns: 1fr;
  }

  .playlist-sidebar {
    position: relative;
    height: auto;
    max-height: 50vh;
    border-left: none;
    border-top: 1px solid var(--border-subtle);
  }

  .player-area {
    padding: 1rem;
  }

  .video-wrapper {
    border-radius: 12px;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .player-area {
    padding: 0.5rem;
  }

  .video-wrapper {
    border-radius: 8px;
  }

  /* Controls */
  .ctrl-btn {
    width: 34px;
    height: 34px;
  }

  .ctrl-btn svg {
    width: 18px;
    height: 18px;
  }

  .ctrl-btn.small svg {
    width: 15px;
    height: 15px;
  }

  .controls-bar {
    padding: 0 0.5rem;
    gap: 0.25rem;
  }

  .controls-left,
  .controls-right {
    gap: 0;
  }

  .time-display {
    font-size: 0.68rem;
    margin: 0 0.25rem;
  }

  .progress-container {
    width: calc(100% - 1rem);
    margin-left: 0.5rem;
    margin-right: 0.5rem;
  }

  /* Volume - always show on mobile */
  .volume-slider-wrap {
    display: none;
  }

  /* Speed/Quality value badges */
  .speed-value,
  .quality-value {
    font-size: 0.65rem;
  }

  /* Dropdown menus */
  .dropdown-menu {
    min-width: 140px;
  }

  .dropdown-item {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  /* Video info */
  .video-info {
    padding: 0.75rem 0.5rem;
  }

  .video-title {
    font-size: 1rem;
  }

  .video-meta {
    font-size: 0.78rem;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  /* Playlist */
  .playlist-sidebar {
    max-height: 40vh;
  }

  .playlist-header {
    padding: 1rem 0.75rem;
  }

  .playlist-header h2 {
    font-size: 0.9rem;
  }

  .video-item {
    padding: 0.6rem 0.75rem 0.6rem 1rem;
    gap: 0.5rem;
  }

  .video-item-title {
    font-size: 0.8rem;
  }

  .video-item-duration {
    font-size: 0.7rem;
  }

  .video-item-index {
    font-size: 0.75rem;
    min-width: 20px;
  }

  .module-header {
    padding: 0.75rem;
  }

  .module-header h3 {
    font-size: 0.8rem;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .player-area {
    padding: 0.25rem;
  }

  .video-wrapper {
    border-radius: 6px;
  }

  .ctrl-btn {
    width: 30px;
    height: 30px;
  }

  .ctrl-btn svg {
    width: 16px;
    height: 16px;
  }

  .time-display {
    font-size: 0.6rem;
    margin: 0 0.15rem;
  }

  /* Hide less important controls on very small screens */
  #theater-btn,
  #quality-btn {
    display: none;
  }

  .big-play-btn {
    width: 60px;
    height: 60px;
  }

  .big-play-btn svg {
    width: 28px;
    height: 28px;
  }
}