/* ==========================================================================
   Immersive Single Player - Layout, Player Container, Overlays, Quiz
   Requirements: 7.1, 7.2, 9.8, 9.9
   ========================================================================== */

/* ==========================================================================
   0. SLIM COURSE BANNER — Player-first toolbar, image as small thumbnail
   No poster/hero feel. Solid dark bg, thumbnail left, text center, CTA right.
   ========================================================================== */

.sw-course-banner {
  background: #1a1a2e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

/* Content layout: thumbnail + text + actions */
.sw-course-banner__content {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 12px;
  padding-bottom: 12px;
  width: 100%;
}

/* Thumbnail — wide aspect ratio matching hero images */
.sw-course-banner__thumb {
  flex-shrink: 0;
  width: 120px;
  height: 68px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
}

.sw-course-banner__thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.sw-course-banner__left {
  flex: 1;
  min-width: 0;
}

/* Sport label */
.sw-course-banner__sport {
  margin-bottom: 1px;
}

.sw-course-banner__sport a {
  color: rgba(255, 255, 255, 0.6);
  font-family: 'Poppins', sans-serif;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  text-decoration: none;
}

.sw-course-banner__sport a:hover {
  color: #fff;
}

/* Title */
.sw-course-banner__title {
  font-family: 'Poppins', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0 0 2px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Meta row */
.sw-course-banner__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-family: 'Poppins', sans-serif;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.55);
}

.sw-course-banner__meta a {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  text-decoration: none;
}

.sw-course-banner__meta a:hover {
  color: #fff;
  text-decoration: underline;
}

.sw-course-banner__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sw-course-banner__sep {
  opacity: 0.3;
}

.sw-course-banner__avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Action buttons (right side) */
.sw-course-banner__actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.sw-course-banner__action {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.65rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  transition: all 150ms ease;
  white-space: nowrap;
}

.sw-course-banner__action:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Primary CTA — "Guarda la prima lezione" */
.sw-course-banner__action--primary {
  background: var(--iq-brand-color-1, #003399);
  border-color: var(--iq-brand-color-1, #003399);
  color: #fff;
  font-weight: 600;
}

.sw-course-banner__action--primary:hover {
  filter: brightness(1.2);
  color: #fff;
  background: var(--iq-brand-color-1, #003399);
}

.sw-course-banner__action i {
  font-size: 0.6rem;
}

/* Mobile responsive */
@media (max-width: 991.98px) {
  .sw-course-banner__content {
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .sw-course-banner__thumb {
    width: 100%;
    height: 120px;
    border-radius: 8px;
  }

  .sw-course-banner__thumb-img {
    object-position: center center;
  }

  .sw-course-banner__title {
    font-size: 1.1rem;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
  }

  .sw-course-banner__meta {
    font-size: 0.72rem;
  }

  /* CTA buttons must be visible on dark banner bg */
  .sw-course-banner__actions {
    width: 100%;
    gap: 6px;
  }

  .sw-course-banner__action {
    padding: 6px 12px;
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.2);
    background: rgba(255, 255, 255, 0.08);
  }
}

@media (max-width: 575.98px) {
  .sw-course-banner__thumb {
    height: 100px;
  }

  .sw-course-banner__title {
    font-size: 1rem;
  }

  .sw-course-banner__meta {
    font-size: 0.68rem;
  }

  .sw-course-banner__action span {
    display: none;
  }

  .sw-course-banner__action {
    padding: 6px 10px;
  }
}

/* ==========================================================================
   1. PLAYER CONTAINER (#sw-singleton-player)
   - 100% width, aspect-ratio 16:9, max-height 500px on desktop
   - position: relative for overlay positioning
   - sticky on desktop for scroll-along behavior
   ========================================================================== */

#sw-singleton-player {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  z-index: 10;
}

/* Desktop: player with padding, no max-height (aspect-ratio controls height naturally) */
@media (min-width: 992px) {
  #sw-singleton-player {
    margin: 16px 32px;
    width: calc(100% - 64px);
    border-radius: 10px;
  }
}

/* Remove max-height on mobile for full-width experience */
@media (max-width: 991.98px) {
  #sw-singleton-player {
    max-height: none;
    border-radius: 0;
    margin: 0;
    width: 100%;
  }
}

/* Video element fills container */
#sw-sp-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

/* ==========================================================================
   2. PLACEHOLDER OVERLAY
   Shown when no video is selected
   ========================================================================== */

.sw-sp-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  color: #e2e8f0;
  z-index: 5;
  border-radius: 8px;
}

.sw-sp-placeholder__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.sw-sp-placeholder__icon {
  width: 64px;
  height: 64px;
  opacity: 0.5;
}

.sw-sp-placeholder__text {
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 400;
  opacity: 0.7;
  text-align: center;
  padding: 0 20px;
}

.sw-sp-placeholder__desc {
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 400;
  opacity: 0.55;
  text-align: center;
  padding: 0 40px;
  line-height: 1.5;
  max-width: 500px;
  margin: 0;
}

.sw-sp-placeholder__btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  color: #fff;
  background: var(--iq-brand-color-1, #003399);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 150ms ease;
  margin-top: 4px;
}

.sw-sp-placeholder__btn:hover {
  filter: brightness(1.2);
  box-shadow: 0 4px 12px rgba(0, 51, 153, 0.3);
}

/* ==========================================================================
   3. LOADING OVERLAY
   Spinner shown during source swap
   ========================================================================== */

.sw-sp-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  z-index: 15;
  backdrop-filter: blur(2px);
}

.sw-sp-loading__spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--iq-brand-color-1, #003399);
  border-radius: 50%;
  animation: swSpSpin 0.8s linear infinite;
}

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

/* ==========================================================================
   4. ERROR OVERLAY
   Shown when stream URL fetch fails or video errors
   ========================================================================== */

.sw-sp-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
  z-index: 15;
  padding: 24px;
  text-align: center;
}

.sw-sp-error__icon {
  font-size: 2rem;
  color: #ef4444;
  opacity: 0.8;
}

.sw-sp-error__message {
  font-family: 'Poppins', sans-serif;
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.5;
  opacity: 0.85;
}

.sw-sp-error__retry {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  cursor: pointer;
  transition: all 180ms ease;
}

.sw-sp-error__retry:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.35);
}

/* ==========================================================================
   5. QUIZ OVERLAY (#sw-sp-quiz-overlay)
   Dark background, centered content, Poppins font
   Requirement 9.8: dark background coerente col player, card-minimal
   ========================================================================== */

#sw-sp-quiz-overlay,
.sw-sp-quiz-overlay {
  display: none;
  flex-direction: column;
  background: #0f172a;
  color: #f1f5f9;
  z-index: 20;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  border-radius: 0;
  min-height: 280px;
  max-height: 55vh;
}

.sw-sp-quiz-overlay::-webkit-scrollbar {
  width: 5px;
}

.sw-sp-quiz-overlay::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Quiz header: label + skip button */
.sw-sp-quiz-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.sw-sp-quiz-label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(241, 245, 249, 0.7);
}

.sw-sp-quiz-skip {
  font-family: 'Poppins', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  color: rgba(241, 245, 249, 0.8);
  cursor: pointer;
  transition: all 180ms ease;
}

.sw-sp-quiz-skip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  color: #fff;
}

/* "Torna al video" button — more prominent than skip/cancel */
.sw-sp-quiz-back-to-video {
  font-family: 'Poppins', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 4px;
  border: 1px solid var(--iq-brand-color-1, #003399);
  background: rgba(0, 51, 153, 0.15);
  color: #fff;
  cursor: pointer;
  transition: all 180ms ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sw-sp-quiz-back-to-video:hover {
  background: var(--iq-brand-color-1, #003399);
  color: #fff;
}

/* Quiz content area (HTMX injects slides here) */
.sw-sp-quiz-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  min-height: 0;
}

/* Center quiz slides inside the overlay content */
.sw-sp-quiz-content > * {
  width: 100%;
  max-width: 560px;
}

/* ==========================================================================
   6. QUIZ ANSWER CARDS — Dark Theme Overrides
   Minimal style on dark background, light border, hover glow
   Requirement 9.8
   ========================================================================== */

/* Override quiz-slide text colors for dark theme */
.sw-sp-quiz-overlay .quiz-slide__question-text,
.sw-sp-quiz-overlay .quiz-slide {
  color: #f1f5f9;
}

.sw-sp-quiz-overlay .quiz-slide {
  padding: 0;
  background: transparent;
}

/* Answer cards on dark background */
.sw-sp-quiz-overlay .quiz-answer-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: #f1f5f9;
  transition: border-color 200ms ease, background 200ms ease, box-shadow 200ms ease;
}

.sw-sp-quiz-overlay .quiz-answer-card:hover {
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 12px rgba(var(--iq-brand-color-1, 0, 51, 153), 0.15);
}

.sw-sp-quiz-overlay .quiz-answer-card--selected {
  border-color: var(--iq-brand-color-1, #003399);
  background: rgba(0, 51, 153, 0.12);
  box-shadow: 0 0 16px rgba(0, 51, 153, 0.25);
}

.sw-sp-quiz-overlay .quiz-answer-card__text {
  color: #e2e8f0;
}

.sw-sp-quiz-overlay .quiz-answer-card__indicator {
  border-color: rgba(255, 255, 255, 0.25);
}

.sw-sp-quiz-overlay .quiz-answer-card--selected .quiz-answer-card__indicator {
  border-color: var(--iq-brand-color-1, #003399);
  background: var(--iq-brand-color-1, #003399);
  box-shadow: inset 0 0 0 3px #0f172a;
}

/* Dark theme quiz buttons */
.sw-sp-quiz-overlay .quiz-btn--primary {
  background: var(--iq-brand-color-1, #003399);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 51, 153, 0.3);
}

.sw-sp-quiz-overlay .quiz-btn--primary:hover {
  filter: brightness(1.2);
  box-shadow: 0 4px 16px rgba(0, 51, 153, 0.4);
}

.sw-sp-quiz-overlay .quiz-btn--secondary {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border-color: rgba(255, 255, 255, 0.15);
}

.sw-sp-quiz-overlay .quiz-btn--secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

/* Dark theme feedback cards */
.sw-sp-quiz-overlay .inline-quiz-feedback {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.sw-sp-quiz-overlay .inline-quiz-feedback--correct {
  background: rgba(34, 197, 94, 0.08);
  border-color: rgba(34, 197, 94, 0.2);
}

.sw-sp-quiz-overlay .inline-quiz-feedback--incorrect {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}

.sw-sp-quiz-overlay .inline-quiz-feedback__title,
.sw-sp-quiz-overlay .inline-quiz-feedback__body {
  color: #e2e8f0;
}

/* ==========================================================================
   7. QUIZ PROGRESS DOTS — Dark Theme
   Visible above the questions on dark background
   ========================================================================== */

.sw-sp-quiz-overlay .quiz-progress-dots {
  padding: 4px 0 14px;
}

.sw-sp-quiz-overlay .quiz-dot--completed {
  background: var(--iq-brand-color-1, #003399);
}

.sw-sp-quiz-overlay .quiz-dot--active {
  border-color: var(--iq-brand-color-1, #003399);
  background: transparent;
}

.sw-sp-quiz-overlay .quiz-dot--upcoming {
  background: rgba(255, 255, 255, 0.15);
}

/* Dark theme celebration inside quiz overlay */
.sw-sp-quiz-overlay .celebration-wrapper,
.sw-sp-quiz-overlay .inline-celebration {
  background: transparent;
  color: #f1f5f9;
}

.sw-sp-quiz-overlay .celebration-message__title,
.sw-sp-quiz-overlay .inline-celebration__title {
  color: #f1f5f9;
}

.sw-sp-quiz-overlay .celebration-message__subtitle,
.sw-sp-quiz-overlay .inline-celebration__subtitle {
  color: rgba(241, 245, 249, 0.65);
}

.sw-sp-quiz-overlay .inline-celebration__score-count {
  color: #f1f5f9;
}

/* ==========================================================================
   8. LOGO WATERMARK
   Absolute positioned, bottom-right of player container
   ========================================================================== */

.sw-sp-logo {
  position: absolute;
  bottom: 12px;
  right: 12px;
  z-index: 8;
  opacity: 0.6;
  pointer-events: none;
  transition: opacity 200ms ease;
}

.sw-sp-logo img {
  max-height: 24px;
  width: auto;
}

/* Hide watermark when overlays are active */
.sw-sp-loading ~ .sw-sp-logo,
.sw-sp-error ~ .sw-sp-logo,
.sw-sp-quiz-overlay[style*="block"] ~ .sw-sp-logo {
  opacity: 0;
}

/* ==========================================================================
   9. NEXT-LESSON CTA OVERLAY
   Shown at 90% video progress + countdown after ended
   ========================================================================== */

.sw-sp-next-lesson {
  position: absolute;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  color: #f1f5f9;
  z-index: 12;
  backdrop-filter: blur(10px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255,255,255,0.05);
  animation: swSpSlideIn 350ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
  max-width: calc(100% - 32px);
}

@keyframes swSpSlideIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.sw-sp-next-lesson__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sw-sp-next-lesson__label {
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.7);
}

.sw-sp-next-lesson__title {
  font-family: 'Poppins', sans-serif;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.3;
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}

/* Countdown ring SVG */
.sw-sp-next-lesson__countdown {
  position: relative;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.sw-sp-next-lesson__countdown svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.sw-sp-next-lesson__countdown-track,
.sw-sp-next-lesson__ring-bg {
  fill: none;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 3;
}

.sw-sp-next-lesson__countdown-ring,
.sw-sp-next-lesson__ring-fill {
  fill: none;
  stroke: var(--iq-brand-color-1, #003399);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s linear;
}

.sw-sp-next-lesson__countdown-text,
.sw-sp-next-lesson__seconds {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* CTA action buttons */
.sw-sp-next-lesson__actions {
  display: flex;
  gap: 6px;
  margin-left: 8px;
}

.sw-sp-next-lesson__btn {
  font-family: 'Poppins', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  transition: all 150ms ease;
}

.sw-sp-next-lesson__btn--play {
  background: var(--iq-brand-color-1, #003399);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 51, 153, 0.35);
}

.sw-sp-next-lesson__btn--play:hover {
  filter: brightness(1.2);
  box-shadow: 0 4px 16px rgba(0, 51, 153, 0.5);
}

.sw-sp-next-lesson__btn--cancel {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sw-sp-next-lesson__btn--cancel:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ==========================================================================
   10. IMMERSIVE LAYOUT — 2-Column Grid (Player + Playlist Sidebar)
   Desktop: 2fr 1fr | Mobile: single column
   ========================================================================== */

.sw-immersive-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  width: 100%;
}

@media (min-width: 992px) {
  .sw-immersive-layout {
    grid-template-columns: 360px 1fr 360px;
    grid-template-rows: auto;
    gap: 0;
    align-items: stretch;
    background: var(--ly-player-bg, #f8f9fb);
    border: none;
    border-radius: 0;
    padding: 0;
    min-height: calc(100vh - 56px);
  }

  /* Ensure all columns start at the same top edge */
  .sw-immersive-playlist-col,
  .sw-immersive-player-col,
  .sw-immersive-info-col {
    margin-top: 0 !important;
    padding-top: 0;
    align-self: stretch;
  }

  /* Left column: dark branded sidebar, full height, no border radius */
  .sw-immersive-playlist-col {
    max-height: calc(100vh - 56px);
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--pl-border, rgba(255, 255, 255, 0.06));
  }

  .sw-immersive-player-col {
    border-radius: 0;
    border: none;
    overflow: hidden;
    overflow-y: auto;
    background: var(--ly-player-bg, #f8f9fb);
    padding: 0;
  }

  .sw-immersive-info-col {
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--ly-info-border, rgba(0, 0, 0, 0.08));
    padding: 0;
    background: var(--ly-info-bg, #fff);
  }
}

@media (min-width: 1400px) {
  .sw-immersive-layout {
    grid-template-columns: 380px 1fr 400px;
  }
}

/* Player column */
.sw-immersive-player-col {
  min-width: 0;
  position: relative;
}

/* Info sidebar (right column) */
.sw-immersive-info-col {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Playlist sidebar column — flex layout: header + scrollable list */
.sw-immersive-playlist-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--pl-bg, #0f1b3d);
  position: relative;
  color: var(--pl-text, #e2e8f0);
}

/* Scroll fade indicators — top and bottom shadows */
.sw-immersive-playlist-col .sw-playlist-list {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--pl-scrollbar, rgba(255,255,255,0.15)) transparent;
  position: relative;
}

.sw-immersive-playlist-col .sw-playlist-list::-webkit-scrollbar {
  width: 4px;
}

.sw-immersive-playlist-col .sw-playlist-list::-webkit-scrollbar-thumb {
  background: var(--pl-scrollbar, rgba(255,255,255,0.15));
  border-radius: 2px;
}

.sw-immersive-playlist-col .sw-playlist-list::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 991.98px) {
  .sw-immersive-layout {
    max-width: 100vw;
  }

  .sw-immersive-playlist-col {
    max-height: none;
    overflow-y: visible;
    padding: 12px 0;
    border: none;
    border-radius: 0;
    order: 2;
  }

  /* Mobile: player sticky */
  .sw-immersive-player-col {
    position: sticky;
    top: 62px;
    z-index: 100;
    background: var(--iq-body-bg, #141414);
    order: 1;
  }

  /* Lesson detail compact below player */
  .sw-immersive-player-col .sw-lesson-detail {
    padding: 10px 16px;
  }

  .sw-immersive-player-col .sw-lesson-detail__desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 0.82rem;
    line-height: 1.4;
    margin: 4px 0 0;
    color: rgba(255, 255, 255, 0.75);
  }

  .sw-immersive-player-col .sw-lesson-detail__desc.expanded {
    -webkit-line-clamp: unset;
    overflow: visible;
  }

  .sw-lesson-detail__toggle {
    display: inline-block;
    background: none;
    border: none;
    color: var(--iq-primary, #3b82f6);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 2px 0;
    cursor: pointer;
  }

  .sw-lesson-detail__toggle:hover {
    text-decoration: underline;
  }

  /* Info col on mobile: full-width vertical layout */
  .sw-immersive-info-col {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    padding: 0;
    order: 3;
    max-height: none;
    overflow-y: visible;
  }
}

/* Course info bar — compact strip between player zone and full info */
.sw-course-info-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 12px 0;
  margin-top: 1rem;
  border-top: 1px solid rgba(128, 128, 128, 0.1);
  border-bottom: 1px solid rgba(128, 128, 128, 0.1);
  flex-wrap: wrap;
}

.sw-course-info-bar .course-instructor-card {
  margin: 0;
}

.sw-course-info-bar .course-instructor-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.sw-course-info-bar .course-instructor-avatar img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.sw-course-info-bar .course-instructor-info {
  display: flex;
  flex-direction: column;
}

.sw-course-info-bar .course-instructor-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  opacity: 0.6;
  font-family: 'Poppins', sans-serif;
}

.sw-course-info-bar .course-instructor-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--iq-body-text, #1d1d1f);
  font-family: 'Poppins', sans-serif;
}

/* Playlist header */
.sw-playlist-header {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sw-playlist-header h6 {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Playlist thumbnail */
.sw-playlist-thumb {
  position: relative;
  flex-shrink: 0;
  width: 100px;
  height: 56px;
  border-radius: 6px;
  overflow: hidden;
  background: rgba(128, 128, 128, 0.08);
}

.sw-playlist-thumb__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.sw-playlist-thumb__placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.25;
  font-size: 1.1rem;
}

.sw-playlist-thumb__duration {
  position: absolute;
  bottom: 3px;
  right: 3px;
  font-size: 0.6rem;
  font-weight: 600;
  font-family: 'Poppins', sans-serif;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 1px 4px;
  border-radius: 3px;
  line-height: 1.3;
}

.sw-playlist-thumb__num {
  position: absolute;
  top: 3px;
  left: 3px;
  font-size: 0.6rem;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 3px;
  line-height: 1;
}

/* Playlist item progress bar (watch progress) — bottom of item, offset from left border */
.sw-playlist-progress {
  position: absolute;
  bottom: 0;
  left: 3px;
  right: 0;
  height: 2px;
  background: rgba(128, 128, 128, 0.08);
}

.sw-playlist-progress__bar {
  height: 100%;
  background: var(--iq-brand-color-1, #003399);
  opacity: 0.5;
  transition: width 300ms ease;
}

/* Playlist items — add position relative for progress bar */
.sw-playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 180ms ease;
  font-family: 'Poppins', sans-serif;
  position: relative;
}

.sw-playlist-item:hover {
  background: rgba(128, 128, 128, 0.05);
}

.sw-playlist-item--active {
  border-left-color: var(--iq-brand-color-1, #003399);
  background: color-mix(in srgb, var(--iq-brand-color-1, #003399) 5%, transparent);
}

.sw-playlist-item--disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.sw-playlist-item--completed .sw-playlist-status {
  color: #22c55e;
}

/* Playlist item parts */
.sw-playlist-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.4;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sw-playlist-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sw-playlist-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--iq-body-text, #1d1d1f);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sw-playlist-meta {
  font-size: 0.68rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.5;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sw-playlist-status {
  flex-shrink: 0;
  font-size: 0.85rem;
  color: var(--iq-body-text, #1d1d1f);
  opacity: 0.4;
}

/* Quiz badge in playlist */
.sw-quiz-badge {
  color: var(--iq-brand-color-1, #003399);
  font-size: 0.7rem;
  cursor: pointer;
  transition: transform 150ms ease;
}

.sw-quiz-badge:hover {
  transform: scale(1.2);
}

.sw-quiz-badge--completed,
.sw-quiz-badge--done {
  color: #22c55e;
}

.sw-quiz-badge--active {
  animation: quizBadgePulse 1.5s ease-in-out infinite;
}

@keyframes quizBadgePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

/* ==========================================================================
   11. LESSON INFO AREA — now-playing indicator
   Desktop: overlay inside player-col (absolute), auto-hides after 3s, reveals on hover
   Mobile: static below player, normal document flow
   ========================================================================== */

/* Player column needs position relative for the overlay */

.sw-lesson-info {
  display: none !important;
}
  left: 12px;
  z-index: 11;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  border-radius: 6px;
  transition: opacity 300ms ease;
  opacity: 0;
  pointer-events: none;
}

.sw-lesson-info:empty {
  display: none;
}

/* Show on player-col hover or when explicitly visible */
.sw-immersive-player-col:hover .sw-lesson-info:not(:empty),
.sw-lesson-info--visible {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile: below the player, not overlaid */
@media (max-width: 991.98px) {
  .sw-lesson-info {
    position: static;
    bottom: auto;
    left: auto;
    z-index: auto;
    padding: 10px 14px;
    background: transparent;
    backdrop-filter: none;
    border-radius: 0;
    opacity: 1;
    pointer-events: auto;
    border-bottom: 1px solid rgba(128, 128, 128, 0.08);
  }

  .sw-lesson-info,
  .sw-lesson-info *,
  .sw-lesson-info__now-playing,
  .sw-lesson-info__now-playing *,
  .sw-lesson-info__order,
  .sw-lesson-info__duration {
    color: #1d1d1f !important;
    color: var(--iq-body-text, #1d1d1f) !important;
  }

  .sw-lesson-info__quiz-btn {
    color: var(--iq-body-text, #1d1d1f) !important;
    border-color: rgba(128, 128, 128, 0.25) !important;
    background: rgba(128, 128, 128, 0.08) !important;
  }
}

.sw-lesson-info__now-playing {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.sw-lesson-info__order {
  font-weight: 700;
  opacity: 0.6;
}

.sw-lesson-info__sep {
  opacity: 0.4;
  margin: 0 2px;
}

.sw-lesson-info__duration {
  font-size: 0.7rem;
  opacity: 0.6;
}

/* "Quiz" button inside lesson info overlay */
.sw-lesson-info__quiz-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  padding: 4px 10px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  cursor: pointer;
  transition: all 150ms ease;
  vertical-align: middle;
}

.sw-lesson-info__quiz-btn:hover {
  background: rgba(251, 191, 36, 0.3);
  color: #fff;
}

/* ==========================================================================
   11b. RESTART PROMPT — "Already watched" overlay with restart/resume buttons
   ========================================================================== */

.sw-sp-restart-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.85);
  z-index: 15;
  border-radius: 8px;
}

.sw-sp-restart-prompt__inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.sw-sp-restart-prompt__text {
  font-family: 'Poppins', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: #e2e8f0;
  margin: 0;
}

.sw-sp-restart-prompt__actions {
  display: flex;
  gap: 12px;
}

.sw-sp-restart-prompt__btn {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 150ms ease;
}

.sw-sp-restart-prompt__btn--restart {
  background: var(--iq-brand-color-1, #003399);
  color: #fff;
}

.sw-sp-restart-prompt__btn--restart:hover {
  filter: brightness(1.2);
}

.sw-sp-restart-prompt__btn--next {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.sw-sp-restart-prompt__btn--next:hover {
  background: rgba(34, 197, 94, 0.25);
}

.sw-sp-restart-prompt__btn--quiz {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.sw-sp-restart-prompt__btn--quiz:hover {
  background: rgba(251, 191, 36, 0.25);
}

.sw-sp-restart-prompt__btn--resume {
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.sw-sp-restart-prompt__btn--resume:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ==========================================================================
   12. RESPONSIVE — Mobile & Tablet (<992px)
   Requirement 9.9: Quiz overlay occupies full player container on mobile
   Requirement 7.1, 7.2: player responsive, touch-friendly
   ========================================================================== */

@media (max-width: 991.98px) {
  /* Quiz overlay: full container, allow scroll for long answers */
  #sw-sp-quiz-overlay,
  .sw-sp-quiz-overlay {
    padding: 0;
  }

  .sw-sp-quiz-header {
    padding: 10px 14px;
  }

  .sw-sp-quiz-content {
    padding: 14px;
    justify-content: flex-start;
    overflow-y: auto;
  }

  .sw-sp-quiz-content > * {
    max-width: 100%;
  }

  /* Next lesson CTA: centered on mobile */
  .sw-sp-next-lesson {
    left: 12px;
    right: 12px;
    bottom: 14px;
    transform: none;
    border-radius: 10px;
    padding: 14px 16px;
  }

  .sw-sp-next-lesson__title {
    max-width: 180px;
  }

  /* Playlist items slightly larger touch targets */
  .sw-playlist-item {
    padding: 12px 14px;
    min-height: 48px;
  }
}

/* Small mobile (<576px) */
@media (max-width: 575.98px) {
  .sw-sp-quiz-content {
    padding: 10px;
  }

  .sw-sp-next-lesson {
    flex-wrap: wrap;
    gap: 8px;
  }

  .sw-sp-next-lesson__actions {
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
  }
}

/* ==========================================================================
   13. REDUCED MOTION — Respect user preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .sw-sp-loading__spinner {
    animation-duration: 1.5s;
  }

  .sw-sp-next-lesson {
    animation: none;
  }

  .sw-quiz-badge--active {
    animation: none;
  }

  @keyframes swSpSlideIn {
    from { opacity: 1; transform: translateX(-50%); }
    to { opacity: 1; transform: translateX(-50%); }
  }
}

/* ==========================================================================
   14. PLYR OVERRIDES — Ensure Plyr fits correctly inside singleton container
   ========================================================================== */

#sw-singleton-player .plyr {
  width: 100%;
  height: 100%;
  border-radius: 0;
}

#sw-singleton-player .plyr__video-wrapper {
  height: 100%;
}

#sw-singleton-player .plyr--video {
  height: 100%;
}


/* ==========================================================================
   15. COURSE DETAILS — Collapsible <details> section
   ========================================================================== */

.sw-course-details {
  border: 1px solid rgba(128, 128, 128, 0.12);
  border-radius: 8px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.sw-course-details__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-family: 'Poppins', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--iq-body-text, #1d1d1f);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 150ms ease;
}

.sw-course-details__summary:hover {
  background: rgba(128, 128, 128, 0.04);
}

.sw-course-details__summary::-webkit-details-marker {
  display: none;
}

.sw-course-details__icon {
  font-size: 0.7rem;
  transition: transform 200ms ease;
}

.sw-course-details[open] .sw-course-details__icon {
  transform: rotate(180deg);
}

.sw-course-details__content {
  padding: 0 16px 16px;
}

/* Module chip active state */
.sw-module-chip--active {
  opacity: 1 !important;
  font-weight: 700 !important;
  background: color-mix(in srgb, var(--iq-brand-color-1, #003399) 12%, transparent) !important;
  border-color: color-mix(in srgb, var(--iq-brand-color-1, #003399) 25%, transparent) !important;
}

/* Course info section within left column */
.sw-course-info-section {
  padding-bottom: 1rem;
}

/* ==========================================================================
   16. FULL-BLEED OVERRIDES — Ensure course page is edge-to-edge
   ========================================================================== */

/* Remove padding from parent containers on course detail page */
#lessons.movie-detail {
  padding: 0 !important;
  margin: 0 !important;
  max-width: 100vw !important;
}

/* Override Bootstrap container-fluid padding for immersive layout */
.container-fluid:has(.sw-immersive-layout) {
  padding-left: 0 !important;
  padding-right: 0 !important;
  max-width: 100% !important;
}

/* Override main-content margin for course detail */
.main-content:has(.sw-immersive-layout) {
  margin-top: 0 !important;
  padding: 0 !important;
}

.main-content.sw-immersive-page {
  margin-top: 0 !important;
  padding: 0 !important;
  background: var(--iq-primary-bg, #0F1C3F);
  min-height: 100vh;
}

/* Remove footer margin-top on immersive course pages */
.main-content.sw-immersive-page ~ .footer-main {
  margin-top: 0 !important;
}

body:has(.sw-immersive-page) .footer-main {
  margin-top: 0 !important;
}

/* Override any body padding set by the theme */
body:has(.sw-immersive-layout) #content-page,
body:has(.sw-immersive-layout) .content-page,
.content-page:has(.sw-immersive-page) {
  padding: 0 !important;
  margin-left: 0 !important;
  width: 100% !important;
}

/* Navbar full width on immersive course page */
body:has(.sw-immersive-layout) .iq-top-navbar {
  width: 100% !important;
  left: 0 !important;
}

/* Fallback: hide sidebar on immersive page */
body:has(.sw-immersive-layout) .iq-sidebar,
body:has(.sw-immersive-layout) #iq-sidebar {
  display: none !important;
}

/* Mobile: page-level overrides for immersive course */
@media (max-width: 991.98px) {
  .sw-immersive-page .container-fluid {
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
}
