/* =============================================================================
   General Reset / Global Defaults
   ============================================================================= */

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: "Source Serif Pro", serif;
}

html {
    font-size: 14px;
}

/* Global Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
}

/* =============================================================================
   Summary Tables / Accordion (Summary Statistics tab)
   ============================================================================= */

#summary-table-container {
    margin-top: 15px;
    font-size: 0.875rem;
}

#summary-table-container h5 {
    font-size: 1rem;
}

#summary-table-container tbody {
    font-size: 0.85rem;
}

#summary-table-container th {
    font-size: 0.875rem;
}

/* Tighter spacing inside growing-season accordion */
#summary-table-container .accordion-item + .accordion-item {
    margin-top: 0.35rem;
}

#summary-table-container .accordion-body {
    padding: 0.5rem 0.75rem;
}

#summary-table-container .accordion-body > h6 {
    margin-top: 0.35rem;
    margin-bottom: 0.15rem;
}

#summary-table-container .accordion-body > .table {
    margin-bottom: 0.25rem;
}

#summary-table-container .table th,
#summary-table-container .table td {
    padding-top: 4px;
    padding-bottom: 4px;
}

#summary-table-container h2.accordion-header {
    margin-top: 0;
    margin-bottom: 0;
}

/* Make accordion headers clearly clickable */
#summary-table-container .accordion-button {
    background-color: #d7e6ff;
    font-weight: 600;
    cursor: pointer;
}

/* Big chevron instead of subtle Bootstrap caret */
#summary-table-container .accordion-button::after {
    background-image: none;
    content: "▾";
    font-size: 0.9rem;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 0.2s ease-in-out;
}

#summary-table-container .accordion-button.collapsed::after {
    transform: rotate(-90deg);
}

#summary-table-container .accordion-button:hover {
    background-color: #c4daff;
}

/* Prefer compact Bootstrap tables in this container */
#summary-table-container table.table-sm th,
#summary-table-container table.table-sm td {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

/* =============================================================================
   Global table defaults (keep these lightweight)
   ============================================================================= */

.table {
    border-collapse: collapse;
    width: 100%;
}

/* Main data display tables (scoped) */
#main .table th,
#main .table td {
    text-align: center;
    padding: 10px;
    border: 1px solid #ddd;
}

.thead-dark th {
    background-color: #343a40 !important;
    color: white;
}

/* =============================================================================
   Loading overlays (shared dots animation + in-container overlays + boot loader)
   ============================================================================= */

@keyframes dots {
    0%   { content: ""; }
    25%  { content: "."; }
    50%  { content: ".."; }
    75%  { content: "..."; }
    100% { content: ""; }
}

/* In-container overlay (plots, tables, markdown) */
.loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.75);
    z-index: 10;
    font-weight: 600;
}

.loading-overlay .dots::after {
    content: "";
    display: inline-block;
    width: 1.5em;
    text-align: left;
    animation: dots 1.2s steps(4, end) infinite;
}

/* Boot-level page loader (shown immediately on page load) */
.boot-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    z-index: 9999;
    font-weight: 600;
}

.boot-loading-inner {
    font-size: 1.1rem;
}

.boot-loading-inner .dots::after {
    content: "";
    display: inline-block;
    width: 1.5em;
    text-align: left;
    animation: dots 1.2s steps(4, end) infinite;
}

/* =============================================================================
   Layout Containers
   ============================================================================= */

/* Project layout container (do NOT override Bootstrap's .container) */
.biochar-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Match tab font to content */
.nav-tabs .nav-link {
    font-family: "Source Serif Pro", serif;
}
.nav-tabs {
  margin-bottom: 0.35rem;  /* space between tabs and content below */
  row-gap: 0.15rem;        /* space between wrapped rows */
  column-gap: 0.25rem !important;     /* space between tabs horizontally */
}

/* Smaller/tighter tab pills */
.nav-tabs .nav-link {
  font-family: "Source Serif Pro", serif;
  font-size: 0.98rem !important;
  padding: 0.18rem 0.25rem;  /* this is the big one for vertical tightness */
  line-height: 1.15 !important;
}

.nav-tabs .nav-link.active {
    font-weight: 600;
}

/* When tabs wrap to multiple rows */
.nav-tabs {
    flex-wrap: wrap;
}
/* =============================================================================
   MARKDOWN (tight vertical rhythm + consistent layout)
   ============================================================================= */

/*
  IMPORTANT:
  Do not use `.container.markdown-container` anywhere.
  Your HTML currently includes `class="container markdown-container ..."`
  which pulls in Bootstrap container padding/margins and default typography.
  This CSS assumes you will remove `container` from the markdown wrappers
  (see index.html changes below).
*/

/* The outer wrapper used for markdown tabs/sections */
.markdown-container {
    position: relative;        /* enables loading overlay */
    width: 100%;
    margin: 0 auto;
    padding: 8px 12px;         /* tighter than before */
}

/* The injected markdown HTML */
.markdown-content {
    font-family: "Source Serif Pro", serif !important;
    font-size: 14px;
    line-height: 1.28;         /* tighter */
}

/* -------------------------------------------------------------------------
   Markdown heading sizes (override Bootstrap responsive scaling)
   ------------------------------------------------------------------------- */

.markdown-content h1 {
    font-size: 2.1rem;
    font-weight: 500;
}

.markdown-content h2 {
    font-size: 1.6rem;
    font-weight: 500;
}

.markdown-content h3 {
    font-size: 1.3rem;
    font-weight: 500;
}

.markdown-content h4 {
    font-size: 1.1rem;
    font-weight: 500;
}

.markdown-content h5,
.markdown-content h6 {
    font-size: 1rem;
    font-weight: 600;
}

/* Shared spacing */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
    margin-top: 1.0rem;
    margin-bottom: 0.4rem;
    line-height: 1.2;
    text-align: left !important;
    color: #333;
}

/* Paragraphs – noticeably tighter */
.markdown-content p {
    margin: 0 0 0.35rem 0;
}

/* Lists – tighter */
.markdown-content ul,
.markdown-content ol {
    margin: 0 0 0.35rem 0;
    padding-left: 1.15rem;
}

.markdown-content li {
    margin-bottom: 0.18rem;
}

/* Tables, figures, blocks – tighter */
.markdown-content table,
.markdown-content blockquote,
.markdown-content pre,
.markdown-content figure {
    margin: 0 0 0.45rem 0;
}

/* Figures */
.markdown-content figure {
    max-width: 65%;
    margin: 0.75rem auto;      /* tighter */
}

.markdown-content figure img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

.markdown-content img {
    display: block;
    margin: 0.5rem auto;
    max-width: 70%;
    height: auto;
}

.markdown-content figcaption {
    text-align: center;
    font-style: italic;
    margin-top: 0.25rem;
}

/* Pandoc tables: centered but not forced full width */
.markdown-content table {
    display: table;
    width: auto;
    max-width: 100%;
    border-collapse: collapse;
    margin-left: auto;
    margin-right: auto;
}

/* Special: side-by-side figure tables (Figures 2 & 3) */
.markdown-content table.side-by-side-figures {
    margin: 0.75rem auto;
    width: auto;
    border-collapse: collapse;
}

.markdown-content table.side-by-side-figures th {
    border: none;
    padding: 0 1.25em;
    text-align: center;
}

.markdown-content table.side-by-side-figures img {
    max-width: 100%;
    height: auto;
}

/* =============================================================================
   Tabs / Legacy tab controls
   ============================================================================= */

.tabs {
    display: flex;
    background-color: #f8f9fa;
    padding: 10px;
    border-bottom: 1px solid #dee2e6;
}

.tabs button {
    background-color: #e9ecef;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 16px;
    margin-right: 5px;
    border-radius: 0.25rem;
}

.tabs button.active {
    background-color: #0d6efd;
    color: white;
}

.tab-content {
    overflow: visible;
    height: auto;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* =============================================================================
   Control Panels / Plots
   ============================================================================= */

.control-panel {
    flex: 0 0 220px;
    max-width: 220px;
    height: auto;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-sizing: border-box;
    font-family: inherit;
}

.control-panel select,
.control-panel button,
.control-panel input {
    font-size: 14px;
    padding: 4px 6px;
    width: 100%;
}

.control-panel .form-control {
    margin-bottom: 6px;
}

.control-panel h3 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 8px;
}

.summary-panel {
    background-color: #eef2f6;
}

.plot-panel {
    flex-grow: 1;
    flex-basis: 0;
    min-width: 0;
    box-sizing: border-box;
    padding: 10px;
}

.graph-container:last-child {
    margin-bottom: 0;
    font-family: inherit;
}

.graph-container p.text-muted {
    text-align: center;
    font-style: italic;
    color: #6c757d;
    margin-top: 16px;
}

.info-icon {
    font-size: 14px;
    font-weight: bold;
    color: #007bff;
    cursor: pointer;
    margin-left: 5px;
}

.plot-container {
    width: 100%;
}

#plot-1 {
  margin-bottom: 10px;
}
#plot-2 {
    width: 100%;
    height: 450px;
}

/* Buttons */
input[type="submit"],
button {
    padding: 10px 15px;
    font-size: 14px;
    font-weight: bold;
    color: #fff;
    background-color: #0d6efd;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

input[type="submit"]:hover,
button:hover {
    background-color: #0056b3;
}

/* Ensure the row is a flex container */
.row.custom-flex-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 20px;
}

/* =============================================================================
   Responsive Design
   ============================================================================= */

@media screen and (max-width: 768px) {
    /* IMPORTANT: do NOT target Bootstrap's .container */
    .biochar-container {
        flex-direction: column;
        align-items: center;
    }

    .control-panel {
        width: 100%;
        max-width: 100%;
        margin-bottom: 15px;
        padding: 10px;
    }

    .plot-panel {
        width: 100%;
        min-width: 0;
        padding: 0 5px;
    }

    .graph-container {
        width: 100%;
        min-width: 0;
    }
}

/* Larger screen override for readability (markdown) */
@media screen and (min-width: 992px) {
    .markdown-container {
        max-width: 1000px;
    }
}

/* =============================================================================
   Metric tables (Pasture NIR + Soil Bio + Soil Chem + Biomass)
   ============================================================================= */

#nir,
#soilbio,
#soilchem {
    text-align: left;
}

#nir .nir-scroll,
#soilbio .nir-scroll,
#soilchem .nir-scroll {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    text-align: left;
    padding-left: 0;
    padding-right: 0;
}

#nir .nir-content,
#soilbio .nir-content,
#soilchem .nir-content {
    display: block;
    text-align: left;
}

#nir .nir-content h5,
#soilbio .nir-content h5,
#soilchem .nir-content h5 {
    margin: 0.6rem 0 0.35rem 0;
    font-size: 1.0rem;
    font-weight: 600;
    text-align: left;
}

#nir .nir-content table,
#soilbio .nir-content table,
#soilchem .nir-content table {
    font-size: 0.82rem;
    line-height: 1.05;
    width: auto !important;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    table-layout: fixed;
    display: table;
}

#nir .nir-content .table-responsive,
#soilbio .nir-content .table-responsive,
#soilchem .nir-content .table-responsive {
    display: block;
    width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0;
    padding-right: 0;
    text-align: left;
}

#nir .nir-content table th,
#nir .nir-content table td,
#soilbio .nir-content table th,
#soilbio .nir-content table td,
#soilchem .nir-content table th,
#soilchem .nir-content table td {
    padding: 0.20rem 0.35rem !important;
    white-space: nowrap;
    text-align: right !important;
    vertical-align: middle;
}

#nir .nir-content table th:first-child,
#nir .nir-content table td:first-child,
#soilbio .nir-content table th:first-child,
#soilbio .nir-content table td:first-child,
#soilchem .nir-content table th:first-child,
#soilchem .nir-content table td:first-child {
    text-align: left !important;
    width: 5.5rem !important;
}

#nir .nir-content table th:not(:first-child),
#nir .nir-content table td:not(:first-child),
#soilbio .nir-content table th:not(:first-child),
#soilbio .nir-content table td:not(:first-child),
#soilchem .nir-content table th:not(:first-child),
#soilchem .nir-content table td:not(:first-child) {
    width: 5.0rem !important;
}

#nir .nir-content table thead th,
#soilbio .nir-content table thead th,
#soilchem .nir-content table thead th {
    font-weight: 600;
    font-size: 0.80rem;
}

#nir .nir-content .mb-4,
#soilbio .nir-content .mb-4,
#soilchem .nir-content .mb-4 {
    margin-bottom: 0.9rem !important;
}

/* Biomass tables — match NIR / Soil behavior */
#biomass-field .nir-content table {
    font-size: 0.82rem;
    line-height: 1.05;
    width: auto !important;
    max-width: 100%;
    margin-left: 0 !important;
    margin-right: 0 !important;
    table-layout: fixed;
}

#biomass-field .nir-content table th,
#biomass-field .nir-content table td {
    padding: 0.20rem 0.35rem !important;
    white-space: nowrap;
    text-align: right !important;
    vertical-align: middle;
}

#biomass-field .nir-content table th:first-child,
#biomass-field .nir-content table td:first-child {
    text-align: left !important;
    width: 5.5rem !important;
}

#biomass-field .nir-content table th:not(:first-child),
#biomass-field .nir-content table td:not(:first-child) {
    width: 5.0rem !important;
}