/* Global Styles & Lato Font Application */
body {
    font-family: 'Lato', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    /*background-color: #f4f4f4;*/
    background-color: #1a1a1a;
    color: #333;
}

/* Header Styles */
header {
    background-color: #004A7C; 
    color: white;
    padding: 1em 20px;
    text-align: center;
}

header h1 {
    margin: 0 0 0.5em 0;
    font-size: 1.8em;
}

.subheader {
    font-size: 0.9em;
    max-width: 800px;
    margin: 0 auto;
}

.subheader p {
    margin: 0.3em 0;
}

/* "Prepare All Chapters" Button Styles */
.offline-controls {
    margin-top: 15px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

#download-all-button {
    background-color: #2196F3; 
    color: white;
    border: none;
    padding: 10px 15px;
    font-size: 0.9em;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

#download-all-button:hover {
    background-color: #1976D2; 
}

#download-all-button:disabled {
    background-color: #9E9E9E; 
    cursor: not-allowed;
}

#download-status {
    font-size: 0.85em;
    margin-top: 8px;
    color: #f0f0f0;
    min-height: 1.2em; 
}

/* Table of Contents Navigation */
nav#toc-nav {
    padding: 15px 20px;
    background-color: #333;
    text-align: center;
}

nav#toc-nav h2 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.4em;
}

#chapter-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
}

#chapter-list li {
    margin: 5px;
}

#chapter-list button, .subsection-links button {
    background-color: #003366;
    color: white;
    border: none;
    padding: 10px 15px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 1em;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

#chapter-list button:hover, .subsection-links button:hover {
    background-color: #1976D2;
}

#chapter-list button.active {
    background-color: #2196F3;
    /*font-weight: bold;*/
}

/* Main Content Area */
main {
    padding: 20px;
    max-width: 900px;
    margin: 20px auto; 
    background-color: white;
    /*box-shadow: 0 0 10px rgba(0,0,0,0.1);*/
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    border-radius: 5px; 
}

/* Search Bar */
.search-container {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
}

#search-input {
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
}

#search-button, #clear-search-button {
    padding: 10px 15px;
    background-color: #5cb85c; 
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
}
#clear-search-button {
    background-color: #f0ad4e; 
}

#search-button:hover {
    background-color: #4cae4c;
}
#clear-search-button:hover {
    background-color: #ec971f;
}

/* Subsection Links */
#subsection-links-container {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}
#subsection-links-container h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.2em;
}
.subsection-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

hr.content-divider {
    border: 0;
    height: 1px;
    background: #ddd;
    margin: 20px 0;
}

/* Content Display Area (from chapters) */
#content-display {
    margin-top: 20px;
}

#content-display p, #content-display li, #content-display td, #content-display th {
    font-size: 1rem; /* Base font size for content */
    color: #333;
}

#content-display h1, #content-display h2, #content-display h3, #content-display h4,
#content-display .SectionHead, #content-display .SubChapterHead { /* If your local HTML uses these classes */
    font-family: 'Lato', sans-serif; /* Ensure Lato for headings from source */
    color: #004A7C;
}

#content-display .SectionHead { 
    font-weight: bold;
    font-size: 1.3em;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}
#content-display .SubChapterHead { 
    font-weight: bold;
    font-size: 1.1em;
    margin-top: 1em;
    margin-bottom: 0.3em;
}
#content-display table {
    width: 100%; 
    max-width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    font-size: 0.9rem; 
}
#content-display th, #content-display td {
    border: 1px solid #ccc;
    padding: 8px;
    text-align: left;
    vertical-align: top; 
}
#content-display th {
    background-color: #f0f0f0;
}
#content-display a { 
    color: #1a0dab; /* Standard link blue */
}
#content-display a:visited {
    color: #551a8b; /* Standard visited link purple */
}
#content-display img { 
    max-width: 100%;
    height: auto;
    display: block; 
    margin: 0.5em 0; 
}

/* Warning Box for Parsing Issues */
.warning-box {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
}
.warning-box strong {
    color: #664d03;
}

/* Search Highlight Styles */
.highlight { /* For in-page search term highlighting */
    background-color: yellow;
    font-weight: bold;
    color: black; 
}

/* Global Search Results List Styles */
ul.search-results-list {
    list-style-type: none;
    padding-left: 0;
}
ul.search-results-list li {
    margin-bottom: 1.5em;
    padding-bottom: 1em;
    border-bottom: 1px solid #eee;
}
ul.search-results-list li:last-child {
    border-bottom: none;
}
a.search-result-link {
    font-weight: bold;
    text-decoration: none;
    color: #004A7C; 
    font-size: 1.1em;
}
a.search-result-link:hover {
    text-decoration: underline;
}
p.search-snippet {
    font-size: 0.9em;
    color: #555;
    margin-top: 0.3em;
    line-height: 1.5;
}
strong.search-hit { /* For highlighting term in search result snippet */
    background-color: #FFD700; /* Gold */
    padding: 1px 0;
    font-weight: bold; /* Ensure it stands out */
}

/* Footer Styles */
footer {
    text-align: center;
    padding: 15px;
    background-color: #333;
    color: white;
    font-size: 0.8em;
    margin-top: 20px;
}

/* Scroll-to-Top Button Styles */
#scrollToTopBtn {
  display: none; /* Hidden by default, JS will manage 'show' class */
  position: fixed;
  bottom: 25px;
  left: 50%; /* For horizontal centering */
  transform: translateX(-50%); /* Correctly center after left: 50% */
  z-index: 100;
  border: none;
  outline: none;
  background-color: #004A7C;
  color: white; /* Used by the ::before element's border */
  cursor: pointer;
  padding: 10px;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
  transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out, background-color 0.3s ease;
  opacity: 0;
  visibility: hidden;
}

/* Upward pointing CHEVRON using a pseudo-element */
#scrollToTopBtn::before {
  content: '';
  position: absolute;
  box-sizing: border-box;

  /* Position the center of the transform at the button's center */
  left: 50%;
  top: 50%;

  /* Define the size of the square from which the chevron arms are made */
  /* The length of each arm of the chevron will be roughly this size. */
  width: 10px;  /* Adjust for overall size of the chevron */
  height: 10px; /* Adjust for overall size of the chevron */

  /* Create two borders (top and right) on this square */
  /* These will form the "L" shape that gets rotated into a chevron. */
  border-top: 3px solid white !important;   /* Adjust thickness of the chevron lines */
  border-right: 3px solid white !important;  /* Adjust thickness of the chevron lines */
  border-bottom: 0 !important;
  border-left: 0 !important;


  /*
    Transform Explanation:
    1. rotate(-45deg): Rotates the square (with its top and right borders)
       counter-clockwise. This turns the "L" shape into an upward-pointing chevron.
    2. translate(-50%, -75%): This positions the rotated chevron.
       - translateX(-50%): Centers the chevron horizontally relative to its own width.
       - translateY(-75%): Shifts the chevron vertically. The -75% (instead of -50%)
         helps to visually center the chevron, pushing it slightly upwards because
         the visual "point" of the chevron is its highest part.
         You might need to fine-tune the -75% (e.g., to -70% or -80%) for perfect
         visual centering based on the exact arm length and thickness.
  */
  transform: translate(-50%, -75%) rotate(-45deg);
}

/* Change H5 header size & match site theme */
#content-display h5, h5 {
font-family: 'Lato', sans-serif;
color: #004A7C;
font-size: 1.5rem;
font-weight: bold;
margin-top: 1.2rem;
margin-bottom: 0.5rem;
}

#scrollToTopBtn.show {
  opacity: 1;
  visibility: visible;
  display: block;
}

#scrollToTopBtn:hover {
  background-color: #2196F3; /* Lighter blue on hover */
}

.tasbox {
  border: 1px solid #ccc;
  background-color: #b0aea7;
  padding: 16px;
  margin-bottom: 16px;
  border-radius: 4px;
  display: block; /* Ensures the <p> tag behaves like a container */
}
