:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --secondary: #f0fdf4;
  --dark: #1e293b;
  --light: #f8fafc;
  --accent: #34d399;
  --sidebar-width: 250px;
  --code-bg: #f1f5f9;
  --code-border: #cbd5e1;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
}

body {
  background-color: var(--light);
  color: var(--dark);
  position: relative;
  min-height: 100vh;
}

/* Top Navigation */
.top-nav {
  display: flex;
  background-color: var(--dark);
  overflow-x: auto;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  align-items: center; /* Ensure vertical alignment */
  min-height: 52px;
}

.top-nav a {
  display: inline-block;
  color: white;
  text-align: center;
  padding: 16px 20px;
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.3s;
}

.top-nav a:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.top-nav a.active {
  background-color: var(--primary);
  color: white;
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0;
}

.nav-right a {
  margin-left: 0;
}

/* Hamburger menu toggle for mobile - inside nav, not overlapping links */
.menu-toggle {
  display: none;
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--primary);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  z-index: 200;
  border: none;
  outline: none;
  transition: background 0.2s;
  /* Remove bottom/right/fixed/other positions */
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--light);
  position: fixed;
  height: calc(100vh - 52px);
  left: 0;
  top: 52px;
  overflow-y: auto;
  border-right: 1px solid #e2e8f0;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  background-color: var(--primary);
  color: white;
  font-weight: bold;
  font-size: 1.2rem;
}

.sidebar-home {
  padding: 15px 20px;
  background-color: var(--accent);
  color: white;
  font-weight: 500;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.sidebar-menu {
  list-style: none;
}

.sidebar-menu li {
  border-bottom: 1px solid #e2e8f0;
}

.sidebar-menu a {
  display: block;
  padding: 14px 20px;
  color: var(--dark);
  text-decoration: none;
  transition: all 0.2s;
}

.sidebar-menu a:hover {
  background-color: #f1f5f9;
  padding-left: 25px;
  color: var(--primary);
}

.sidebar-menu a.active {
  border-left: 4px solid var(--primary);
  background-color: rgba(37, 99, 235, 0.1);
  color: var(--primary);
  font-weight: 500;
}

/* Main Content */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 40px;
  padding-bottom: 80px;
  max-width: 1200px;
}

.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}

.content-header h1 {
  font-size: 2.4rem;
  color: var(--dark);
  font-weight: 700;
}

.nav-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 20px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background-color: var(--primary);
  color: white;
  border: none;
}

.btn-primary:hover {
  background-color: var(--primary-dark);
}

.btn-outline {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

.btn-outline:hover {
  background-color: rgba(37, 99, 235, 0.05);
}

.content-box {
  background-color: white;
  border-radius: 12px;
  padding: 36px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  margin-bottom: 30px;
  border-left: 6px solid var(--primary);
  transition: box-shadow 0.3s, transform 0.3s;
}

.content-box:hover {
  box-shadow: 0 8px 32px rgba(37, 99, 235, 0.13);
  transform: translateY(-2px) scale(1.01);
}

.lesson-title {
  margin-bottom: 20px;
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--dark);
}

.lesson-description {
  color: #4b5563;
  line-height: 1.6;
  margin-bottom: 30px;
}

.code-example {
  background-color: var(--code-bg);
  border-radius: 8px;
  border-left: 4px solid var(--accent);
  padding: 20px;
  margin-bottom: 30px;
  position: relative;
  overflow: hidden;
}

.code-header {
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--code-border);
  margin-bottom: 15px;
  font-weight: 500;
  color: #64748b;
}

.code-content {
  font-family: "Courier New", Courier, monospace;
  line-height: 1.6;
  white-space: pre-wrap;
  color: #334155;
  overflow-x: auto;
}

.code-tag {
  color: #2563eb;
}

.code-attr {
  color: #d97706;
}

.code-string {
  color: #059669;
}

.cta-button {
  text-align: center;
  margin-top: 40px;
}

.cta-button .btn {
  padding: 14px 30px;
  font-size: 1.1rem;
}

/* Content Styling */
.content-box h3 {
  margin: 25px 0 15px;
  color: var(--dark);
  font-weight: 600;
}

.content-box ul,
.content-box ol {
  margin-left: 20px;
  margin-bottom: 20px;
}

.content-box li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.content-box p {
  margin-bottom: 20px;
  line-height: 1.6;
}

.content-box img {
  max-width: 100%;
  border-radius: 6px;
  margin: 20px 0;
}

.note-box {
  background-color: #eff6ff;
  border-left: 4px solid #3b82f6;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 6px;
}

.tip-box {
  background-color: #ecfdf5;
  border-left: 4px solid #10b981;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 6px;
}

.warning-box {
  background-color: #fff7ed;
  border-left: 4px solid #f97316;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 6px;
}

.try-it-box {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin: 30px 0;
}

.try-it-title {
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.try-it-title svg {
  width: 20px;
  height: 20px;
}

.try-it-description {
  margin-bottom: 15px;
}

.exercise-box {
  background-color: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 8px;
  padding: 20px;
  margin: 30px 0;
}

.exercise-title {
  font-weight: 600;
  margin-bottom: 15px;
  color: #0369a1;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  font-size: 0.9em;
}

table th {
  background-color: var(--primary);
  color: white;
  text-align: left;
  padding: 12px 15px;
}

table td {
  padding: 10px 15px;
  border-bottom: 1px solid #e2e8f0;
}

table tr:nth-child(even) {
  background-color: #f8fafc;
}

.result-preview {
  background-color: white;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  padding: 20px;
  margin: 20px 0;
}

.result-title {
  font-weight: 500;
  color: #64748b;
  margin-bottom: 10px;
  display: block;
}

/* Subtopics Section for HTML Lessons */
.subtopics-section {
  margin: 22px 0 14px 0;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 14px 20px;
  animation: subtopics-fadein 0.6s;
  box-shadow: 0 1px 6px rgba(52, 211, 153, 0.06);
}

@keyframes subtopics-fadein {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.subtopics-section h3 {
  margin-top: 0;
  font-size: 1.13em;
  color: var(--primary-dark);
  letter-spacing: 0.7px;
}

.subtopic {
  margin-bottom: 8px;
}

.subtopic-toggle {
  background: #e0f2fe;
  border: 1px solid #bae6fd;
  color: var(--primary-dark);
  font-weight: 600;
  padding: 7px 13px;
  border-radius: 5px;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.2s, border 0.2s, box-shadow 0.2s;
  min-height: 44px;
  font-size: 1.04em;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.03);
}

.subtopic-toggle.open,
.subtopic-toggle:hover {
  background: #bae6fd;
  border: 1.5px solid var(--primary);
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.subtopic-content {
  background: #fff;
  border-left: 3px solid var(--primary);
  margin-top: 4px;
  margin-bottom: 10px;
  padding: 9px 13px;
  border-radius: 0 8px 8px 0;
  font-size: 1em;
  box-shadow: 0 1px 4px rgba(52, 211, 153, 0.06);
}

/* For mobile */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 99;
  }

  .sidebar.active {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
  }

  .menu-toggle {
    display: flex;
  }

  .content-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .content-header h1 {
    font-size: 2rem;
  }

  .content-box {
    padding: 25px;
  }
}

/* Responsive improvements */
@media (max-width: 1200px) {
  .main-content {
    max-width: 100vw;
    padding: 24px;
  }
}

@media (max-width: 900px) {
  .content-box {
    padding: 18px;
    font-size: 0.99em;
  }

  .subtopics-section {
    padding: 10px 6px;
    font-size: 0.98em;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 52px;
    width: 240px;
    height: calc(100vh - 52px);
    z-index: 1000;
    background: #fff;
    transition: left 0.3s;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
    border-right: 1px solid #e2e8f0;
  }

  .sidebar.active {
    left: 0;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 20px;
    max-width: 100vw;
  }

  .menu-toggle {
    display: flex !important;
    position: relative !important;
    top: unset !important;
    left: unset !important;
    margin-right: 8px;
    margin-left: 0;
    order: 0;
  }
  .top-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    display: flex;
    align-items: center;
  }
  .top-nav a {
    order: 1; /* nav links after menu toggle */
  }
  .nav-right {
    order: 2; /* always at the end */
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0;
    position: static; /* prevent overlay */
    background: none;
  }
  .main-content {
    padding-top: 64px; /* add space for fixed nav */
  }
  .sidebar {
    top: 52px;
  }
}

@media (max-width: 600px) {
  body {
    font-size: 0.98em;
  }

  .content-box {
    padding: 8px;
    font-size: 0.97em;
    margin-bottom: 16px;
  }

  .subtopics-section {
    padding: 6px 2px;
    font-size: 0.97em;
    border-radius: 6px;
  }

  .subtopic-toggle {
    font-size: 0.97em;
    padding: 10px 8px;
    min-height: 40px;
  }

  .subtopic-content {
    padding: 7px 6px;
    font-size: 0.97em;
  }

  table {
    font-size: 0.95em;
  }
}

/* Toggle button for mobile */
.menu-toggle {
  display: none;
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--primary);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  justify-content: center;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  z-index: 200;
  border: none;
  outline: none;
  transition: background 0.2s;
}

.menu-toggle:hover,
.menu-toggle:focus {
  background: var(--primary-dark);
}

.menu-toggle svg {
  width: 28px;
  height: 28px;
  display: block;
  stroke: white;
}

/* Ensure .menu-toggle is hidden by default */
.menu-toggle {
  display: none;
}

.progress-bar {
  height: 6px;
  background-color: #e2e8f0;
  border-radius: 3px;
  margin: 30px 0;
  overflow: hidden;
}

.progress {
  height: 100%;
  background-color: var(--accent);
  border-radius: 3px;
  transition: width 0.5s;
}
