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

:root {
  --bg-primary: #0a0a0c;
  --bg-secondary: #121216;
  --bg-card: rgba(26, 26, 30, 0.65);
  --bg-card-hover: rgba(36, 36, 42, 0.8);
  --bg-sidebar: rgba(16, 16, 20, 0.95);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --text-primary: #f8f8f9;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  
  /* PyTorch Theme Colors */
  --accent-primary: #ee4c2c;
  --accent-primary-dim: rgba(238, 76, 44, 0.15);
  --accent-secondary: #f9ab00; /* Colab Yellow */
  --accent-secondary-dim: rgba(249, 171, 0, 0.15);
  
  --accent-gradient: linear-gradient(135deg, #ee4c2c, #f9ab00);
  --accent-gradient-warm: linear-gradient(135deg, #ee4c2c, #d32f2f);
  
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 8px 40px rgba(238, 76, 44, 0.12);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition-fast: 0.2s ease;
  --transition-med: 0.35s ease;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== Background Decoration ===== */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.22;
  pointer-events: none;
  z-index: 0;
}

.bg-glow--orange {
  width: 500px;
  height: 500px;
  background: var(--accent-primary);
  top: -120px;
  right: -100px;
}

.bg-glow--yellow {
  width: 400px;
  height: 400px;
  background: var(--accent-secondary);
  bottom: -80px;
  left: -60px;
}

/* ===== Layout ===== */
.app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ===== Header ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(10, 10, 12, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.header__icon {
  width: 36px;
  height: 36px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.header__title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.header__subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.header__back-btn {
  display: none;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.85rem;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.header__back-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

.header__back-btn.visible {
  display: flex;
}

/* ===== HOME VIEW ===== */
.view-home {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}

.hero {
  text-align: center;
  margin-bottom: 3.5rem;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.9rem;
  border-radius: 100px;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.25rem;
}

.hero__title {
  font-size: clamp(2rem, 5vw, 3.2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-bottom: 1rem;
}

.hero__title span {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__description {
  max-width: 640px;
  margin: 0 auto;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.hero__stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-top: 2rem;
  flex-wrap: wrap;
}

.hero__stat {
  text-align: center;
}

.hero__stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero__stat-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}

/* ===== Lesson Cards Grid ===== */
.lessons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.lesson-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  cursor: pointer;
  transition: all var(--transition-med);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: relative;
  overflow: hidden;
}

.lesson-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.lesson-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(238, 76, 44, 0.25);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-3px);
}

.lesson-card:hover::before {
  opacity: 1;
}

.lesson-card__header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.75rem;
}

.lesson-card__number {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  flex-shrink: 0;
}

.lesson-card__title {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.lesson-card__description {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.lesson-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.lesson-card__tag {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.lesson-card__arrow {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: all var(--transition-fast);
}

.lesson-card:hover .lesson-card__arrow {
  background: var(--accent-primary);
  color: #fff;
}

/* ===== LESSON VIEW ===== */
.view-lesson {
  display: none;
  height: calc(100vh - 57px);
}

.view-lesson.active {
  display: flex;
}

.view-home.hidden {
  display: none;
}

/* Sidebar */
.sidebar {
  width: 320px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar__header {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar__title {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.sidebar__list {
  list-style: none;
  padding: 0.5rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar__module-heading {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-secondary);
  text-transform: uppercase;
  padding: 1.2rem 0.85rem 0.4rem;
  letter-spacing: 0.05em;
}

.sidebar__item {
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
  text-decoration: none;
}

.sidebar__link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

.sidebar__link.active {
  background: var(--accent-primary-dim);
  color: var(--accent-primary);
}

.sidebar__icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.sidebar__link.active .sidebar__icon {
  background: var(--accent-primary);
  color: #fff;
}

.sidebar__link-title {
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
}

/* Lesson nav footer */
.sidebar__footer {
  padding: 1rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 0.5rem;
}

.sidebar__nav-btn {
  flex: 1;
  padding: 0.55rem;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-family: var(--font-sans);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
}

.sidebar__nav-btn:hover:not(:disabled) {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

.sidebar__nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Viewer Container */
.lesson-frame-container {
  flex: 1;
  position: relative;
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
}

/* iframe for Slides */
.lesson-frame-container iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #fff;
}

/* Colab Launch Page */
.colab-launcher {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
  padding: 2rem;
  background: var(--bg-secondary);
  position: absolute;
  inset: 0;
  z-index: 10;
}

.colab-launcher.active {
  display: flex;
}

.colab-launcher__icon {
  width: 80px;
  height: 80px;
  margin-bottom: 2rem;
}

.colab-launcher__title {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 1rem;
  max-width: 600px;
}

.colab-launcher__desc {
  font-size: 1.05rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin-bottom: 2.5rem;
  line-height: 1.6;
}

.btn-colab {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 2rem;
  background: #fff;
  color: #000;
  text-decoration: none;
  border-radius: var(--radius-lg);
  font-weight: 600;
  font-size: 1.05rem;
  transition: all var(--transition-med);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.btn-colab:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.2);
}

/* Loading overlay */
.lesson-frame-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg-secondary);
  z-index: 5;
  transition: opacity var(--transition-med);
}

.lesson-frame-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-card);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.lesson-frame-loading__text {
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border-subtle);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .header {
    padding: 0.75rem 1rem;
  }

  .header__subtitle {
    display: none;
  }

  .view-home {
    padding: 2rem 1rem 3rem;
  }

  .hero {
    margin-bottom: 2rem;
  }

  .hero__stats {
    gap: 1.5rem;
  }

  .lessons-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    width: 240px;
  }

  .sidebar__link-title {
    font-size: 0.8rem;
  }
}

@media (max-width: 560px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 57px;
    bottom: 0;
    z-index: 50;
    width: 260px;
    transform: translateX(-100%);
    transition: transform var(--transition-med);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 57px;
    background: rgba(0, 0, 0, 0.5);
    z-index: 49;
  }

  .sidebar-overlay.open {
    display: block;
  }

  .mobile-menu-btn {
    display: flex !important;
  }
}

.mobile-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.mobile-menu-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}
