/* === Responsive full-width page layout with smart padding === */

/* Large screens (≥992px): full-width content with custom padding */
@media (min-width: 992px) {
  .container,
  .container-fluid,
  .main-container,
  .main-container > .row,
  .content {
    max-width: 100% !important;
    width: 100% !important;
    padding-left: 40px !important;   /* You can tweak */
    padding-right: 40px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }
}

/* Small & medium screens (<992px): safe padding preserved */
/* === Disable floating TOC on mobile (stack it normally) === */
@media (max-width: 991px) {
  #TOC {
    float: none !important;
    position: relative !important;
    width: 100% !important;
    max-width: 100% !important;
    margin-bottom: 20px;
    padding: 0 16px;
    border-left: none !important;
    border-right: none !important;
  }

  /* Optional: center align TOC on mobile */
  #TOC .tocify-item {
    border-left: none !important;
    text-align: left;
    padding-left: 0;
  }

  .col-md-3 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
  }

  .col-md-9 {
    width: 100% !important;
    max-width: 100% !important;
    flex: 0 0 100% !important;
    margin-left: 0 !important;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}



/* --- RESET & BASE TYPOGRAPHY --- */
body {
  font-size: 18px;
  padding-top: 80px;
  counter-reset: fig-num package-plot-num package-table-num;
  transition: padding-top 0.3s ease;
  font-weight: 400;
  line-height: 1.6;
  background-color: #F5F5F7 !important;
}

h1, h2, h3, h4, h5, h6 {
  color: #003366;
  font-weight: bold;
}

h1 { font-size: 34px; }
h2 { 
  font-size: 28px; 
  margin-top: 2.5rem;
}
h3 { font-size: 24px; }
h4 { font-size: 20px; }
code, pre { font-size: 16px; }

/* --- SECTION DIVIDERS --- */
h1::before {
  content: "";
  display: block;
  border-top: 1px solid #ccc;
  margin: 40px 0 20px 0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.03);
  border-radius: 0.5px;
}

/* Specific fix for step2, step3, and FAQs layout issues */
body .container-fluid.main-container {
  display: flex;
  flex-direction: column;
}

@media (min-width: 992px) {
  body .container-fluid.main-container > .row {
    display: flex !important;
    flex-direction: row !important;
    width: 100% !important;
  }
  
  body .container-fluid.main-container > .row > .col-md-3,
  body .container-fluid.main-container > .row > div:first-child {
    width: 300px !important;
    flex: 0 0 300px !important;
    position: fixed !important;
    height: calc(100vh - 100px);
    overflow-y: auto;
    top: 80px;
  }
  
  body .container-fluid.main-container > .row > .col-md-9,
  body .container-fluid.main-container > .row > div:nth-child(2) {
    margin-left: 320px !important;
    width: calc(100% - 320px) !important;
    flex: 1 1 auto !important;
  }
}

/* === TOC Modern GTAP Style === */

/* TOC wrapper reset */
#TOC {
  border: none !important;
  background: none !important;
  box-shadow: none !important;
  padding: 0 !important;
}

/* TOC list and items */
#TOC ul {
  padding-left: 1.2em;
  margin-top: 0.6em;
  margin-bottom: 0.6em;
}

#TOC ul li {
  margin: 6px 0;
  list-style: none;
}

/* All TOC items */
#TOC .tocify-item {
  font-size: 18px;
  line-height: 1.6;
  padding: 4px 12px;
  color: #003366 !important;             /* Always gold */
  border-left: 3px solid transparent;
  font-weight: normal;
  background: none !important;
  transition: all 0.3s ease;
}

/* Hover effect */
#TOC .tocify-item:hover {
  color: #B5853F !important;
  border-left: 4px solid #003366;
}

/* Active TOC item (highlighted section) */
#TOC .tocify-focus,
#TOC .tocify-focus.tocify-item,
#TOC .tocify-item.tocify-focus {
  font-weight: bold !important;
  color: #B5853F !important;
  border-left: 4px solid #003366 !important;
  background: none !important;
  background-color: transparent !important;
  border-radius: 0 !important;
}

/* Also override Bootstrap-styled .active if present */
#TOC li.active,
#TOC li.active > a,
#TOC li.tocify-focus,
#TOC li.tocify-focus > a {
  background: none !important;
  background-color: transparent !important;
  font-weight: bold !important;
  color: #B5853F !important;
  border-left: 4px solid #003366 !important;
}

@media (min-width: 992px) {
  /* TOC block */
  .col-md-3 {
    width: 300px !important;
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  #TOC {
    width: 100% !important;
    max-width: 100% !important;
    margin-right: 0 !important;
  }

  /* Content block with clear margin */
  .col-md-9 {
    width: auto !important;
    max-width: none !important;
    margin-left: 90px !important;     /* ← FIXED SPACE FROM TOC */
    padding-left: 60px !important;
    padding-right: 90px !important;
  }

  /* Safety reset if needed */
  .content,
  .main-container .content {
    margin-left: 0 !important;
    padding-left: 0 !important;
  }
}

/* --- FIGURE & TABLE CONTAINERS --- */
.center-figure, .package-figure, .package-table {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: 20px auto;
}

.package-figure, .package-table {
  counter-increment: package-plot-num package-table-num;
}

.package-figure figcaption::before {
  content: "Plot " counter(package-plot-num) ": ";
  font-weight: bold;
}

.package-table figcaption::before {
  content: "Table " counter(package-table-num) ": ";
  font-weight: bold;
}

/* --- BOX STYLES --- */
.code-box, .table-box, .package-figure-box, .package-table-box {
  border: 1px solid #ccc;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
  padding: 10px;
  border-radius: 5px;
  background-color: #FAFAFA;
  display: inline-block;
  width: fit-content;
  font-size: 14px !important;
}

/* --- FIGURE NOTES --- */
.figure-note, .package-fig-note, .package-table-note {
  font-size: 90%;
  color: #555;
  font-style: italic;
  text-align: center;
  margin-top: 5px;
}

/* --- WIDE TABLE STYLING --- */
.table-box table {
  border-collapse: collapse;
  width: 100%;
}

.table-box th, .table-box td {
  border: 1px solid #ABB2BF;
  padding: 8px;
  text-align: left;
}

/* --- INFO BOXES --- */
.tip-box {
  background-color: #E8F4FD;
  border-left: 5px solid #5B9BD5;
  padding: 10px 15px;
  margin: 15px 0;
  border-radius: 4px;
  font-size: 16px;
}

.info-box {
  background-color: #FDF8E4;
  border-left: 5px solid #E8A317;
  padding: 15px 20px;
  margin: 20px 0;
  border-radius: 6px;
  font-size: 17px;
  font-weight: 400;
  color: #5C3D00;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

.note-box, details.note-box {
  background-color: #F7F7F7;
  border-left: 4px solid #999;
  padding: 12px 16px;
  margin: 16px 0;
  border-radius: 4px;
  font-size: 16px;
  color: #333;
  box-shadow: 1px 1px 4px rgba(0, 0, 0, 0.05);
}

/* --- FOLDER TREE --- */
.folder-tree {
  background-color: #FAFAFA;
  border: 1px solid #ccc;
  border-radius: 5px;
  padding: 10px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
  display: inline-block;
  width: fit-content;
  font-family: "Courier New", monospace;
  font-size: 15px;
  white-space: pre;
  line-height: 1.4;
  text-align: left;
  position: relative;
}

.folder-tree .copy-code-button,
.folder-tree pre::after {
  display: none !important;
}

.folder-tree pre,
.folder-tree code {
  background: none !important;
  border: none !important;
  padding: 0 !important;
  margin: 0 !important;
  box-shadow: none !important;
}

/* --- TOGGLE STYLES --- */
.toggle-summary, .toggle-code-summary, .toggle-info {
  font-weight: bold;
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
}

.toggle-summary {
  color: #F2A900;
  background-color: #003366;
}

.toggle-code-summary {
  position: relative;
  padding: 8px 14px;
  margin: 14px 0 18px 1.1em; /* same as toggle-summary */
  font-family: monospace;
  font-size: 15px;
  font-weight: bold;
  background-color: #f5f5f5;
  color: #333;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 1px 1px 6px rgba(0, 0, 0, 0.08);
  overflow: visible;
  z-index: 0;
}

/* GTAP Stripe 1 (Navy) */
.toggle-code-summary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -0.8em;
  width: 0.3em;
  height: 100%;
  background-color: #003366;
  z-index: -1;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}

/* GTAP Stripe 2 (Gold) */
.toggle-code-summary::after {
  content: "";
  position: absolute;
  top: 0;
  left: -0.4em;
  width: 0.3em;
  height: 100%;
  background-color: #F2A900;
  z-index: -1;
  border-top-left-radius: 3px;
  border-bottom-left-radius: 3px;
}


.toggle-code-summary:not([hidden]) {
  margin-bottom: 1.1rem; /* Adjust as needed */
}

.toggle-info {
  color: #8B5E00; 
  border-left: 5px solid #E8A317;
  background-color: #FDF8E4;
  font-weight: bold;
}

.toggle-note {
  font-weight: bold;
  padding: 4px 12px;
  margin: 0;
  background-color: #F7F7F7;
  text-align: left;
  border-radius: 4px;
  cursor: pointer;
  line-height: 1.4;
  display: list-item;  /* Keep arrow */
}

/* --- R CODE CHUNK STYLING --- */
pre {
  position: relative;
  margin-top: 0.9rem !important;
  margin-bottom: 1.5rem !important;
}

pre.r {
  position: relative;
  display: block;
  padding: 10px;
  margin-left: 1.1em; /* shift box to make room for stripes */
  background-color: #FAFAFA;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.1);
  font-size: 14px !important;
  white-space: pre;
  overflow: visible !important;  /* KEY: allow ::before to show outside */
  z-index: 0;
}

/* GTAP Stripe 1 (Navy) */
pre.r::before {
  content: "";
  position: absolute;
  top: 0;
  left: -0.8em;
  width: 0.3em;
  height: 100%;
  background-color: #003366;
  z-index: -1;
}

/* GTAP Stripe 2 (Gold) */
pre.r::after {
  content: "";
  position: absolute;
  top: 0;
  left: -0.4em;
  width: 0.3em;
  height: 100%;
  background-color: #F2A900;
  z-index: -1;
}

/* --- HR ELEMENT --- */
hr {
  border: none;
  height: 2px;
  background: linear-gradient(to right, #bbb, #ccc);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin: 2rem 0;
}

/* --- COMMON ISSUE STYLE --- */
.common-issue {
  font-weight: bold;
  color: #8B0000;  /* dark red */
  font-size: 100%;
}

/* --- COPY BUTTON --- */
.copy-code-button {
  background-color: #003366;
  color: #F2A900;
  border: none;
  font-weight: bold;
  padding: 4px 10px;
  font-size: 0.9rem;
  border-radius: 5px;
  cursor: pointer;
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 10;
  transform: scale(1);
  transition: transform 0.15s ease, background-color 0.3s ease, color 0.3s ease;
}

.copy-code-button:hover {
  transform: scale(1.08); /* Smooth zoom */
}

.copy-code-button.copied {
  background-color: #F2A900 !important;
  color: #003366 !important;
  transform: scale(1.1);
}

/* === FIXED NAVBAR STYLING === */
.navbar a.brand-fake {
  font-weight: bold;
  color: #F2A900 !important;
  font-size: 20px;
  margin-right: 30px;
}
/* Basic responsive navbar styles */
.navbar {
  background-color: #003366 !important;
  color: white !important;
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
}

/* Navbar links */
.navbar a {
  color: white !important;
  text-decoration: none;
}

.navbar a:hover {
  color: #F2A900 !important;
}

/* Fix for active navbar item - make it just bold text without background */
.navbar-nav > li > a.active,
.navbar-nav > li.active > a,
.navbar a.is-active,
.navbar li.active a {
  font-weight: bold !important;
  color: #F2A900 !important;
  background-color: transparent !important;
  background: none !important;
  text-decoration: none !important;
  box-shadow: none !important;
  border: none !important;
}

/* Additional specificity for Bootstrap's typical active classes */
.navbar .nav-item.active .nav-link,
.navbar .nav-link.active,
.navbar .active > .nav-link {
  font-weight: bold !important;
  color: #F2A900 !important;
  background-color: transparent !important;
  background: none !important;
}

/* Fix for the project setup style specifically */
.navbar #project-setup-link.active,
.navbar a[href*="project-setup"].active,
.navbar li.active a[href*="project-setup"] {
  background-color: transparent !important;
  background: none !important;
  font-weight: bold !important;
  color: #F2A900 !important;
}

/* ChatGPT special button */
.navbar-nav > li > a.chatgpt-link,
.navbar-nav > li > a[href*="chatgpt.com"] {
  background-color: #F2A900 !important;
  color: black !important;
  font-weight: bold;
  padding: 10px 15px;
  border-radius: 4px;
  margin-top: 5px;
}

/* DESKTOP STYLES */
@media (min-width: 769px) {
  .navbar-collapse {
    display: flex !important;
  }
  
  .navbar-nav {
    display: flex;
    flex-direction: row;
  }
  
  .navbar-nav .nav-item {
    margin-right: 15px;
  }
  
  .navbar-toggler {
    display: none !important;
  }
}

/* MOBILE STYLES */
@media (max-width: 768px) {
  /* Hide navbar by default on mobile */
  .navbar-collapse {
    display: none;
    position: absolute;
    top: 56px;
    left: 0;
    width: 100%;
    background-color: #003366;
    box-shadow: 0 5px 10px rgba(0,0,0,0.2);
    padding: 0;
  }
  
  /* Show navbar when toggled */
  .navbar-collapse.show {
    display: block !important;
  }
  
  /* Style the navbar items in mobile view */
  .navbar-nav {
    flex-direction: column;
    width: 100%;
    margin: 0;
    padding: 0;
  }
  
  .navbar-nav .nav-item {
    width: 100%;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin: 0;
  }
  
  .navbar-nav .nav-item > a {
    padding: 15px;
    display: block;
    width: 100%;
  }
  
  /* Toggle button styling */
  .navbar-toggler {
    display: block !important;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.5);
    padding: 10px;
    margin-left: auto;
    cursor: pointer;
  }
  
  .navbar-toggler .icon-bar {
    display: block;
    width: 22px;
    height: 2px;
    background-color: white !important;
    margin: 4px 0;
  }
  
  /* Full-width ChatGPT button on mobile */
  .navbar-nav > li > a.chatgpt-link,
  .navbar-nav > li > a[href*="chatgpt.com"] {
    width: calc(100% - 30px);
    margin: 10px 15px;
    text-align: center;
  }
}

