/* Default Color Variables - Can be overridden by custom-colors.php */
:root {
  --text: #e5e2e9;
  --primary: #7c60a4;  /* Purple for primary highlights */
  --secondary: #a1602b; /* Orange/brown for secondary highlights */
  --background: #121212; /* Darker background */
  --surface: #1e1e1e; /* Darker surface */
  --border: #333333;
  --hover: rgba(124, 96, 164, 0.1); /* Purple-tinted hover */
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  --link: #9f83c7; /* Lighter purple for links */
  --link-hover: #b69ddb; /* Even lighter purple for link hover */
}

.light-mode {
  --text: #333333;
  --primary: #7c60a4;
  --secondary: #a1602b;
  --background: #ffffff;
  --surface: #f5f5f7;
  --border: #e0e0e0;
  --hover: rgba(124, 96, 164, 0.05);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  --link: #7c60a4; /* Same purple but darker for light mode */
  --link-hover: #634d83; /* Darker purple for link hover in light mode */
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--background);
  color: var(--text);
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
  font-size: 14px;
}

/* Remove the light-mode class from body in HTML files */

/* Header Styles */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px; /* Keep horizontal padding */
  background-color: rgba(18, 18, 18, 0.8); /* Slightly transparent background matching page color */
  backdrop-filter: blur(10px); /* Add blur effect */
  -webkit-backdrop-filter: blur(10px); /* For Safari */
  position: fixed; /* Change to fixed instead of sticky */
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: 60px; /* Increased height from 50px to 60px */
  width: 100%; /* Full width */
  box-sizing: border-box;
}

/* Adjust for light mode */
.light-mode header {
  background-color: rgba(255, 255, 255, 0.8); /* Slightly transparent white for light mode */
}

/* Add a pseudo-element for the full-width border */
header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 1px;
  background-color: var(--border);
}

/* Adjust the header content to be centered within the full-width header */
.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.logo-container {
  display: flex;
  align-items: center;
}

.logo {
  height: 30px;
  margin-right: 8px;
}

.logo-text {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.website-btn {
  background-color: transparent; /* Remove background */
  color: var(--text);
  padding: 0.3rem 0.7rem;
  border-radius: 20px; /* Make edges more rounded */
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  transition: background-color 0.3s;
}

.website-btn:hover {
  background-color: rgba(124, 96, 164, 0.1); /* Primary color hover effect */
  border-color: var(--primary); /* Highlight border on hover */
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: transparent; /* Remove background */
}

.theme-toggle:hover {
  background-color: rgba(85, 85, 85, 0.05); /* Lighter hover effect */
}

/* Theme toggle icon display */
/* First, hide both icons by default */
.theme-toggle .fa-sun,
.theme-toggle .fa-moon {
  display: none;
}

/* In dark mode (default), show only the sun icon */
body:not(.light-mode) .theme-toggle .fa-sun {
  display: inline-block;
}

/* In light mode, show only the moon icon */
.light-mode .theme-toggle .fa-moon {
  display: inline-block;
}

/* Container Layout */
.container {
  display: flex;
  min-height: calc(100vh - 60px - 60px); /* Adjust for header and approximate footer height */
  max-width: 1200px;
  margin: 60px auto 0; /* Add top margin to account for fixed header */
  padding: 0 20px;
}

/* Sidebar Styles */
.sidebar {
  width: 180px;
  background-color: transparent;
  border-right: 1px solid var(--border);
  padding: 2rem 0.5rem 1rem 0; /* Increased top padding from 1rem to 2rem */
  overflow-y: auto; /* This already exists but let's make sure it works properly */
  height: calc(100vh - 60px); /* Height calculation based on viewport minus header */
  position: fixed;
  top: 60px;
  left: calc((100% - 1200px) / 2 + 20px);
  margin-right: 15px;
  -webkit-overflow-scrolling: touch; /* For better scrolling on iOS devices */
}

/* Also add top margin to the first sidebar group */
.sidebar-group:first-child {
  margin-top: 0.5rem;
}

.search-container {
  padding: 0 1.5rem 1.5rem;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background-color: var(--background);
  color: var(--text);
  font-size: 0.9rem;
}

.search-btn {
  position: absolute;
  left: 2rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text);
  opacity: 0.7;
}

.sidebar-nav {
  padding: 0 0.5rem;
}

.sidebar-group {
  margin-bottom: 0.8rem;
}

.sidebar-group-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0.4rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text); /* Ensure text color is used, not purple */
  border-radius: 3px;
  font-size: 0.9rem;
}

.sidebar-group-header:hover {
  background-color: rgba(85, 85, 85, 0.05);
}

.sidebar-group-content {
  list-style: none;
  padding-left: 0.8rem;
  margin-top: 0.3rem;
}

.sidebar-group-content li {
  margin-bottom: 0.3rem;
}

.sidebar-group-content a {
  display: block;
  padding: 0.4rem;
  color: var(--text);
  text-decoration: none;
  border-radius: 3px;
  transition: background-color 0.2s;
  font-size: 0.85rem;
}

.sidebar-group-content a:hover,
.sidebar-group-content a.active {
  background-color: rgba(85, 85, 85, 0.05);
  color: var(--text); /* Ensure text color is used, not purple */
}

.sidebar-group-content a.active {
  font-weight: 500;
  border-left: 2px solid var(--primary);
}

/* Standalone sidebar item (for Introduction) */
.sidebar-item {
    padding: 0.5rem 0.4rem;
    margin-bottom: 1rem;
}

.sidebar-item a {
    display: block;
    padding: 0.4rem;
    color: var(--text);
    text-decoration: none;
    border-radius: 3px;
    transition: background-color 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.sidebar-item a:hover,
.sidebar-item a.active {
    background-color: rgba(85, 85, 85, 0.05);
}

.sidebar-item a.active {
    color: var(--primary);
    border-left: 2px solid var(--primary);
    padding-left: calc(0.4rem - 2px);
}

/* Main wrapper to contain both content and footer */
.main-wrapper {
  flex: 1;
  margin-left: 180px; /* Same as sidebar width */
}

/* Main Content Styles */
.content {
  padding: 1.5rem 0 1.5rem 15px;
  max-width: 800px;
  margin-left: 0; /* Remove margin as it's now on the wrapper */
}

.breadcrumb {
  margin-bottom: 1.5rem;
  color: var(--text);
  opacity: 0.7;
  font-size: 0.8rem;
}

.breadcrumb a {
  color: var(--link);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
  color: var(--link-hover);
}

h1 {
  font-size: 1.8rem;
  margin-bottom: 1.2rem;
  color: var(--text); /* Ensure text color is used, not purple */
}

.article h2 {
  font-size: 1.4rem;
  margin: 1.5rem 0 0.8rem;
  color: var(--text); /* Ensure text color is used, not purple */
}

.article p {
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
}

.article ul {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}

.article li {
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
}

/* Add this to your styles.css file to fix ordered list alignment */
.article ol {
  margin-bottom: 1.2rem;
  padding-left: 1.5rem;
}

.article ol li {
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  padding-left: 0.3rem; /* Add some padding to align text better */
}

/* For nested lists */
.article ol ul, 
.article ul ol {
  margin-top: 0.4rem;
  margin-bottom: 0.4rem;
}

.info-box {
  background-color: var(--surface);
  border-left: 3px solid var(--primary);
  border-radius: 3px;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

.info-box-header {
  padding: 0.7rem;
  background-color: rgba(124, 96, 164, 0.1);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.info-box-content {
  padding: 0.7rem;
  font-size: 0.9rem;
}

.info-box-content p {
  margin-bottom: 0;
}

.article-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
}

.article-feedback {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.feedback-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.3rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.8rem;
}

.feedback-btn:hover {
  background-color: var(--hover);
  color: var(--text); /* Ensure text color is used, not purple */
}

.article-nav-next, .article-nav-prev {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text); /* Ensure text color is used, not purple */
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
}

.article-nav-next:hover, .article-nav-prev:hover {
  text-decoration: underline;
}


/* Responsive Design Enhancements */

/* Base responsive container */
.container {
  display: flex;
  min-height: calc(100vh - 60px - 60px); /* Adjust for header and approximate footer height */
  max-width: 1200px;
  margin: 60px auto 0; /* Add top margin to account for fixed header */
  padding: 0 20px;
}

/* Media queries for different screen sizes */
@media (max-width: 1240px) {
  .sidebar {
      left: 20px; /* Adjust sidebar position for smaller screens */
  }
  
  .main-wrapper {
      margin-left: 200px; /* Slightly adjust content margin */
  }
}

@media (max-width: 992px) {
  /* Tablet layout */
  .container {
      flex-direction: column;
      padding: 0 15px;
  }
  
  .sidebar {
      width: 100%;
      height: auto;
      position: relative;
      top: 0;
      left: 0;
      border-right: none;
      border-bottom: 1px solid var(--border);
      padding: 1rem 0;
      margin-right: 0;
  }
  
  .main-wrapper {
      margin-left: 0;
  }
  
  .content {
      padding: 1.5rem 0;
  }
  
  /* Add mobile sidebar toggle button */
  .mobile-sidebar-toggle {
      display: block;
      position: absolute;
      left: 20px;
      top: 50%;
      transform: translateY(-50%);
      background: none;
      border: none;
      color: var(--text);
      font-size: 1.2rem;
      cursor: pointer;
      z-index: 101;
  }
  
  /* Adjust header for mobile toggle */
  .header-content {
      padding-left: 40px; /* Make room for the toggle button */
  }
  
  /* Collapsible sidebar for mobile */
  .sidebar {
      display: none; /* Hide by default on mobile */
      transition: all 0.3s ease;
  }
  
  .sidebar.mobile-open {
      display: block;
  }
}

@media (max-width: 768px) {
  /* Mobile layout */
  header {
      height: 50px; /* Slightly smaller header */
  }
  
  .container {
      margin-top: 50px;
      padding: 0 10px;
  }
  
  .logo-text {
      font-size: 0.9rem;
  }
  
  .website-btn {
      font-size: 0.8rem;
      padding: 0.25rem 0.6rem;
  }
  
  h1 {
      font-size: 1.5rem;
  }
  
  .article h2 {
      font-size: 1.2rem;
  }
  
  .article p, .article li {
      font-size: 0.85rem;
  }
  
  /* Adjust footer for mobile */
  .footer-container {
      flex-direction: column;
      text-align: center;
      gap: 0.8rem;
      padding: 0 10px;
  }
  
  .footer-nav {
      justify-content: center;
      gap: 1rem;
      flex-wrap: wrap;
  }
  
  /* Adjust article footer for mobile */
  .article-footer {
      flex-direction: column;
      gap: 1rem;
      align-items: flex-start;
  }
  
  .article-nav {
      width: 100%;
      display: flex;
      justify-content: space-between;
  }
}

@media (max-width: 480px) {
  /* Small mobile layout */
  .header-right {
      gap: 0.3rem;
  }
  
  .website-btn {
      padding: 0.2rem 0.5rem;
      font-size: 0.75rem;
  }
  
  .theme-toggle {
      width: 25px;
      height: 25px;
  }
  
  .breadcrumb {
      font-size: 0.7rem;
  }
  
  /* Make tables responsive */
  table {
      display: block;
      overflow-x: auto;
      white-space: nowrap;
  }
  
  /* Adjust code blocks for small screens */
  pre {
      padding: 0.75rem;
      font-size: 0.8rem;
  }
}

/* Animation for collapsible sidebar */
.sidebar-group-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}

.sidebar-group.active .sidebar-group-content {
  max-height: 500px;
}

.sidebar-group.active .sidebar-group-header i {
  transform: rotate(180deg);
}

.sidebar-group-header i {
  transition: transform 0.3s;
}

/* Additional styling for code blocks */
pre {
  background-color: var(--surface);
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--secondary);
}

code {
  font-family: 'Courier New', Courier, monospace;
  color: var(--secondary);
}

/* Table styling */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

th, td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background-color: var(--surface);
  font-weight: 600;
  color: var(--primary);
}

tr:hover {
  background-color: var(--hover);
}

/* Image styling */
.article img {
  max-width: 100%;
  border-radius: 4px;
  margin: 1.5rem 0;
}

/* Blockquote styling */
blockquote {
  border-left: 4px solid var(--secondary);
  padding-left: 1rem;
  margin: 1.5rem 0;
  color: var(--text);
  opacity: 0.8;
  font-style: italic;
}

/* Feedback thanks message */
.feedback-thanks {
  margin-left: 0.5rem;
  font-size: 0.8rem;
  color: var(--text);
  opacity: 0.8;
}

/* Mobile sidebar toggle styles - fix visibility */
.mobile-sidebar-toggle {
    display: none; /* Hide by default on all screen sizes */
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 101;
    padding: 0.3rem;
}

/* Only show on mobile screens */
@media (max-width: 992px) {
    .mobile-sidebar-toggle {
        display: block; /* Only display on screens smaller than 992px */
    }
    
    /* Add space for the toggle button */
    .header-content {
        padding-left: 40px;
    }
}

/* Hide on desktop */
@media (min-width: 993px) {
    .mobile-sidebar-toggle {
        display: none !important; /* Force hide on desktop with !important */
    }
    
    .header-content {
        padding-left: 0; /* Remove padding on desktop */
    }
}

/* Footer Styles */
footer {
  width: 100%;
  padding: 1.2rem 0;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
  background-color: rgba(18, 18, 18, 0.8); /* Match header style */
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.light-mode footer {
  background-color: rgba(255, 255, 255, 0.8); /* Light mode version */
}

.footer-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.footer-left p {
  font-size: 0.85rem;
  color: var(--text);
  opacity: 0.8;
  margin: 0;
}

.footer-right {
  display: flex;
  align-items: center;
}

.footer-nav {
  display: flex;
  gap: 1.5rem;
}

.footer-nav a {
  color: var(--text);
  text-decoration: none;
  font-size: 0.85rem;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.footer-nav a:hover {
  opacity: 1;
}

/* Responsive footer adjustments */
@media (max-width: 768px) {
  .footer-container {
      flex-direction: column;
      text-align: center;
      gap: 0.8rem;
  }
  
  .footer-nav {
      justify-content: center;
      gap: 1rem;
  }
}

/* Mobile drawer menu styles */
@media (max-width: 992px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px; /* Start off-screen */
        width: 280px;
        height: 100vh;
        background-color: var(--background);
        z-index: 1000;
        transition: left 0.3s ease;
        padding: 70px 1.5rem 1.5rem; /* Add padding for header */
        border-right: 1px solid var(--border);
        overflow-y: auto;
        max-height: 100vh; /* Ensure it doesn't exceed viewport height */
        -webkit-overflow-scrolling: touch; /* For better scrolling on iOS devices */
    }
    
    .sidebar.mobile-open {
        left: 0; /* Slide in */
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    /* Overlay for when drawer is open */
    .overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(3px);
        -webkit-backdrop-filter: blur(3px);
        z-index: 999;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Adjust main wrapper when sidebar is open */
    .sidebar.mobile-open + .main-wrapper {
        opacity: 0.7;
    }
    
    /* Make sure the sidebar content doesn't get cut off at the bottom */
    .sidebar-nav {
        padding-bottom: 2rem; /* Add some bottom padding to ensure last items are visible */
    }
}

/* Smaller logo on mobile */
@media (max-width: 768px) {
    .logo {
        height: 20px; /* Reduced from 30px to 20px */
        margin-right: 6px; /* Slightly reduced margin */
    }
    
    .logo-text {
        font-size: 0.8rem; /* Reduced from 1rem to 0.8rem */
    }
}

/* Even smaller on very small screens */
@media (max-width: 480px) {
    .logo {
        height: 18px; /* Even smaller */
    }
    
    .logo-text {
        font-size: 0.75rem; /* Even smaller text */
    }
}

/* Consistent link styling in articles */
.article-link {
    color: var(--link);
    text-decoration: none;
    transition: color 0.2s;
}

.article-link:hover {
    color: var(--link-hover);
    text-decoration: underline;
}
