/* --- Global  --- */
html {
  box-sizing: border-box;
}
*, *:before, *:after {
  box-sizing: inherit;
}


/* Ensure html and body take full viewport and have no unexpected spacing */
html, body {
  width: 100%;
  margin: 0;
  padding: 0; 
}


/* Text wrapping for common block elements to prevent overflow */
p, li, h1, h2, h3, h4, h5, h6, div {
  word-wrap: break-word;   /* Older browsers */
  overflow-wrap: break-word; /* Standard property */
}


/* --- Base Styles --- */
body {
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.6;
  background-color: #ffffff;
  color: #000000;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden; /* Prevents horizontal scrollbar on body if something overflows */
}


/* --- Emphasis Styles --- */
.box {
  padding: 5px;
  padding-left: 10px;
  padding-right: 10px;
  margin-top: 1.2em;
  margin-bottom: 1.2em;
  border-radius: 4px;
}

#manual-content .box h4, p {
  margin-top: 0px;
}

.important-info {
  background-color: #e7f3fe; /* Light Blue */
  border: 3px solid #b8d9f8;  /* Complementary Blue Border */
}

.best-practice {
  background-color: #e6ffed; /* Light Green */
  border: 3px solid #a3d9b1;  /* Medium Green Border */
}

.warning {
  background-color: #fce8e6; /* Light Desaturated Red */
  border: 3px solid #ea9999;  /* Muted Red Border */
}


/* Ensure flex items can shrink properly */
header,
#table-of-contents,
#manual-content,
footer {
  min-width: 0;
}

header {
  background-color: #f8f9fa;
  padding: 20px 40px;
  text-align: center;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0; /* Header should not shrink */
}
header h1 {
  margin: 0;
  font-size: 2.2em;
  font-weight: 600;
}
header h2 {
  margin: 5px 0 0;
  font-size: 1.3em;
  color: #495057;
  font-weight: 400;
}
#table-of-contents {
  max-width: 900px;         /* Match #manual-content for consistency */
  margin-left: auto;        /* Center the block */
  margin-right: auto;       /* Center the block */
  width: 100%;              /* Use available width up to max-width */
  box-sizing: border-box;   /* Include padding in width calculation */
  padding: 20px 40px;       /* Inner padding */
  background-color: #f1f3f5;
  border-bottom: 1px solid #dee2e6;
  margin-bottom: 30px;
  flex-shrink: 0;           /* Table of Contents should not shrink */
}

#table-of-contents h3 {
  margin-top: 0;
  margin-bottom: 20px; 
  font-size: 1.6em;
  font-weight: 600;
}

#table-of-contents ul {
  list-style-type: none;
  padding-left: 0;
  margin-top: 0;
  margin-bottom: 0;
}

/* General style for all list items in ToC */
#table-of-contents ul li {
  margin-bottom: 6px;     
}

/* Specific style for top-level chapter list items */
#table-of-contents > ul > li {
  margin-bottom: 0.9em;     /* More space after a main chapter block (approx 14px) */
}

#table-of-contents ul ul {
  padding-left: 25px;       /* Indentation for sub-levels */
  margin-top: 6px;          /* Space above a sub-list */
}

#table-of-contents .TOC_TOP {
 font-size: 1.3em;
}

#table-of-contents .TOC_SM {
 font-size: 0.95em;
}

/* Link styles */
#table-of-contents a,
#table-of-contents a:link,
#table-of-contents a:visited,
#table-of-contents a:active {
    color: #000000;
    text-decoration: none;
    font-weight: 500;
}
#table-of-contents a:hover {
    color: #000000;
    text-decoration: underline;
}

#manual-content {
  flex: 1; /* Allows main content to grow and fill available vertical space */
  padding: 0px 40px 40px 40px;
  max-width: 900px; /* Content will not exceed this width */
  margin: 0 auto;   /* Centers content when viewport > max-width */
  width: 100%;      /* Ensures it tries to use available width up to max-width */
}
#manual-content h1,
#manual-content h2,
#manual-content h3,
#manual-content h4,
#manual-content h5,
#manual-content h6 {
  color: #212529;
  margin-top: 2em;
  margin-bottom: 0.8em;
  scroll-margin-top: 20px;
  font-weight: 600;
}
#manual-content h1 {
  font-size: 2em;
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 0.4em;
}
#manual-content h2 {
  font-size: 1.7em;
  border-bottom: 1px solid #e9ecef;
  padding-bottom: 0.3em;
}
#manual-content h3 {
  font-size: 1.4em;
}
#manual-content h4 {
  font-size: 1.2em;
}

a,
a:link,
a:visited,
a:active {
    color: inherit;
    text-decoration: none;
}
a:hover {
    color: inherit;
    text-decoration: underline;
}

p {
  margin-bottom: 1.2em;
  text-align: left;
}
#manual-content ul,
#manual-content ol {
  margin-bottom: 1.2em;
  padding-left: 30px;
}
#manual-content ul li,
#manual-content ol li {
  margin-bottom: 0.6em;
  text-align: left;
}
#manual-content ul ul,
#manual-content ol ol {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

pre {
  /* Essential for layout and scrolling */
  display: block; /* Default, but explicit */
  max-width: 100%; /* Constrain the <pre> block itself */
  overflow-x: auto; /* Allow horizontal scrolling FOR THE CONTENT INSIDE PRE */
  white-space: pre; /* Preserve code formatting, prevent line wrapping */
  box-sizing: border-box; /* Include padding and border in the element's total width and height */

  background-color: #e9ecef;
  border: 1px solid #ced4da;
  padding: 15px; /* Base padding */
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 0.875em; /* Base font size */
  margin-bottom: 1.5em;
}

code {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  background-color: #f8f9fa;
  padding: .2em .4em;
  border-radius: 3px;
  font-size: 0.875em;
  color: #bf0000;
  border: 1px solid #e0e0e0;
}
pre > code {
  background-color: transparent;
  padding: 0;
  border-radius: 0;
  font-size: 1em;
  color: inherit;
  border: none;
  margin-left: 0;
  margin-right: 0;
  white-space: pre-wrap;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 25px auto;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

strong {
  font-weight: 600;
}
hr {
  border: 0;
  height: 1px;
  background-color: #ced4da;
  margin: 2.5em 0;
  width: 100%; /* Ensure hr doesn't have odd default width/margins */
}

footer {
  text-align: center;
  padding: 25px 40px;
  background-color: #f8f9fa;
  border-top: 1px solid #dee2e6;
  font-size: 0.9em;
  color: #6c757d;
  margin-top: auto;
  flex-shrink: 0; /* Footer should not shrink */
}



/* --- Responsive Styles --- */
@media (max-width: 768px) {
  header {
    padding: 15px;
  }
  header h1 {
    font-size: 1.8em;
  }
  header h2 {
    font-size: 1.1em;
  }

  #table-of-contents {
    /* Padding adjusted for smaller screens, max-width and margin:auto still apply */
    padding: 15px;
    margin-bottom: 20px;
  }
  #table-of-contents h3 {
    font-size: 1.3em;
  }
  #table-of-contents ul ul {
    padding-left: 15px;
  }

  #manual-content {
    padding: 0 15px 20px 15px; /* Reduced padding for content area */
  }

  #manual-content h1 { font-size: 1.7em; }
  #manual-content h2 { font-size: 1.5em; }
  #manual-content h3 { font-size: 1.2em; }

  pre {
    padding: 10px;
    font-size: 0.8em;
  }

  #manual-content ul img,
  #manual-content ol img {
    margin-left: 0;
    margin-right: 0;
  }

  #manual-content ul,
  #manual-content ol {
    padding-left: 20px; /* Reduce list indentation */
  }

  footer {
    padding: 20px 15px;
    font-size: 0.85em;
  }
}

@media (max-width: 480px) {
  header h1 { font-size: 1.6em; }
  header h2 { font-size: 1.0em; }

  #manual-content {
    padding: 0 10px 20px 10px; /* Further reduced padding for very small screens */
  }
  #manual-content h1 { font-size: 1.5em; }
  #manual-content h2 { font-size: 1.3em; }


  #table-of-contents h3 { font-size: 1.2em; }
  #table-of-contents ul li { font-size: 0.95em; }

  #manual-content ul,
  #manual-content ol {
    padding-left: 15px; /* Further reduce list indentation */
  }
}



/* --- Print Styles --- */
@media print {
  html, body {
    width: auto; /* Reset for print */
    height: auto;
    overflow: visible; /* Show all content for print */
  }
  .page-break, #manual-content h1 { /* Ensure h1 starts on a new page when printing */
    page-break-before: always;
    break-before: page;
  } 
  
  #manual-content h1.no-page-break-before {
    page-break-before: auto; /* Reset to default */
    break-before: auto;      /* Reset to default */
  }
  
  a::after {
    content: ""; /* prevents showing the URL */
  }
  a {
    pointer-events: none;
    color: inherit;
    text-decoration: none;
  }
}

@media (max-width: 768px) {

  #table-of-contents {
    padding-left: 25px;
	padding-right: 20px;
  }
  
  #manual-content {
    padding-left: 25px;
	padding-right: 20px;
  }
}