/* CSS Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

html, body {
  height: 100%;
}

body {
  font-family: Arial, sans-serif;
  -webkit-user-drag: none;
  -khtml-user-drag: none;
  -moz-user-drag: none;
  -o-user-drag: none;
}

body.no-scroll {
  overflow: hidden;
}

/* Loading Screen */
#loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  color: black;
  font-size: 24px;
  z-index: 9999;
}

.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid #3498db;
  border-radius: 50%;
  width: 100px;
  height: 100px;
  animation: spin 2s linear infinite;
  margin-bottom: 20px;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ---- App Layout ---- */

.hidden {
  display: none !important;
}

#app {
  display: block;
  min-height: 100vh;
  background-color: #fafafa;
}

/* ---- Header ---- */

.header {
  background-color: #ffffff;
  padding: 40px 60px;
  border-bottom: 1px solid #e0e0e0;
}

.logo {
  font-size: 48px;
  font-weight: bold;
  color: #1a1a2e;
  letter-spacing: 2px;
}

/* ---- Lessons Container ---- */

.lessons-container {
  padding: 40px 60px;
}

/* ---- Lesson Row (Each lesson group) ---- */

.lesson-row {
  margin-bottom: 60px;
}

.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 12px;
  border-bottom: 3px solid #3498db;
}

.lesson-date {
  font-size: 28px;
  font-weight: bold;
  color: #1a1a2e;
}

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

.lesson-period-badge {
  background-color: #e8f4fc;
  color: #2980b9;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
}

.lesson-badge {
  background-color: #3498db;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
}

/* ---- Parts Container (Horizontal scroll like Netflix) ---- */

.parts-container {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  padding: 20px 40px 20px 24px;
  scroll-behavior: smooth;
}

.parts-container::-webkit-scrollbar {
  height: 8px;
}

.parts-container::-webkit-scrollbar-track {
  background: #e0e0e0;
  border-radius: 4px;
}

.parts-container::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 4px;
}

/* ---- Part Card ---- */

.part-card {
  flex-shrink: 0;
  width: 400px;
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  overflow: hidden;
  border: 2px solid transparent;
}

.part-card:hover,
.part-card:focus {
  transform: scale(1.05);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
  border-color: #3498db;
  outline: none;
}

.part-card:hover .part-card-thumbnail::after,
.part-card:focus .part-card-thumbnail::after {
  transform: scale(1.2);
}

.part-card-thumbnail {
  width: 100%;
  height: 200px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.part-card-thumbnail::after {
  content: '▶';
  font-size: 60px;
  color: rgba(255, 255, 255, 0.9);
  transition: transform 0.3s ease;
}

.part-card:hover .part-card-thumbnail::after {
  transform: scale(1.2);
}

.part-number {
  position: absolute;
  top: 12px;
  left: 12px;
  background-color: #3498db;
  color: white;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.part-card-content {
  padding: 24px;
}

.part-card-title {
  font-size: 22px;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 12px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.part-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 18px;
  color: #666;
}

.part-card-duration {
  display: flex;
  align-items: center;
  gap: 8px;
}

.part-card-duration::before {
  content: '⏱';
}

/* ---- Mobile Responsive ---- */

@media (max-width: 480px) {
  .header {
    padding: 16px 20px;
  }

  .logo {
    font-size: 24px;
    letter-spacing: 1px;
  }

  .lessons-container {
    padding: 16px 16px;
  }

  .lesson-row {
    margin-bottom: 32px;
  }

  .lesson-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
    padding-bottom: 8px;
  }

  .lesson-date {
    font-size: 18px;
    margin-right: 0;
  }

  .lesson-badges {
    gap: 8px;
  }

  .lesson-period-badge {
    font-size: 14px;
    padding: 4px 8px;
  }

  .lesson-badge {
    font-size: 12px;
    padding: 4px 10px;
  }

  .parts-container {
    gap: 12px;
    padding: 12px 20px 12px 12px;
  }

  .part-card {
    width: 260px;
    border-radius: 12px;
  }

  .part-card:hover,
  .part-card:focus {
    transform: scale(1.02);
  }

  .part-card-thumbnail {
    height: 140px;
  }

  .part-card-thumbnail::after {
    font-size: 40px;
  }

  .part-number {
    top: 10px;
    left: 10px;
    font-size: 12px;
    padding: 4px 10px;
  }

  .part-card-content {
    padding: 14px;
  }

  .part-card-title {
    font-size: 14px;
    margin-bottom: 8px;
  }

  .part-card-meta {
    font-size: 12px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .spinner {
    width: 60px;
    height: 60px;
  }

  #loading {
    font-size: 16px;
  }

  .video-close {
    top: 16px;
    right: 16px;
    font-size: 24px;
    width: 44px;
    height: 44px;
  }

  .video-loading {
    font-size: 16px;
  }

  .video-loading .spinner {
    width: 60px;
    height: 60px;
  }

  .error-alert-content {
    padding: 24px 20px;
    margin: 16px;
    max-width: calc(100% - 32px);
    border-radius: 12px;
  }

  .error-alert-icon {
    font-size: 40px;
    margin-bottom: 12px;
  }

  .error-alert-message {
    font-size: 16px;
    margin-bottom: 20px;
  }

  .error-alert-close {
    padding: 12px 28px;
    font-size: 14px;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .header {
    padding: 24px 32px;
  }

  .logo {
    font-size: 32px;
  }

  .lessons-container {
    padding: 24px 32px;
  }

  .lesson-row {
    margin-bottom: 40px;
  }

  .lesson-header {
    margin-bottom: 20px;
  }

  .lesson-date {
    font-size: 22px;
  }

  .lesson-badges {
    gap: 10px;
  }

  .lesson-period-badge {
    font-size: 16px;
    padding: 5px 10px;
  }

  .lesson-badge {
    font-size: 14px;
    padding: 6px 12px;
  }

  .parts-container {
    gap: 16px;
    padding: 16px 32px 16px 16px;
  }

  .part-card {
    width: 320px;
  }

  .part-card-thumbnail {
    height: 160px;
  }

  .part-card-thumbnail::after {
    font-size: 50px;
  }

  .part-number {
    font-size: 14px;
    padding: 6px 12px;
  }

  .part-card-content {
    padding: 18px;
  }

  .part-card-title {
    font-size: 18px;
  }

  .part-card-meta {
    font-size: 14px;
  }

  .spinner {
    width: 80px;
    height: 80px;
  }

  #loading {
    font-size: 20px;
  }

  .video-close {
    top: 20px;
    right: 24px;
    font-size: 32px;
    width: 56px;
    height: 56px;
  }

  .video-loading {
    font-size: 20px;
  }

  .error-alert-content {
    padding: 32px 40px;
    max-width: 500px;
  }

  .error-alert-icon {
    font-size: 50px;
  }

  .error-alert-message {
    font-size: 20px;
  }

  .error-alert-close {
    padding: 14px 32px;
    font-size: 16px;
  }
}

/* ---- TV Focus (Large Screens) ---- */

@media (min-width: 1920px) {
  .header {
    padding: 60px 100px;
  }

  .logo {
    font-size: 64px;
  }

  .lessons-container {
    padding: 60px 100px;
  }

  .lesson-date {
    font-size: 36px;
  }

  .lesson-badges {
    gap: 16px;
  }

  .lesson-period-badge {
    font-size: 24px;
    padding: 8px 16px;
  }

  .lesson-badge {
    font-size: 22px;
    padding: 10px 20px;
  }

  .part-card {
    width: 500px;
  }

  .part-card-thumbnail {
    height: 250px;
  }

  .part-card-thumbnail::after {
    font-size: 80px;
  }

  .part-number {
    font-size: 22px;
    padding: 10px 20px;
  }

  .part-card-content {
    padding: 32px;
  }

  .part-card-title {
    font-size: 28px;
  }

  .part-card-meta {
    font-size: 22px;
  }

  .parts-container {
    gap: 32px;
    padding: 20px 60px 20px 40px;
  }
}

@media (min-width: 2560px) {
  .header {
    padding: 80px 140px;
  }

  .logo {
    font-size: 80px;
  }

  .lessons-container {
    padding: 80px 140px;
  }

  .lesson-date {
    font-size: 44px;
  }

  .lesson-badges {
    gap: 20px;
  }

  .lesson-period-badge {
    font-size: 28px;
    padding: 10px 20px;
  }

  .lesson-badge {
    font-size: 26px;
    padding: 12px 24px;
  }

  .part-card {
    width: 600px;
  }

  .part-card-thumbnail {
    height: 300px;
  }

  .part-card-thumbnail::after {
    font-size: 100px;
  }

  .part-number {
    font-size: 26px;
    padding: 12px 24px;
  }

  .part-card-content {
    padding: 40px;
  }

  .part-card-title {
    font-size: 34px;
  }

  .part-card-meta {
    font-size: 26px;
  }

  .parts-container {
    gap: 40px;
    padding: 20px 80px 20px 60px;
  }
}

/* ---- Video Player Fullscreen ---- */

.video-player {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #000;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-player.hidden {
  display: none;
}

.video-player video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000;
}

.video-close {
  position: absolute;
  top: 30px;
  right: 40px;
  background-color: rgba(255, 255, 255, 0.1);
  border: none;
  color: white;
  font-size: 40px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10001;
  transition: background-color 0.3s ease, transform 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-close:hover,
.video-close:focus {
  background-color: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
  outline: none;
}

.video-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  color: white;
  font-size: 24px;
  z-index: 10002;
}

.video-loading.hidden {
  display: none;
}

/* ---- Video Player TV Responsive ---- */

@media (min-width: 1920px) {
  .video-close {
    top: 50px;
    right: 60px;
    font-size: 50px;
    width: 90px;
    height: 90px;
  }

  .video-loading {
    font-size: 32px;
  }

  .video-loading .spinner {
    width: 120px;
    height: 120px;
  }
}

@media (min-width: 2560px) {
  .video-close {
    top: 70px;
    right: 80px;
    font-size: 60px;
    width: 110px;
    height: 110px;
  }

  .video-loading {
    font-size: 40px;
  }

  .video-loading .spinner {
    width: 150px;
    height: 150px;
  }
}

/* ---- Error Alert ---- */

.error-alert {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
}

.error-alert.hidden {
  display: none;
}

.error-alert-content {
  background-color: #ffffff;
  padding: 40px 60px;
  border-radius: 16px;
  text-align: center;
  max-width: 600px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.error-alert-icon {
  font-size: 60px;
  color: #e74c3c;
  display: block;
  margin-bottom: 20px;
}

.error-alert-message {
  font-size: 24px;
  color: #1a1a2e;
  margin-bottom: 30px;
  line-height: 1.4;
}

.error-alert-close {
  background-color: #3498db;
  color: white;
  border: none;
  padding: 16px 40px;
  font-size: 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.3s ease;
}

.error-alert-close:hover,
.error-alert-close:focus {
  background-color: #2980b9;
  transform: scale(1.05);
  outline: none;
}

/* ---- Error Alert TV Responsive ---- */

@media (min-width: 1920px) {
  .error-alert-content {
    padding: 60px 80px;
    max-width: 800px;
  }

  .error-alert-icon {
    font-size: 80px;
  }

  .error-alert-message {
    font-size: 32px;
  }

  .error-alert-close {
    padding: 20px 50px;
    font-size: 26px;
  }
}

@media (min-width: 2560px) {
  .error-alert-content {
    padding: 80px 100px;
    max-width: 1000px;
  }

  .error-alert-icon {
    font-size: 100px;
  }

  .error-alert-message {
    font-size: 40px;
  }

  .error-alert-close {
    padding: 24px 60px;
    font-size: 32px;
  }
}
