/* --- Base & Typography --- */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 70px; /* Increased from 56px to ensure anchors clear the header */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #1a1a1a;
  margin: 0;
}


img.logo {
  max-width: 100%;
  height: auto;
}


/* --- Navbar & Sidebar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  z-index: 1030;
  background-color: #111;
  /* Use your background image or fallback to dark gradient */
  background-image: linear-gradient(rgba(10,10,10,0.85), rgba(10,10,10,0.9)), url("/static/IBTM-Color_page-0001-removebg-preview.png");
  background-size: cover;
  background-position: center center;
  border-bottom: 1px solid #2a2a2a;
}

.sidebar, .offcanvas-start {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 250px;
  overflow-y: auto;
  background-color: #111;
  background-image: linear-gradient(rgba(10,10,10,0.9), rgba(10,10,10,0.95)), url("/static/IBTM-Color_page-0001-removebg-preview.png");
  background-size: cover;
  background-position: center center;
  border-right: 1px solid #2a2a2a;
}

.offcanvas-start {
  background-attachment: scroll;
  /* Mobile offcanvas covers whole screen height */
  top: 0; 
  height: 100vh;
  z-index: 1045;
  border-right: none;
}

/* --- Main Content --- */
.main-content {
  /* 1. Remove margin (this was the cause of the collapse/undersliding) */
  margin-top: 0; 

  /* 2. Use Padding to create a solid "wall" that pushes text down.
     56px (Header) + 24px (Breathing room) = 80px Total */
  padding-top: 80px; 
  
  /* Keep your other padding */
  padding-bottom: 1.5rem;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}


/* --- Sidebar Navigation --- */
.sidebar .nav-link, .offcanvas-body .nav-link {
  color: #adb5bd !important;
  border-radius: 0.375rem;
  margin-bottom: 4px;
  transition: all 0.2s ease-in-out;
  font-weight: 500;
  background-color: transparent; 
}

.sidebar .nav-link:hover, .offcanvas-body .nav-link:hover {
  color: #ffffff !important;
  background-color: rgba(0, 204, 102, 0.15);
  transform: translateX(4px);
}

.sidebar .nav-link.active, .offcanvas-body .nav-link.active {
    color: #ffffff !important;
    background-color: rgba(0, 204, 102, 0.25);
    border-left: 3px solid #00cc66;
}

/* --- Collapsible Headers (Categories) --- */
.collapsible-sidebar-heading {
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 0.75rem 1rem !important;
  cursor: pointer;
  display: flex !important;
  justify-content: space-between;
  align-items: center;
  color: #00cc66 !important; /* Always green text */
  background-color: rgba(0, 204, 102, 0.05);
  border-bottom: 1px solid rgba(0, 204, 102, 0.1);
  margin-top: 12px;
  transition: all 0.2s ease;
}

/* Chevron Arrow Indicator */
.collapsible-sidebar-heading::after {
    content: '';
    display: inline-block;
    width: 0.5em;
    height: 0.5em;
    border-right: 2px solid #00cc66;
    border-top: 2px solid #00cc66;
    transform: rotate(135deg); /* Pointing up (expanded) */
    transition: transform 0.3s ease;
    margin-left: 10px;
}

/* When Bootstrap adds the 'collapsed' class (closed) */
.collapsible-sidebar-heading.collapsed::after {
    transform: rotate(45deg); /* Pointing right/down */
}

.collapsible-sidebar-heading.collapsed {
    background-color: transparent;
    border-bottom: none;
    color: #adb5bd !important; /* Grey when closed */
}

/* Active Category (calculated in Jinja) */
.collapsible-sidebar-heading.active-category,
.collapsible-sidebar-heading:not(.collapsed) {
  box-shadow: 0 0 10px rgba(0, 204, 102, 0.1);
  background-color: rgba(0, 204, 102, 0.15);
  color: #fff !important;
}

.sidebar-logo-container {
  border-bottom: 1px solid rgba(0, 204, 102, 0.2);
}

/* --- Mobile adjustment (GLUE TO TOP FIX) --- */
@media (max-width: 768px) {
  .sidebar, .offcanvas-start {
    width: 100%;
    height: calc(100vh - 56px);
  }

  .main-content {
    margin-left: 0;
    margin-top: 56px; /* Exact height of navbar */
    padding: 1rem !important;
  }
  
  /* CHANGED: Increased padding-top here significantly. 
     Previously 0.5rem (8px) was too small, causing overlap. 
     Now 2rem (32px) ensures the title sits comfortably below the navbar. */
  .main-content > h1:first-child,
  .main-content > h2:first-child,
  .main-content > .content-section > h1:first-child,
  .main-content > .content-section > h2:first-child {
    margin-top: 0 !important;
    padding-top: 2rem !important; 
  }
}

/* --- Article Content & Typography --- */
.article-content h2,
.content-section h2 {
  font-weight: 600;
  color: #00ff88;
  border-bottom: 1px solid #333;
  padding-bottom: 8px;
  margin-top: 2.5rem;
  margin-bottom: 1.5rem;
}

.article-content h3,
.content-section h3 {
  font-weight: 600;
  color: #00cc66;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.article-content p, 
.content-section p {
  font-size: 1.05rem;
  line-height: 1.8;
  color: #e0e0e0;
  margin-bottom: 1.25rem;
}

.article-content ul, .content-section ul {
    line-height: 1.7;
    color: #e0e0e0;
}

.article-content a,
.content-section a {
  color: #00cc66;
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px dashed #00cc66;
  transition: all 0.2s ease;
}

.article-content a:hover,
.content-section a:hover {
  color: #00ff88;
  background-color: rgba(0, 204, 102, 0.1);
  border-bottom: 1px solid #00ff88;
}

/* Blockquotes */
.article-content blockquote,
.content-section blockquote {
  border-left: 4px solid #00cc66;
  padding: 1rem 1.5rem;
  background-color: rgba(255, 255, 255, 0.05);
  border-radius: 0 0.375rem 0.375rem 0;
  margin: 1.5rem 0;
  font-style: italic;
  color: #f0f0f0;
}

/* Code blocks */
.article-content pre,
.content-section pre {
  background-color: #000;
  border: 1px solid #333;
  border-radius: 0.375rem;
  padding: 1rem;
  overflow-x: auto;
}
.article-content code,
.content-section code {
  color: #00ff88;
  background-color: rgba(0, 204, 102, 0.1);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.9em;
}
.article-content pre code {
  background-color: transparent;
  padding: 0;
  color: #e0e0e0;
}

/* Inline Table of Contents */
.toc {
  background-color: rgba(20, 20, 20, 0.5);
  border: 1px solid #333;
  border-radius: 0.375rem;
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: inline-block;
  min-width: 250px;
}
.toc > ul {
  padding-left: 1rem;
  margin-bottom: 0;
}
.toc ul li {
  list-style-type: none;
  margin-bottom: 0.5rem;
}
.toc a {
  text-decoration: none;
  border: none;
  font-weight: 600;
  color: #adb5bd;
}
.toc a:hover {
  color: #00cc66;
  border: none;
}

/* Callout Blocks */
.callout {
  border-left: 5px solid;
  border-radius: 0.375rem;
  margin: 1.5rem 0;
  background-color: #222;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
.callout-header {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  background-color: rgba(255,255,255,0.02);
  font-weight: bold;
}
.callout-body { padding: 1.25rem; }
.callout-body p:last-child { margin-bottom: 0; }

.callout-note { border-left-color: #00cc66; }
.callout-note .callout-header { color: #00ff88; border-bottom-color: #00cc66; }

.callout-warning { border-left-color: #ffc107; }
.callout-warning .callout-header { color: #ffc107; border-bottom-color: #ffc107; }

.callout-tip { border-left-color: #0dcaf0; }
.callout-tip .callout-header { color: #0dcaf0; border-bottom-color: #0dcaf0; }

/* Back to Top Button */
#toTopBtn {
  opacity: 0.8;
  transition: all 0.3s ease;
}
#toTopBtn:hover {
  opacity: 1;
  transform: scale(1.05);
}

/* Anchor offset fix */
h1, h2, h3, h4, h5, h6, .article-content [id], .content-section [id] {
  scroll-margin-top: 70px;
}

