/* Custom Fonts */
@import url("https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap");

/* --- New Dark Theme Palette for Code Journey --- */
:root {
  --primary-color: #00ffa3; /* Vibrant Mint Green */
  --dark-background: #0a192f; /* Dark Navy Background */
  --light-background: #172a45; /* Lighter Navy for components */
  --primary-text-color: #ccd6f6; /* Light Slate/Gray for text */
  --secondary-text-color: #8892b0; /* Slate/Gray for subtitles */
  --border-color: #233554;
  --code-bg: #112240;
  --header-text: #fff; /* Kept for bright headings */

  /* The variables below are now mapped to the new theme */
  --background-color: var(--dark-background);
  --text-color: var(--primary-text-color);
  --sidebar-bg: var(--light-background);
  --header-bg: var(--light-background);
  --accent-color: var(--primary-color);
}

/* Base Styles */
body {
  font-family: "Cairo", sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--background-color);
  color: var(--text-color);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

/* Header (Navbar) - Adjusted from your code */
.navbar {
  background-color: rgba(10, 25, 47, 0.85); /* Slightly transparent */
  backdrop-filter: blur(10px);
  color: var(--text-color);
  padding: 15px 0;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar .container {
  display: flex;
  align-items: center;
  justify-content: center; /* يضمن تمركز العنوان */
  position: relative;
}

.title-container {
  text-align: center;
}

/* --- Responsive Sidebar (Hamburger Menu) --- */
#menu-toggle {
  display: none;
  position: absolute;
  top: 50%;
  left: 15px; /* Adjusted position */
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  z-index: 1001;
  padding: 10px;
  width: 50px;
  height: 50px;
}

#menu-toggle .hamburger-icon,
#menu-toggle .hamburger-icon::before,
#menu-toggle .hamburger-icon::after {
  background-color: var(--primary-text-color);
  width: 30px;
  height: 3px;
  display: block;
  position: relative;
  transition: all 0.3s ease;
}

#menu-toggle .hamburger-icon::before,
#menu-toggle .hamburger-icon::after {
  content: "";
  position: absolute;
}

#menu-toggle .hamburger-icon::before {
  top: -8px;
}

#menu-toggle .hamburger-icon::after {
  bottom: -8px;
}

/* --- Animation to 'X' mark --- */
#menu-toggle.active .hamburger-icon {
  background-color: transparent;
}

#menu-toggle.active .hamburger-icon::before {
  top: 0;
  transform: rotate(45deg);
  background-color: var(--primary-color);
}

#menu-toggle.active .hamburger-icon::after {
  bottom: 0;
  transform: rotate(-45deg);
  background-color: var(--primary-color);
}

/* Overlay for when menu is open */
#overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  z-index: 998;
}

/* Main Content Wrapper */
.main-content-wrapper {
  display: flex;
  padding-top: 30px;
}

/* Sidebar */
/* Sidebar */
.sidebar {
  flex: 0 0 280px;
  margin-left: 30px;
  padding: 20px;
  background-color: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  position: sticky;
  top: 48px;
  max-height: calc(100vh - 140px); /* نستخدم max-height بدلاً من height */
  overflow-y: auto;
  transition: transform 0.3s ease-in-out;
  z-index: 999;
}

.sidebar h2 {
  font-size: 1.8em;
  color: var(--primary-color);
  margin-top: 0;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
}

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

.sidebar nav ul li a {
  display: block;
  padding: 8px 10px;
  color: var(--text-color);
  text-decoration: none;
  border-radius: 5px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar nav ul li a:hover {
  background-color: rgba(0, 255, 163, 0.1);
  color: var(--primary-color);
}

.sidebar nav ul li a.active {
  background-color: var(--primary-color);
  color: var(--dark-background);
  font-weight: 600;
}

/* Main Content Area */
.content {
  flex: 1;
  padding: 30px;
  background-color: var(--sidebar-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.content h3 {
  font-size: 1.8em;
  margin-top: 0;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--border-color);
  color: var(--header-text);
}
.content h4 {
  font-size: 1.4em;
  color: var(--primary-text-color);
  margin-top: 30px;
}

/* Code Examples & Copy Button */
.code-example {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 25px;
  overflow-x: auto;
  position: relative;
}

.code-example pre,
.code-example code {
  font-family: "Consolas", "Monaco", monospace;
  color: #88c0d0; /* Light blue for code */
  white-space: pre-wrap;
  word-wrap: break-word;
}

.copy-btn {
  position: absolute;
  top: 10px;
  left: 10px;
  background-color: var(--secondary-text-color);
  color: white;
  border: none;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-family: "Cairo", sans-serif;
  font-size: 0.8em;
  opacity: 0.7;
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

.code-example:hover .copy-btn {
  opacity: 1;
}

.copy-btn:hover {
  background-color: var(--primary-color);
  color: var(--dark-background);
}

/* Exercise Box */
.exercise {
  background-color: rgba(0, 255, 163, 0.05);
  border-right: 5px solid var(--accent-color);
  border-radius: 5px;
  padding: 15px;
  margin-bottom: 25px;
  color: var(--primary-text-color);
}

/* --- Media Queries for Responsiveness --- */
@media (max-width: 992px) {
  .docs-page #menu-toggle {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 100px;
    right: 0;
    width: 280px;
    height: 75%;
    transform: translateX(100%);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    margin-left: 0;
    border-radius: 0;
    border: none;
  }
  .sidebar.show {
    transform: translateX(0);
  }
  #overlay.show {
    display: block;
  }
  .content {
    padding: 20px;
  }
}
/* Styling for the new Code Explanation Table */
.code-explanation-table {
  margin-bottom: 25px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  overflow: hidden;
}

.code-explanation-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95em;
}

.code-explanation-table td {
  padding: 12px 15px;
  vertical-align: top;
  border-bottom: 1px solid var(--border-color);
}

.code-explanation-table tr:last-child td {
  border-bottom: none;
}

.code-explanation-table .code-cell {
  background-color: var(--code-bg);
  width: 45%;
  direction: ltr;
  text-align: left;
}

.code-explanation-table .code-cell pre,
.code-explanation-table .code-cell code {
  margin: 0;
  padding: 0;
  font-family: "Consolas", "Monaco", monospace;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.code-explanation-table .explanation-cell {
  background-color: var(--sidebar-bg);
  line-height: 1.5;
}
/* --- Professional Header (Your code, adapted) --- */
.navbar-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo-area {
  position: absolute;
  right: 15px; /* Use px for better control */
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  background-color: transparent; /* Should not have a background */
}
.logo-area .logo-link {
  text-decoration: none;
}

.logo-area h2 {
  margin: 0;
  font-size: 1.8em;
  color: var(--primary-color);
  font-weight: 700;
}

.logo-area span {
  font-size: 1.1em;
  color: var(--secondary-text-color);
}
.logo-image {
  width: 122px;
  position: absolute;
  left: -1px;
  top: -40%;
}

.project-title-area {
  text-align: center;
  flex-grow: 1; /* Allow it to take up space */
}

.project-title-area h1 {
  margin: 0;
  font-size: 1.6em;
  font-weight: 600;
  color: var(--header-text);
}

.project-title-area p {
  margin: 5px 0 0;
  font-size: 0.9em;
  color: var(--secondary-text-color);
}

/* --- Professional Footer --- */
.site-footer {
  background-color: var(--header-bg);
  color: var(--secondary-text-color);
  padding: 50px 0 0;
  font-size: 0.95em;
  margin-top: 50px;
  border-top: 1px solid var(--border-color);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 40px;
  padding-bottom: 40px;
}

.footer-column h4 {
  font-size: 1.2em;
  color: var(--header-text);
  margin-top: 0;
  margin-bottom: 20px;
  font-weight: 600;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 10px;
  display: inline-block;
}

.footer-column h4 i {
  margin-left: 8px; /* For RTL */
}

.about-column p {
  line-height: 1.8;
}

.contact-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.contact-list li {
  margin-bottom: 15px;
}

.contact-list a {
  color: var(--secondary-text-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

.contact-list a:hover {
  color: var(--primary-color);
}

.contact-list i {
  margin-left: 10px;
  color: var(--primary-color);
  width: 20px;
  text-align: center;
}

.social-icons {
  display: flex;
  gap: 15px;
}

.social-icons a {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: #233554;
  color: var(--primary-text-color);
  text-decoration: none;
  font-size: 1.2em;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.social-icons a:hover {
  background-color: var(--primary-color);
  color: var(--dark-background);
  transform: translateY(-3px);
}

.social-icons a span {
  font-size: 0.7em;
  font-weight: bold;
}

.footer-bottom {
  border-top: 1px solid var(--border-color);
  text-align: center;
  padding: 20px 0;
  font-size: 0.9em;
}

/* --- Responsive Adjustments for Header/Footer --- */
@media (max-width: 992px) {
  #menu-toggle {
    order: 3;
  }
  .project-title-area {
    order: 2;
    flex-grow: 1;
    padding: 0 15px;
  }
  .logo-area {
    order: 1;
  }
}

@media (max-width: 768px) {
  .navbar {
    position: sticky;
  }
  .navbar-content {
    justify-content: space-between;
  }
  .logo-area {
    display: none;
  }
  .logo-image {
    display: none;
  }
}
/* --- Landing Page Specific Styles --- */

.landing-page-body {
  background-color: var(--dark-background);
}

/* Hero Section */
.hero {
  background: none;
  padding: 100px 0;
  text-align: center;
}

.hero-content h1 {
  font-size: 3.5em;
  font-weight: 700;
  color: var(--header-text);
  margin-bottom: 20px;
}

.hero-content .subtitle {
  font-size: 1.3em;
  color: var(--secondary-text-color);
  max-width: 700px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

.cta-button {
  background-color: transparent;
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  font-size: 1.2em;
  font-weight: 600;
  padding: 15px 35px;
  border-radius: 8px;
  text-decoration: none;
  transition: all 0.3s ease;
  display: inline-block;
  box-shadow: none;
}

.cta-button:hover {
  background-color: rgba(0, 255, 163, 0.1);
  transform: translateY(-3px);
  color: var(--primary-color);
}

.cta-button i {
  margin-right: 10px;
  transition: transform 0.3s ease;
}

.cta-button:hover i {
  transform: translateX(-5px);
}

/* General Section Styling */
.features,
.curriculum,
.quote,
.final-cta {
  padding: 80px 0;
  text-align: center;
}

.features h2,
.curriculum h2,
.final-cta h2 {
  font-size: 2.5em;
  margin-bottom: 20px;
  color: var(--header-text);
}

.curriculum p,
.final-cta p {
  font-size: 1.1em;
  color: var(--secondary-text-color);
  margin-bottom: 40px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* Features Section */
.features {
  background-color: var(--dark-background);
}
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 30px;
  margin-top: 50px;
  text-align: right;
}

.feature-card {
  background-color: var(--light-background);
  padding: 30px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: transform 0.3s ease, border-color 0.3s ease;
}

.feature-card:hover {
  transform: translateY(-10px);
  border-color: var(--primary-color);
}

.feature-card i {
  font-size: 2.5em;
  color: var(--primary-color);
  margin-bottom: 20px;
}

.feature-card h3 {
  font-size: 1.5em;
  margin-bottom: 15px;
  color: var(--header-text);
}

.feature-card p {
  color: var(--secondary-text-color);
  line-height: 1.8;
}

/* Curriculum Section */
.curriculum-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 15px;
}

.curriculum-tags span {
  background-color: var(--light-background);
  color: var(--primary-color);
  padding: 10px 20px;
  border-radius: 20px;
  font-weight: 600;
  border: 1px solid var(--border-color);
}

/* Quote Section */
.quote {
  background-color: var(--light-background);
  color: var(--header-text);
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}

.quote blockquote {
  border: none;
  padding: 0;
  margin: 0 auto;
  max-width: 800px;
}

.quote blockquote p {
  font-size: 1.5em;
  font-style: italic;
  line-height: 1.8;
  margin-bottom: 20px;
}

.quote blockquote cite {
  font-size: 1.1em;
  font-weight: 600;
  color: var(--primary-color);
}

/* Final CTA Section */
.final-cta {
  background-color: var(--dark-background);
}

/* Responsive Landing Page */
@media (max-width: 768px) {
  .hero-content h1 {
    font-size: 2.5em;
  }
  .hero-content .subtitle {
    font-size: 1.1em;
  }
  .features h2,
  .curriculum h2,
  .final-cta h2 {
    font-size: 2em;
  }
}
/* --- Elegant Loader --- */
.loader-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 300px; /* يعطي مساحة للتحميل ليظهر بشكل جيد */
  transition: opacity 0.3s ease;
}

.loader {
  border: 5px solid var(--border-color); /* لون الدائرة الأساسي */
  border-top: 5px solid var(--primary-color); /* لون الجزء المتحرك من الدائرة */
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
}

.loading-text {
  margin-top: 20px;
  font-size: 1.1em;
  color: var(--secondary-text-color);
  letter-spacing: 1px;
}

/* حركة الدوران */
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
/* --- Solutions Page Specific Styles --- */
.solutions-page .content, .solutions-page .sidebar {
    /* نضمن أن الشريط الجانبي في صفحة الحلول يتبع نفس النمط */
    top: 110px;
}

.solutions-page main.content {
    border: none;
    background-color: transparent;
    padding: 0;
}

.solution-topic-block {
    background-color: var(--light-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px; /* تقليل المسافة بين الحلول */
}

.solution-topic-block h4 {
    color: var(--primary-color);
    font-size: 1.2em;
    margin-top: 20px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid var(--border-color);
}
.solution-topic-block h4:first-of-type {
    margin-top: 0;
}

.solution-topic-block .exercise-question {
    font-weight: 600;
    color: var(--primary-text-color);
    line-height: 1.8;
}

.solution-topic-block p {
    line-height: 1.8;
    color: var(--secondary-text-color);
}

/* Re-use code-example for solution code blocks */
.solution-code {
    margin-top: 10px;
}