/* ============================================
   Tutorial Page Styles
   ============================================ */

/* --- Hero Section --- */
.tutorial-hero {
  background: linear-gradient(135deg, #1677ff 0%, #4096ff 50%, #69b1ff 100%);
  color: var(--text-white);
  padding: 64px 0 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.tutorial-hero::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -10%;
  width: 120%;
  height: 200%;
  background: radial-gradient(circle at 30% 50%, rgba(255, 255, 255, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.tutorial-hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-white);
  position: relative;
}

.tutorial-hero .hero-subtitle {
  font-size: 1.15rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 24px;
  position: relative;
}

.tutorial-hero .hero-tags {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  position: relative;
}

.tutorial-hero .hero-tag {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--text-white);
  padding: 6px 18px;
  border-radius: 20px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.tutorial-hero .hero-hosted {
  margin-top: 32px;
  font-size: 0.9rem;
  opacity: 0.8;
  position: relative;
  color: var(--text-white);
}

.tutorial-hero .hero-hosted a,
.tutorial-hero .hero-hosted a:visited,
.tutorial-hero .hero-hosted a:hover {
  color: #ffffff !important;
  text-decoration: underline !important;
  text-underline-offset: 3px;
  font-weight: 500;
}

.tutorial-hero .hero-hosted a:hover {
  text-decoration-thickness: 2px;
}

/* --- Tutorial Layout (Sidebar + Content) --- */
.tutorial-layout {
  display: flex;
  min-height: calc(100vh - var(--header-height) - 200px);
}

/* --- Sidebar --- */
.tutorial-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  background-color: var(--bg-white);
  border-right: 1px solid var(--border-color);
  padding: 20px 0;
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.sidebar-section-title:hover {
  color: var(--primary);
}

.sidebar-section-title .section-icon {
  font-size: 1rem;
}

.sidebar-section-title .chevron {
  margin-left: auto;
  transition: transform var(--transition-fast);
  font-size: 0.7rem;
}

.sidebar-section-title.collapsed .chevron {
  transform: rotate(-90deg);
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}

.sidebar-nav li {
  margin: 0;
}

.sidebar-nav a {
  display: block;
  padding: 7px 20px 7px 36px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav a:hover {
  color: var(--primary);
  background-color: var(--primary-bg);
}

.sidebar-nav a.active {
  color: var(--primary);
  background-color: var(--primary-bg);
  border-left-color: var(--primary);
  font-weight: 600;
}

/* --- Mobile Sidebar Toggle --- */
.sidebar-toggle-btn {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 1050;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background-color: var(--primary);
  color: var(--text-white);
  border: none;
  box-shadow: var(--shadow-lg);
  font-size: 1.2rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.sidebar-toggle-btn:hover {
  background-color: var(--primary-hover);
  transform: scale(1.08);
}

/* --- Mobile Sidebar Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  z-index: 1039;
}

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

.topic-card {
  background-color: var(--bg-white);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-normal);
}

.topic-card:hover {
  box-shadow: var(--shadow-md);
}

.topic-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.topic-card-header .topic-number {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.topic-card-header h3 {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0;
}

.topic-description {
  color: var(--text-secondary);
  line-height: 1.7;
}

.topic-description p {
  margin-bottom: 12px;
}

.topic-description ul,
.topic-description ol {
  padding-left: 24px;
  margin-bottom: 12px;
}

.topic-description li {
  margin-bottom: 4px;
}

.topic-description strong {
  color: var(--text-primary);
}

.topic-description code {
  font-size: 0.85em;
}

.topic-description table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 0.9rem;
}

.topic-description th,
.topic-description td {
  padding: 6px 10px;
  text-align: left;
  border: 1px solid var(--border-color);
}

.topic-description th {
  background-color: var(--primary);
  color: var(--text-white);
}

.topic-description pre {
  margin: 12px 0;
}

/* --- Live Code Editor --- */
.code-editor {
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  overflow: hidden;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
}

.code-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #f6f8fa;
  border-bottom: 1px solid var(--border-color);
  padding: 0 12px;
}

.code-editor-tabs {
  display: flex;
  gap: 0;
}

.code-editor-tab {
  padding: 10px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.code-editor-tab:hover {
  color: var(--text-secondary);
}

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

.code-editor-actions {
  display: flex;
  gap: 8px;
}

.code-editor-actions .btn {
  font-size: 0.8rem;
  padding: 4px 14px;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
}

.btn-run {
  background-color: var(--primary);
  color: var(--text-white);
  border: none;
}

.btn-run:hover {
  background-color: var(--primary-hover);
  color: var(--text-white);
}

.btn-reset {
  background-color: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-reset:hover {
  background-color: #f0f0f0;
  color: var(--text-primary);
}

.code-editor-body {
  display: flex;
  min-height: 200px;
}

.code-editor-input {
  flex: 1;
  min-width: 0;
  border-right: 1px solid var(--border-color);
  position: relative;
}

.code-editor-textarea {
  width: 100%;
  height: 100%;
  min-height: 200px;
  border: none;
  outline: none;
  resize: vertical;
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: #fafbfc;
  tab-size: 2;
}

.code-editor-textarea:focus {
  background-color: var(--bg-white);
}

.code-editor-preview {
  flex: 1;
  min-width: 0;
  background-color: var(--bg-white);
  position: relative;
}

.code-editor-preview .preview-label {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 1;
  pointer-events: none;
}

.code-editor-iframe {
  width: 100%;
  height: 100%;
  min-height: 200px;
  border: none;
  display: block;
}

/* --- Quiz CTA Section --- */
.quiz-cta {
  text-align: center;
  padding: 56px 24px;
  background: linear-gradient(135deg, #f0f7ff 0%, #e6f4ff 100%);
  border-radius: var(--border-radius-lg);
  margin-top: 24px;
  border: 1px solid var(--primary-border);
}

.quiz-cta h2 {
  font-size: 1.75rem;
  margin-bottom: 12px;
}

.quiz-cta p {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 1.05rem;
}

.quiz-cta .btn {
  font-size: 1.05rem;
  padding: 12px 36px;
}

/* --- Section Divider --- */
.section-divider {
  text-align: center;
  margin: 48px 0 32px;
  position: relative;
}

.section-divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background-color: var(--border-color);
}

.section-divider-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: var(--bg-body);
  padding: 6px 20px;
  border-radius: 20px;
  position: relative;
  font-weight: 700;
  font-size: 1.1rem;
  border: 1px solid var(--border-color);
}

/* --- Progress Indicator --- */
.progress-bar-container {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  height: 3px;
  background-color: var(--border-color);
  z-index: 1025;
}

.progress-bar-fill {
  height: 100%;
  background-color: var(--primary);
  width: 0;
  transition: width 0.15s linear;
}

/* --- Responsive Design --- */

/* Tablet (768px - 991px) */
@media (max-width: 991.98px) {
  .tutorial-sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    min-width: 280px;
    height: 100vh;
    z-index: 1040;
    transition: left var(--transition-normal);
    padding-top: calc(var(--header-height) + 16px);
    box-shadow: none;
  }

  .tutorial-sidebar.show {
    left: 0;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-toggle-btn {
    display: flex;
  }

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

  .tutorial-content {
    padding: 24px 24px 40px;
  }

  .topic-card {
    padding: 24px;
  }

  .code-editor-body {
    flex-direction: column;
  }

  .code-editor-input {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .code-editor-textarea {
    min-height: 160px;
  }

  .code-editor-iframe {
    min-height: 160px;
  }
}

/* Mobile (< 768px) */
@media (max-width: 767.98px) {
  .tutorial-hero {
    padding: 40px 16px 36px;
  }

  .tutorial-hero h1 {
    font-size: 1.75rem;
  }

  .tutorial-hero .hero-subtitle {
    font-size: 1rem;
  }

  .tutorial-content {
    padding: 16px 16px 32px;
  }

  .topic-card {
    padding: 20px 16px;
    margin-bottom: 20px;
  }

  .topic-card-header h3 {
    font-size: 1.15rem;
  }

  .code-editor-header {
    flex-direction: column;
    align-items: stretch;
    padding: 8px;
    gap: 8px;
  }

  .code-editor-actions {
    justify-content: flex-end;
  }

  .quiz-cta {
    padding: 36px 16px;
  }

  .quiz-cta h2 {
    font-size: 1.35rem;
  }

  .section-divider {
    margin: 32px 0 24px;
  }
}

/* Small Mobile (< 576px) */
@media (max-width: 575.98px) {
  .tutorial-hero h1 {
    font-size: 1.5rem;
  }

  .hero-tag {
    font-size: 0.8rem;
    padding: 4px 12px;
  }
}
