/* ===== صفحة الدرس – تخطيط W3Schools ===== */
.lesson-page {
  min-height: 100vh;
  background: var(--bg-color);
}

.lesson-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  z-index: 1100;
  border-radius: 0;
  border-top: none;
  border-left: none;
  border-right: none;
}

.lesson-navbar-inner {
  max-width: 100%;
  height: 100%;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.lesson-navbar .logo {
  font-size: 20px;
  flex-shrink: 0;
}

.lesson-navbar .app-version {
  font-size: 10px;
  padding: 3px 8px;
}

.lesson-navbar .site-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.lesson-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 0;
}

.lesson-breadcrumb a {
  color: var(--primary);
  text-decoration: none;
  white-space: nowrap;
}

.lesson-breadcrumb a:hover {
  text-decoration: underline;
}

.lesson-breadcrumb i {
  font-size: 10px;
  opacity: 0.5;
}

.lesson-breadcrumb span {
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-toggle-btn {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 18px;
}

.lesson-layout {
  --lesson-sidebar-width: 280px;
  --lesson-sidebar-gap: 40px;
  display: flex;
  padding-top: 64px;
  min-height: 100vh;
}

/* السايدبار – يمين في RTL */
.lesson-sidebar {
  position: fixed;
  top: 64px;
  right: 0;
  width: var(--lesson-sidebar-width);
  height: calc(100vh - 64px);
  border-radius: 0;
  border-top: none;
  border-right: none;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  border-bottom: 1px solid var(--panel-border);
  flex-shrink: 0;
}

.sidebar-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: 'Satoshi', 'Noto Sans Arabic', sans-serif;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sidebar-lessons {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-listview {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.sidebar-listview::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

.sidebar-listview ul {
  list-style: none;
}

/* عنوان فاصل – أضفه يدوياً في courses/اسم-الدورة/sidebar.html */
.sidebar-lessons .sidebar-divider {
  padding: 22px 20px 10px;
  pointer-events: none;
  user-select: none;
}

.sidebar-lessons .sidebar-divider:first-child {
  padding-top: 8px;
}

.sidebar-lessons .sidebar-divider span {
  display: block;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fafafa;
  position: relative;
  padding-bottom: 10px;
}

.sidebar-lessons .sidebar-divider span::after {
  content: '';
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(to left, var(--panel-border) 0%, transparent 100%);
}

[data-theme="light"] .sidebar-lessons .sidebar-divider span {
  color: #0a0a0a;
}

.sidebar-lessons a {
  display: block;
  padding: 12px 20px;
  text-decoration: none;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 14px;
  border-right: 3px solid transparent;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

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

.sidebar-lessons a.active {
  background: var(--primary-bg);
  color: var(--primary);
  border-right-color: var(--primary);
}

.lesson-main {
  flex: 1;
  margin-right: calc(var(--lesson-sidebar-width) + var(--lesson-sidebar-gap));
  padding: 28px 48px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

.lesson-article,
.lesson-pager {
  width: 100%;
  max-width: 900px;
}

.lesson-article {
  padding: 44px 40px;
  border-radius: 20px;
  margin-bottom: 24px;
}

.lesson-article h1 {
  font-size: 34px;
  font-weight: 900;
  line-height: 1.35;
  margin-bottom: 28px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.lesson-section {
  margin-bottom: 36px;
  padding-bottom: 8px;
}

.lesson-section:not(:last-child) {
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 28px;
}

.lesson-section h2 {
  font-size: 23px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 16px;
  padding-right: 16px;
  border-right: 4px solid var(--primary);
  line-height: 1.45;
}

.lesson-section p,
.lesson-section li {
  color: var(--text-secondary);
  line-height: 1.9;
  font-size: 16px;
}

.lesson-section p {
  margin-bottom: 14px;
}

.lesson-section strong {
  color: var(--text-primary);
  font-weight: 800;
}

.lesson-section ul,
.lesson-section ol {
  margin: 12px 24px 0 0;
  padding-right: 20px;
}

.lesson-section li {
  margin-bottom: 8px;
}

.lesson-section h3 {
  font-size: 18px;
  font-weight: 800;
  color: #8B7FD4;
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lesson-section h3::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  flex-shrink: 0;
}

[data-theme="light"] .lesson-section h3 {
  color: var(--primary-hover);
}

.lesson-section a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.lesson-section a:hover {
  text-decoration: underline;
}

/* جداول المقارنة داخل الدرس */
.lesson-table-wrap {
  margin: 20px 0 8px;
  border-radius: 14px;
  border: 1px solid var(--panel-border);
  overflow: hidden;
  background: rgba(24, 24, 27, 0.35);
}

.lesson-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  text-align: right;
}

.lesson-table thead {
  background: var(--primary-bg);
}

.lesson-table th,
.lesson-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
  vertical-align: top;
  line-height: 1.65;
}

.lesson-table thead th {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.02em;
}

.lesson-table tbody th[scope="row"] {
  font-weight: 800;
  color: var(--text-primary);
  background: rgba(82, 68, 185, 0.06);
  white-space: nowrap;
  width: 1%;
}

.lesson-table tbody td {
  color: var(--text-secondary);
}

.lesson-table tbody tr:last-child th,
.lesson-table tbody tr:last-child td {
  border-bottom: none;
}

.lesson-table tbody tr:hover td,
.lesson-table tbody tr:hover th[scope="row"] {
  background: rgba(82, 68, 185, 0.05);
}

.lesson-table code {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(82, 68, 185, 0.2);
}

[data-theme="light"] .lesson-table-wrap {
  background: #fafafa;
}

[data-theme="light"] .lesson-table thead {
  background: rgba(82, 68, 185, 0.08);
}

[data-theme="light"] .lesson-table tbody th[scope="row"] {
  background: rgba(82, 68, 185, 0.05);
}

@media (max-width: 640px) {
  .lesson-table-wrap {
    overflow-x: auto;
  }

  .lesson-table {
    min-width: 520px;
  }

  .lesson-table th,
  .lesson-table td {
    padding: 12px 14px;
    font-size: 14px;
  }
}

.lesson-section p code,
.lesson-section li code {
  background: var(--primary-bg);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 6px;
  font-family: 'Fira Code', monospace;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(82, 68, 185, 0.2);
}

/* كتل الكود – Prism.js */
.lesson-code-wrap {
  position: relative;
  margin: 18px 0 26px;
}

.lesson-code-wrap pre.lesson-code-snippet,
.lesson-code-wrap pre.lesson-code-plain {
  margin: 0;
  padding-top: 48px !important;
}

.lesson-code-copy {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: rgba(30, 30, 36, 0.92);
  color: var(--text-secondary);
  font-family: 'Noto Sans Arabic', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.lesson-code-copy:hover {
  background: rgba(45, 45, 52, 0.95);
  color: var(--text-primary);
  border-color: rgba(82, 68, 185, 0.4);
}

.lesson-code-copy.copied {
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.45);
}

[data-theme="light"] .lesson-code-copy {
  background: rgba(255, 255, 255, 0.95);
  color: #52525b;
  border-color: #e4e4e7;
}

[data-theme="light"] .lesson-code-copy:hover {
  background: #fff;
  color: #18181b;
}

.lesson-article pre.lesson-code-snippet {
  margin: 18px 0 26px;
  border-radius: 14px;
  overflow: auto;
  border: 1px solid var(--panel-border);
  direction: ltr;
  text-align: left;
  background: #1d1f21 !important;
  padding: 18px 22px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.lesson-article pre.lesson-code-snippet code {
  font-family: 'Fira Code', monospace;
  font-size: 14px;
  line-height: 1.75;
  background: none !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0;
  color: #f8f8f2;
  text-shadow: none;
  font-weight: 400;
}

/* الوضع الفاتح – خلفية فاتحة + ألوان واضحة (بما فيها Bash) */
[data-theme="light"] .lesson-article pre.lesson-code-snippet {
  background: #fafafa !important;
  border-color: #e4e4e7;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="light"] .lesson-article pre.lesson-code-snippet code {
  color: #24292e;
}

[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.comment,
[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.prolog {
  color: #6a737d;
}

[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.string,
[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.char {
  color: #0a7c42;
}

[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.keyword,
[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.builtin {
  color: #5244B9;
}

[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.function {
  color: #5244B9;
}

[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.operator,
[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.punctuation {
  color: #393f46;
}

[data-theme="light"] .lesson-article pre.lesson-code-snippet .token.number {
  color: #0550ae;
}

/* نص عادي داخل pre (مخرجات، مسارات…) */
.lesson-article pre.lesson-code-plain {
  background: var(--code-bg) !important;
  border-color: var(--panel-border);
}

.lesson-code-plain code {
  color: var(--code-text) !important;
  font-weight: 500;
}

[data-theme="light"] .lesson-article pre.lesson-code-plain {
  background: #f4f4f5 !important;
}

[data-theme="light"] .lesson-code-plain code {
  color: #18181b !important;
}

.lesson-pager {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.pager-btn {
  flex: 1;
  min-width: 160px;
}

.pager-btn.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.lesson-error {
  text-align: center;
  padding: 60px 24px;
}

.lesson-error h1 {
  margin-bottom: 16px;
}

.lesson-loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px;
}

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

/* Responsive */
@media (max-width: 992px) {
  .lesson-main {
    margin-right: 0;
    padding: 20px 20px 40px;
    align-items: stretch;
  }

  .lesson-article,
  .lesson-pager {
    max-width: 100%;
  }

  .lesson-sidebar {
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: var(--shadow-lg);
  }

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

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

  .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .lesson-article {
    padding: 28px 20px;
  }

  .lesson-article h1 {
    font-size: 26px;
  }
}

@media (max-width: 576px) {
  .lesson-breadcrumb {
    display: none;
  }

  .lesson-pager {
    flex-direction: column;
  }
}
/* حل مشكلة الخطوط المائلة وفصل رموز المقارنة في المتصفح */
.lesson-table code,
.lesson-section p code,
.lesson-section li code,
.lesson-article pre.lesson-code-snippet code {
  font-variant-ligatures: none !important;
}
