/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Background gradient */
.app-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, var(--primary-glow), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(168, 85, 247, 0.15), transparent),
    var(--bg-deep);
  pointer-events: none;
  z-index: -1;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.text-muted { color: var(--text-muted); }
.text-dim { color: var(--text-dim); }

/* Animation */
.animate-in {
  animation: fadeSlideIn 0.5s ease-out;
}

@keyframes fadeSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 40px;
}

.auth-header {
  text-align: center;
  margin-bottom: 32px;
}

.auth-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.auth-icon-register {
  background: linear-gradient(135deg, #8B5CF6, #EC4899);
}

.auth-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Alerts */
.alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #FCA5A5;
}

/* Forms */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.input-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper svg {
  position: absolute;
  left: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  padding: 14px 16px 14px 48px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 1rem;
  transition: all 0.2s;
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

.input-wrapper input::placeholder {
  color: var(--text-dim);
}

.input-hint {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary));
  color: white;
  font-weight: 600;
  font-size: 1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.btn-full {
  width: 100%;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 24px;
  background: var(--bg-card);
  color: var(--text);
  font-weight: 600;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-dim);
}

.btn-large {
  padding: 18px 32px;
  font-size: 1.1rem;
}

.auth-footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-footer a {
  color: var(--primary);
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ===== APP LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: rgba(0,0,0,0.3);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
}

.course-badge {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

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

.course-title {
  font-size: 1.1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-progress {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 10px;
  color: var(--text-muted);
}

.progress-percent {
  color: var(--primary);
  font-weight: 600;
}

.progress-bar {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 3px;
  transition: width 0.3s;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 0;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-num {
  width: 22px;
  height: 22px;
  background: var(--bg-card);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
}

.nav-lessons {
  list-style: none;
}

.nav-lesson {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px 10px 36px;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-lesson:hover {
  background: var(--bg-card);
  color: var(--text);
}

.nav-lesson.active {
  background: var(--primary-glow);
  color: var(--text);
}

.lesson-check {
  color: var(--text-dim);
  flex-shrink: 0;
}

.lesson-check.completed {
  color: var(--success);
}

.lesson-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lesson-time {
  font-size: 0.75rem;
  color: var(--text-dim);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border);
}

.logout-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.logout-link:hover {
  color: var(--danger);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 32px 40px;
  min-width: 0;
}

.content-header {
  margin-bottom: 32px;
}

.content-header h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}

/* Section Cards */
.content-grid {
  display: grid;
  gap: 24px;
}

.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  transition: all 0.2s;
}

.section-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255,255,255,0.12);
}

.section-card-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.section-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
}

.section-card-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.section-desc {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.section-lessons-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lesson-preview-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: rgba(255,255,255,0.02);
  border-radius: 10px;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.lesson-preview-item:hover {
  background: rgba(255,255,255,0.05);
}

.lesson-preview-item svg {
  color: var(--primary);
  flex-shrink: 0;
}

.lesson-preview-item span {
  flex: 1;
}

.badge-free {
  padding: 3px 8px;
  background: rgba(16, 185, 129, 0.2);
  color: var(--success);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 4px;
}

.more-lessons {
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ===== LESSON PAGE ===== */
.sidebar-lesson {
  width: 280px;
  min-width: 280px;
}

.back-to-course {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: color 0.2s;
}

.back-to-course:hover {
  color: var(--text);
}

.current-lesson-info {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}

.lesson-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: block;
}

.current-lesson-info h3 {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
}

.lesson-progress-box {
  padding: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.progress-circle {
  width: 80px;
  height: 80px;
  position: relative;
}

.progress-circle svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-circle .progress-bg {
  fill: none;
  stroke: rgba(255,255,255,0.1);
  stroke-width: 3;
}

.progress-circle .progress-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dasharray 0.3s;
}

.progress-circle .progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.quiz-sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 20px 24px;
  padding: 14px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 600;
  border-radius: 12px;
  transition: all 0.2s;
}

.quiz-sidebar-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--primary-glow);
}

.lesson-main {
  padding: 0;
}

.video-section {
  background: #000;
  position: relative;
}

.video-wrapper {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
}

.video-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.video-placeholder {
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(168, 85, 247, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
}

.placeholder-content {
  text-align: center;
}

.placeholder-icon {
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.placeholder-content p {
  font-size: 1.1rem;
  margin-bottom: 8px;
}

.lesson-header {
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
}

.lesson-header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.lesson-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lesson-tabs {
  display: flex;
  gap: 4px;
  padding: 0 32px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 20px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.lesson-content-area {
  padding: 32px;
}

.lesson-text {
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1.8;
}

.empty-content {
  padding: 40px;
  text-align: center;
}

.quiz-cta-card {
  margin: 32px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.cta-content h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

/* ===== QUIZ PAGE ===== */
.quiz-page {
  min-height: 100vh;
  padding: 40px 20px;
}

.quiz-container {
  max-width: 800px;
  margin: 0 auto;
}

.quiz-header {
  margin-bottom: 32px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--text);
}

.quiz-title-block {
  display: flex;
  align-items: center;
  gap: 20px;
}

.quiz-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
}

.quiz-title-block h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

/* Quiz Form */
.questions-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
}

.question-header {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.question-num {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.question-text {
  font-size: 1.1rem;
  font-weight: 500;
  line-height: 1.5;
}

.answers-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.answer-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.answer-option:hover {
  background: rgba(255,255,255,0.04);
  border-color: var(--text-dim);
}

.answer-option input {
  display: none;
}

.radio-custom {
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-dim);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: all 0.2s;
}

.answer-option input:checked + .radio-custom {
  border-color: var(--primary);
  background: var(--primary);
}

.answer-option input:checked + .radio-custom::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.checkbox-custom {
  width: 22px;
  height: 22px;
  border: 2px solid var(--text-dim);
  border-radius: 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.checkbox-custom svg {
  opacity: 0;
  color: white;
  transition: opacity 0.2s;
}

.answer-option input:checked + .checkbox-custom {
  border-color: var(--primary);
  background: var(--primary);
}

.answer-option input:checked + .checkbox-custom svg {
  opacity: 1;
}

.answer-text {
  font-size: 1rem;
  line-height: 1.4;
}

.quiz-submit {
  margin-top: 32px;
  text-align: center;
}

/* Quiz Result */
.quiz-result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 48px;
  text-align: center;
}

.result-passed {
  border-color: rgba(16, 185, 129, 0.3);
}

.result-failed {
  border-color: rgba(239, 68, 68, 0.3);
}

.result-icon {
  margin-bottom: 24px;
}

.result-passed .result-icon {
  color: var(--success);
}

.result-failed .result-icon {
  color: var(--danger);
}

.quiz-result-card h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.result-score {
  margin-bottom: 32px;
}

.score-value {
  display: block;
  font-size: 4rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.result-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  margin-bottom: 32px;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--border);
}

.result-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .sidebar {
    width: 260px;
    min-width: 260px;
  }
}

@media (max-width: 768px) {
  .app-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    position: relative;
  }

  .sidebar-nav {
    max-height: 300px;
  }

  .main-content {
    padding: 24px;
  }

  .lesson-main {
    padding: 0;
  }

  .lesson-header,
  .lesson-tabs,
  .lesson-content-area,
  .quiz-cta-card {
    padding-left: 20px;
    padding-right: 20px;
  }

  .quiz-cta-card {
    flex-direction: column;
    text-align: center;
  }

  .result-actions {
    flex-direction: column;
  }

  .auth-card {
    padding: 30px 24px;
  }
}
