/* ================================================================
   EduStream 공통 CSS v2.0 — 모바일 최적화 + DRM 보호
   ================================================================ */
:root {
  --bg-primary: #0f0e17;
  --bg-secondary: #1a1a2e;
  --bg-card: #1e1e2e;
  --bg-card-hover: #252540;
  --color-primary: #6c5ce7;
  --color-primary-light: #a29bfe;
  --color-pink: #fd79a8;
  --color-mint: #00cec9;
  --color-gold: #fdcb6e;
  --color-green: #00b894;
  --text-primary: #e0e0e0;
  --text-secondary: #a0a0b0;
  --text-muted: #666680;
  --border-color: #2e2e4a;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
  --radius: 12px;
  --radius-sm: 8px;
  /* 모바일 터치 피드백 */
  --tap-highlight: rgba(108,92,231,0.12);
}

/* ── 기본 리셋 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  /* 모바일 터치 최적화 */
  -webkit-tap-highlight-color: var(--tap-highlight);
  touch-action: pan-y;
  overscroll-behavior: contain;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
button { font-family: inherit; cursor: pointer; }

/* ── 스크롤바 ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--color-primary); border-radius: 3px; }

/* ── 선택 방지 (DRM 보호 강화) ── */
.no-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ── 헤더 ── */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(15,14,23,0.97);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 20px;
}

.header-logo {
  font-size: 1.3rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--color-primary), var(--color-pink));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  /* 모바일: 최소 터치 영역 */
  min-height: 44px;
  display: flex;
  align-items: center;
}

.header-nav { display: flex; gap: 4px; flex: 1; }
.header-nav a {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all 0.2s;
  white-space: nowrap;
  min-height: 36px;
  display: flex;
  align-items: center;
}
.header-nav a:hover, .header-nav a.active {
  background: var(--bg-card);
  color: var(--text-primary);
}

.header-right { margin-left: auto; position: relative; flex-shrink: 0; }

/* 햄버거 메뉴 (모바일) */
.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 1.2rem;
  padding: 8px;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.mobile-menu-btn:hover { background: var(--bg-card); }

.mobile-nav {
  display: none;
  position: fixed;
  top: 60px; left: 0; right: 0;
  background: rgba(15,14,23,0.98);
  border-bottom: 1px solid var(--border-color);
  padding: 12px 0;
  z-index: 999;
  backdrop-filter: blur(12px);
  animation: slideDown 0.2s ease;
}
.mobile-nav.open { display: block; }
.mobile-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  color: var(--text-secondary);
  font-size: 0.95rem;
  transition: all 0.15s;
  min-height: 50px;
  border-left: 3px solid transparent;
}
.mobile-nav a:hover, .mobile-nav a.active {
  background: rgba(108,92,231,0.08);
  color: var(--text-primary);
  border-left-color: var(--color-primary);
}

@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ── 유저 뱃지 ── */
.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.875rem;
  min-height: 40px;
}
.user-badge:hover { border-color: var(--color-primary); }

.user-avatar {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-pink));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700; color: white;
  flex-shrink: 0;
}

.user-dropdown {
  display: none;
  position: fixed;
  right: 16px;
  top: 68px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  min-width: 210px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 1001;
}
.user-dropdown.show { display: block; }
.dropdown-info { padding: 14px 16px; }
.dropdown-divider { height: 1px; background: var(--border-color); }
.dropdown-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all 0.15s;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  min-height: 48px; /* 모바일 최소 터치 영역 */
}
.dropdown-item:hover { background: var(--bg-secondary); color: var(--text-primary); }

/* ── 강좌 카드 ── */
.course-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.25s, border-color 0.25s, box-shadow 0.25s;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  /* 모바일 터치 피드백 */
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .course-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
    box-shadow: 0 8px 30px rgba(108,92,231,0.2);
  }
}
.course-card:active { transform: scale(0.98); }

.course-thumbnail {
  width: 100%;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.course-badge {
  position: absolute;
  top: 8px; left: 8px;
  padding: 3px 9px;
  border-radius: 50px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  pointer-events: none;
}
.badge-hot { background: #ff4757; color: white; }
.badge-new { background: var(--color-mint); color: #0f0e17; }
.badge-best { background: var(--color-gold); color: #0f0e17; }
.badge-free { background: var(--color-green); color: white; }

.course-body { padding: 14px; flex: 1; display: flex; flex-direction: column; }
.course-category { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 5px; }
.course-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 5px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.course-instructor { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 7px; }
.course-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.stars { color: var(--color-gold); font-size: 0.75rem; }
.course-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  flex-wrap: wrap;
  gap: 4px;
}
.course-price { font-size: 1rem; font-weight: 700; color: var(--color-primary-light); }
.price-free { color: var(--color-green); }

/* ── 버튼 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  min-height: 40px; /* 모바일 최소 터치 영역 */
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary { background: var(--color-primary); color: white; }
.btn-primary:hover { background: #5b4ed0; }
.btn-primary:active { transform: scale(0.97); }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-secondary); }
.btn-outline:hover { border-color: var(--color-primary); color: var(--color-primary-light); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; min-height: 34px; }
.btn-danger { background: #e74c3c; color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: var(--color-green); color: white; }
.btn-success:hover { background: #009975; }

/* ── 입력 폼 ── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 0.83rem; color: var(--text-secondary); margin-bottom: 5px; }
.form-input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 0.9rem;
  transition: border-color 0.2s;
  font-family: 'Noto Sans KR', sans-serif;
  /* iOS 확대 방지 */
  font-size: max(16px, 0.9rem);
  min-height: 44px;
}
.form-input:focus { outline: none; border-color: var(--color-primary); }
.form-input::placeholder { color: var(--text-muted); }
/* iOS 자동 스타일 제거 */
.form-input[type="date"],
.form-input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
}

/* ── 별점 ── */
.star-rating { display: flex; gap: 4px; cursor: pointer; }
.star-rating .star {
  font-size: 1.5rem; /* 모바일 터치 용이하게 크게 */
  color: var(--text-muted);
  transition: color 0.15s;
  cursor: pointer;
  padding: 2px;
  min-width: 36px;
  text-align: center;
}
.star-rating .star.active { color: var(--color-gold); }

/* ── 페이지네이션 ── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; flex-wrap: wrap; }
.page-btn {
  min-width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.85rem;
  padding: 0 8px;
}
.page-btn:hover { border-color: var(--color-primary); color: var(--color-primary-light); }
.page-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: white; }

/* ── 로딩 ── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  flex-direction: column;
  gap: 14px;
  color: var(--text-muted);
}
.spinner {
  width: 34px; height: 34px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── 스켈레톤 로딩 ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-secondary) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ── 토스트 ── */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 240px;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideInRight 0.3s ease;
  box-shadow: var(--shadow);
  font-size: 0.875rem;
}
.toast.success { border-left: 3px solid var(--color-green); }
.toast.error { border-left: 3px solid #e74c3c; }
.toast.info { border-left: 3px solid var(--color-primary); }
@keyframes slideInRight { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── 카테고리 컬러 ── */
.cat-programming { color: #a29bfe; }
.cat-design { color: #fd79a8; }
.cat-business { color: #fdcb6e; }
.cat-data { color: #55efc4; }
.cat-ai { color: #00cec9; }
.cat-mobile { color: #74b9ff; }

/* ── 레이아웃 ── */
.main-container { padding-top: 60px; min-height: 100vh; }
.section { padding: 60px 20px; max-width: 1200px; margin: 0 auto; }
.section-title { font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 800; margin-bottom: 6px; }
.section-subtitle { color: var(--text-secondary); margin-bottom: 28px; font-size: 0.9rem; }

/* ── 그리드 ── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── 반응형 브레이크포인트 ── */
/* 데스크톱 (1200px+) */
@media (min-width: 1200px) {
  .section { padding: 60px 24px; }
  .grid-4 { gap: 20px; }
}

/* 태블릿 가로 (1024px) */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

/* 태블릿 세로 (768px) */
@media (max-width: 768px) {
  .header { height: 56px; padding: 0 16px; gap: 12px; }
  .header-nav { display: none; }
  .mobile-menu-btn { display: flex; }
  .main-container { padding-top: 56px; }
  .section { padding: 40px 16px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .grid-2 { grid-template-columns: 1fr; }
  .toast-container { bottom: 16px; right: 12px; }
}

/* 모바일 (480px) */
@media (max-width: 480px) {
  .header { padding: 0 12px; }
  .header-logo { font-size: 1.1rem; }
  .section { padding: 32px 12px; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .grid-3 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .course-body { padding: 12px; }
  .course-title { font-size: 0.85rem; }
  .course-price { font-size: 0.9rem; }
  .btn { padding: 8px 14px; font-size: 0.82rem; }
  .user-badge span { display: none; } /* 모바일에서 이름 숨김 */
}

/* 초소형 모바일 (360px) */
@media (max-width: 360px) {
  .grid-4, .grid-3 { grid-template-columns: 1fr; }
}

/* ── 유틸리티 ── */
.text-primary-c { color: var(--color-primary-light); }
.text-pink { color: var(--color-pink); }
.text-mint { color: var(--color-mint); }
.text-gold { color: var(--color-gold); }
.text-green { color: var(--color-green); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.p-4 { padding: 16px; }
.rounded { border-radius: var(--radius); }
.hidden { display: none !important; }
.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.ml-1 { margin-left: 4px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 안전 영역 (노치 디바이스) ── */
@supports (padding: max(0px)) {
  .header { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .toast-container { right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); }
}

/* ── PWA 설치 배너 ── */
.pwa-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2000;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  animation: slideUp 0.3s ease;
}
.pwa-banner.hidden { display: none; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ── 인쇄 스타일 (PDF 수료증용) ── */
@media print {
  .header, .mobile-menu-btn, .toast-container { display: none !important; }
  body { background: white; color: black; }
  .main-container { padding-top: 0; }
}

/* ── 고대비 모드 지원 ── */
@media (prefers-contrast: high) {
  .form-input { border-width: 2px; }
  .btn { border-width: 2px; }
}

/* ── 애니메이션 감소 (접근성) ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
