/**
 * CoursePlayer v3 스타일
 * 강좌 플레이어 UI 디자인
 */

/* =============================================
   플레이어 메인 컨테이너
   ============================================= */
.course-player {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #f5f5f5;
}

/* =============================================
   헤더
   ============================================= */
.course-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #d6edf7 0%, #99ceeb 100%);
  color: #1f607f;
  padding: 10px 20px;
  border-radius: 8px;
  margin-bottom: 0px;
}

.course-title h1 {
  font-size: 28px;
  font-weight: 600;
  margin: 0 0 5px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.course-title h1 i {
  font-size: 32px;
}

.course-title p {
  margin: 5px 0 0 0;
  font-size: 14px;
  opacity: 0.9;
  color: #878787;
}

.user-info {
  background-color: rgba(255, 255, 255, 0.2);
  padding: 8px 15px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
}

/* =============================================
   메인 컨텐츠 레이아웃
   ============================================= */
.course-main {
  display: flex;
  gap: 0px;
  flex: 1;
  padding: 0 0px 20px 0px;
  flex-direction: row-reverse;
}

/* =============================================
   사이드바: 챕터 네비게이션
   ============================================= */
.course-sidebar {
  width: 280px;
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); */
  height: fit-content;
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.course-sidebar::-webkit-scrollbar {
  width: 6px;
}

.course-sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.course-sidebar::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 3px;
}

.chapter-nav h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 15px 0;
  color: #333;
  border-bottom: 2px solid #e0e0e0;
  padding-bottom: 10px;
}

.chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.chapter-item {
  margin-bottom: 5px;
}

.chapter-link {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0px 12px;
  border-radius: 6px;
  transition: all 0.25s ease;
  color: #333;
  text-decoration: none;
  border-left: 3px solid transparent;
}

.chapter-link:hover {
  background-color: #f0f0f0;
  border-left-color: #667eea;
}

.chapter-item.active > .chapter-link {
  background-color: #f0f0f0;
  border-left-color: #1f607f;
  color: #1f607f;
  font-weight: 600;
}

.chapter-num {
  display: inline-block;
  min-width: 50px;
  font-size: 13px;
  color: #999;
  font-weight: 600;
  text-align: left;
}

.chapter-name {
  flex: 1;
  font-size: 14px;
  line-height: 1.4;
}

/* =============================================
   섹션 서브 메뉴
   ============================================= */
.section-list {
  list-style: none;
  padding: 2px 0 2px 0;
  margin: 2px 0 0 0;
}

.section-item {
  margin: 0px 0;
}

.section-item a {
  display: block;
  padding: 0px 12px 0px 36px;
  border-radius: 4px;
  font-size: 14px;
  color: #666;
  text-decoration: none;
  transition: all 0.25s ease;
  position: relative;
}

.section-item a:hover {
  background-color: #f9f9f9;
  color: #333;
}

.section-item.active a {
  background-color: #e8eaf6;
  color: #0093bd;
  font-weight: 600;
}

/* =============================================
   년도별 서브 메뉴
   ============================================= */
.year-list {
  list-style: none;
  padding: 0px 0 0px 40px;
  margin: 0px 0 0 0;
  border-left: 2px solid #e0e0e0;
}

.year-item {
  margin: 3px 0;
}

.year-item a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: #888;
  text-decoration: none;
  transition: all 0.25s ease;
}

.year-item a:hover {
  background-color: #f5f5f5;
  color: #555;
}

.year-item.active a {
  background-color: #fff3e0;
  color: #ff9800;
  font-weight: 600;
}

.revision {
  display: inline-block;
  font-size: 9px;
  background-color: #ff9800;
  color: white;
  padding: 0px 5px;
  border-radius: 3px;
}

/* =============================================
   메인 컨텐츠 영역
   ============================================= */
.course-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.content-area {
  flex: 1;
  background-color: white;
  border-radius: 8px;
  padding: 40px 30px;
  /* box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); */
  overflow-y: auto;
  line-height: 1.8;
  color: #333;
  margin-bottom: 20px;
}

.content-area::-webkit-scrollbar {
  width: 8px;
}

.content-area::-webkit-scrollbar-track {
  background: transparent;
}

.content-area::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

.content-area::-webkit-scrollbar-thumb:hover {
  background: #999;
}

/* =============================================
   챕터 헤더 (콘텐츠 제목)
   ============================================= */
.chapter-header {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 2px solid #e0e0e0;
}

.chapter-header h2 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 10px 0;
  color: #333;
}

.breadcrumb {
  font-size: 13px;
  color: #999;
  margin: 10px 0 0 0;
}

.breadcrumb i {
  font-size: 10px;
  margin: 0 8px;
}

.year-badge {
  display: inline-block;
  background-color: #4caf50;
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  margin: 8px 0 0 0;
}

.view-mode-badge {
  display: inline-block;
  background-color: #667eea;
  color: white;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  margin: 8px 0 0 0;
}

.chapter-description {
  margin: 10px 0 0 0;
  font-size: 14px;
  color: #666;
}

/* =============================================
   콘텐츠 마크다운 스타일
   ============================================= */
.content-area h2,
.content-area .md-h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 30px 0 15px 0;
  color: #333;
  border-left: 4px solid #1f607f;
  padding-left: 15px;
}

.content-area h3,
.content-area .md-h2 {
  font-size: 20px;
  font-weight: 600;
  margin: 25px 0 12px 0;
  color: #444;
  border-left: 3px solid #2f7fa6;
  padding-left: 12px;
}

.content-area h4,
.content-area .md-h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 20px 0 10px 0;
  color: #555;
}

.content-area p {
  margin: 0 0 15px 0;
  line-height: 1.8;
  color: #333;
}

.content-area strong {
  font-weight: 600;
  color: #333;
}

.content-area em {
  font-style: italic;
  color: #666;
}

.content-area code {
  background-color: #f5f5f5;
  border: 1px solid #ddd;
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  color: #d63384;
}

.content-area pre {
  background-color: #1e1e1e;
  color: #d4d4d4;
  padding: 15px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 15px 0;
  line-height: 1.5;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  border: 1px solid #333;
}

.content-area pre code {
  background-color: transparent;
  border: none;
  padding: 0;
  color: inherit;
}

/* =============================================
   테이블
   ============================================= */
.content-area table,
.content-area .content-table,
#course-content table {
  width: 100% !important;
  border-collapse: collapse !important;
  margin: 20px 0 !important;
  background-color: white !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05) !important;
  font-size: 14px !important;
}

/* 모든 셀 기본 스타일 - 흰색 */
.content-area table td,
.content-area table th,
#course-content table td,
#course-content table th {
  padding: 12px 15px !important;
  border: 1px solid #e0e0e0 !important;
  background-color: white !important;
  color: #333 !important;
  font-weight: normal !important;
}

/* 첫 번째 행만 파란색 헤더 */
.content-area table tr:first-child td,
.content-area table tr:first-child th,
#course-content table tr:first-child td,
#course-content table tr:first-child th {
  background-color: #667eea !important;
  color: white !important;
  font-weight: bold !important;
  border: 1px solid #5568d3 !important;
}

/* tbody가 있는 경우 - 첫 번째 행만 파란색 */
.content-area table tbody tr:first-child td,
.content-area table tbody tr:first-child th,
#course-content table tbody tr:first-child td,
#course-content table tbody tr:first-child th {
  background-color: #667eea !important;
  color: white !important;
  font-weight: bold !important;
  border: 1px solid #5568d3 !important;
}

/* 2번째 행부터는 흰색/회색 교차 */
.content-area table tr:nth-child(even):not(:first-child) td,
.content-area table tr:nth-child(even):not(:first-child) th,
#course-content table tr:nth-child(even):not(:first-child) td,
#course-content table tr:nth-child(even):not(:first-child) th {
  background-color: #f9f9f9 !important;
}

.content-area table tbody tr:nth-child(even):not(:first-child) td,
.content-area table tbody tr:nth-child(even):not(:first-child) th,
#course-content table tbody tr:nth-child(even):not(:first-child) td,
#course-content table tbody tr:nth-child(even):not(:first-child) th {
  background-color: #f9f9f9 !important;
}

/* hover 효과 - 첫 행 제외 */
.content-area table tr:not(:first-child):hover td,
.content-area table tr:not(:first-child):hover th,
#course-content table tr:not(:first-child):hover td,
#course-content table tr:not(:first-child):hover th {
  background-color: #f1f1f1 !important;
}

/* thead가 있는 경우를 위한 추가 스타일 */
.content-area table thead tr,
.content-area table thead th,
#course-content table thead tr,
#course-content table thead th {
  background-color: #667eea !important;
  color: white !important;
  font-weight: bold !important;
  border: 1px solid #5568d3 !important;
}

/* =============================================
   리스트
   ============================================= */
.content-area ul,
.content-area ol {
  margin: 15px 0 15px 20px;
  padding-left: 20px;
}

.content-area li {
  margin-bottom: 8px;
  line-height: 1.8;
}

.content-area ul li {
  list-style-type: disc;
}

.content-area ol li {
  list-style-type: decimal;
}

.list-item {
  margin-bottom: 8px;
  line-height: 1.8;
}

/* =============================================
   블록 인용
   ============================================= */
.content-area blockquote {
  background-color: #f0f0f0;
  border-left: 4px solid #f0b020;
  padding: 15px 20px;
  margin: 15px 0;
  border-radius: 4px;
  font-style: italic;
  color: #666;
}

/* =============================================
   이미지
   ============================================= */
.content-area img,
.content-area .content-img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 20px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* =============================================
   링크
   ============================================= */
.content-area a {
  color: #667eea;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.25s ease;
}

.content-area a:hover {
  border-bottom-color: #667eea;
  color: #764ba2;
}

/* =============================================
   네비게이션 (이전/다음)
   ============================================= */
.content-navigation {
  margin-top: 20px;
}

.nav-buttons {
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
  background-color: white;
  border-radius: 8px;
  text-decoration: none;
  color: #333;
  font-weight: 500;
  transition: all 0.25s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  border: 2px solid transparent;
}

.nav-btn:hover {
  border-color: #667eea;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
  background-color: #f9f9f9;
}

.nav-btn.prev-btn {
  justify-content: flex-start;
}

.nav-btn.next-btn {
  justify-content: flex-end;
}

.nav-arrow {
  font-size: 20px;
  color: #667eea;
}

.nav-text {
  font-size: 13px;
  color: #666;
}

.nav-btn.disabled {
  opacity: 0;
  pointer-events: none;
}

/* =============================================
   에러 메시지
   ============================================= */
.error-message {
  background-color: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.error-message h3 {
  margin: 0 0 10px 0;
  color: #856404;
}

.error-message p {
  margin: 0;
  color: #856404;
  font-size: 14px;
}

/* =============================================
   반응형 디자인
   ============================================= */
@media (max-width: 1024px) {
  .course-main {
    flex-direction: column;
    gap: 15px;
  }

  .course-sidebar {
    width: 100%;
    position: relative;
    top: auto;
    max-height: none;
  }

  .chapter-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .chapter-item {
    margin-bottom: 0;
  }
}

@media (max-width: 768px) {
  .course-header {
    flex-direction: column;
    text-align: center;
    padding: 20px 15px;
  }

  .course-header h1 {
    font-size: 22px;
  }

  .course-title {
    width: 100%;
  }

  .user-info {
    margin-top: 15px;
  }

  .chapter-list {
    grid-template-columns: 1fr;
  }

  .content-area {
    padding: 20px 15px;
  }

  .nav-buttons {
    flex-direction: column;
  }

  .nav-btn {
    justify-content: center;
  }

  .course-main {
    padding: 0 15px 15px 15px;
  }
}

@media (max-width: 480px) {
  .course-header h1 {
    font-size: 18px;
  }

  .content-area {
    padding: 15px 10px;
  }

  .chapter-header h2 {
    font-size: 20px;
  }

  .content-area h3 {
    font-size: 16px;
  }
}
