/* ---- Bundled Fredoka (offline) ------------------------------------------- */
/* Brand title font, served locally instead of a Google Fonts @import so nothing
   is fetched from fonts.googleapis.com (Azure blocks that egress). */
@font-face {
  font-family: "Fredoka"; font-style: normal; font-weight: 400;
  font-display: swap;
  src: url("fonts/fredoka-400.woff2") format("woff2");
}
@font-face {
  font-family: "Fredoka"; font-style: normal; font-weight: 500;
  font-display: swap;
  src: url("fonts/fredoka-500.woff2") format("woff2");
}
@font-face {
  font-family: "Fredoka"; font-style: normal; font-weight: 600;
  font-display: swap;
  src: url("fonts/fredoka-600.woff2") format("woff2");
}

/* ==== MsPOSSUM theme =========================================================
   Portable brand styles: CSS tokens, navbar title, nav links, footer,
   DataTables headers, and optional "hero + steps" info components.
   Pair with mspossom_theme.R (same folder), which defines the matching R-side
   brand tokens -- if a hex changes, change it in both files. */

/* ---- Brand tokens (mirrors mspossom_brand in mspossom_theme.R) ---------- */

:root {
  --brand-navy:  #232d52;
  --brand-teal:  #23A48B;
  --brand-coral: #E8846B;
  --brand-gold:  #E9B44C;
  --brand-ink:   #1F2937;
  --brand-muted: #667085;
  --brand-paper: #F8F9FB;
  --brand-line:  #D9DEE8;
}

/* ---- Navbar title (use with mspossom_title()) ---------------------------- */
/* Edit here to iterate on font/size/weight without touching R code. */

.app-title {
  font-family: "Nunito Sans", system-ui, sans-serif;
  font-weight: 700;
  font-style: normal;
  font-size: 1.35rem;
  letter-spacing: 0.005em;
  color: #fff;
  vertical-align: middle;
}

/* ---- App tab strip moved into the header bar ----------------------------- */
/* app.R relocates the navset's <ul> here; restyle it for a dark background. */
.mspossom-header .header-nav {
  --bs-nav-tabs-border-width: 0;
  border-bottom: 0;
  margin-left: auto;
  flex-wrap: wrap;
  gap: 0.15rem;
}
/* Bootstrap gives .nav-tabs links a 1px border that reads as a white underline
   on a dark bar, and paints the active one with the body background. Both are
   cleared so the active tab is marked by colour and weight instead. */
.mspossom-header .header-nav .nav-link,
.mspossom-header .header-nav .nav-link:hover,
.mspossom-header .header-nav .nav-link:focus,
.mspossom-header .header-nav .nav-link.active {
  border: 0;
  border-color: transparent;
  background: transparent;
  isolation: auto;
}
.mspossom-header .header-nav .nav-link {
  color: rgba(255, 255, 255, 0.78);
  border-radius: 0.35rem;
  padding: 0.35rem 0.75rem;
  font-weight: 600;
  transition: color 0.15s ease-in-out;
}
.mspossom-header .header-nav .nav-link:hover,
.mspossom-header .header-nav .nav-link:focus {
  color: #fff;
}
/* Active tab inverts the bar's navy for the brand teal, and bolds. */
.mspossom-header .header-nav .nav-link.active {
  color: var(--brand-teal);
  font-weight: 800;
}

/* ---- Navbar links: bolder, teal accent on hover/active ------------------- */

.navbar .nav-link {
  font-weight: 600;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
  color: var(--brand-teal) !important;
}

.navbar .nav-link.active {
  box-shadow: inset 0 -3px 0 var(--brand-teal);
}

/* ---- Footer (give your footer div class="app-footer") -------------------- */

.app-footer {
  padding: 0.6rem 1.25rem;
  border-top: 1px solid var(--brand-line);
  background: var(--brand-paper);
  color: var(--brand-muted);
  font-size: 0.8rem;
  text-align: center;
  flex-shrink: 0;   /* pinned at the bottom of the .mspossom-shell flex column */
}

/* ==== Portable app shell (page_fluid + mspossom_shell_header/footer) =========
   Header bar -> data-selection bar -> panels -> footer, in a flex column so the
   footer sticks to the bottom of the viewport even when content is short. */

.mspossom-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: none;
  padding-left: 0;   /* header/body/footer manage their own padding */
  padding-right: 0;
}

/* Body: native bslib sidebar layout. The sidebar collapses to the side on
   desktop and stacks above on mobile via sidebar(open = ...); we re-skin bslib
   through its CSS variables here. */
.app-body {
  flex: 1 0 auto;
  display: flex;
  --bslib-sidebar-bg: var(--brand-paper);
  --bslib-sidebar-border: 1px solid var(--brand-line);
  --bslib-sidebar-border-radius: 0;
  --bslib-sidebar-padding: 0;
}

.app-body > .bslib-sidebar-layout {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
}

.app-body .sidebar-title {
  font-weight: 700;
  color: var(--brand-navy);
}

/* Main panel region (bslib emits .main inside the layout). */
.app-body .bslib-sidebar-layout > .main {
  min-width: 0;   /* let DT/plots shrink instead of overflowing the row */
  padding: 1rem 1.25rem 1.5rem;
}

/* Sidebar accordion used as the visible "Data Selection"/"Filters" header.
   The header collapses the controls upward; the native sidebar chevron still
   collapses the whole panel to the side on desktop. */
.app-sidebar-accordion,
.app-sidebar-accordion .accordion-item {
  --bs-accordion-bg: transparent;
  --bs-accordion-active-bg: transparent;
  --bs-accordion-btn-focus-box-shadow: none;
  border: 0;
  background: transparent;
}

.app-sidebar-accordion .accordion-button {
  font-weight: 700;
  color: var(--brand-navy);
  background: transparent;
  box-shadow: none;
  padding: 0.35rem 0.25rem;
}

.app-sidebar-accordion .accordion-button:not(.collapsed) {
  color: var(--brand-navy);
}

.app-sidebar-accordion .accordion-button .accordion-icon,
.app-sidebar-accordion .accordion-button svg {
  color: var(--brand-teal);
}

.app-sidebar-accordion .accordion-body {
  padding: 0.6rem 0.25rem 0.25rem;
}

/* ---- Header bar --------------------------------------------------------- */

.mspossom-header {
  background: var(--brand-navy);
  padding: 0.4rem 1.25rem;
  min-height: 58px;
  flex-shrink: 0;
}

.mspossom-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  margin-right: 1rem;
  text-decoration: none;
}

.mspossom-brand:hover,
.mspossom-brand:focus {
  text-decoration: none;
}

.mspossom-nav-link {
  font-weight: 600;
  color: #fff !important;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.mspossom-nav-link:hover,
.mspossom-nav-link:focus {
  color: var(--brand-teal) !important;
}

.mspossom-header .dropdown-menu {
  --bs-dropdown-link-active-bg: var(--brand-teal);
}

.mspossom-header .navbar-toggler {
  border: 0;
  box-shadow: none;
}

.mspossom-header .navbar-toggler:focus {
  box-shadow: none;
}

.mspossom-header .navbar-collapse {
  min-width: 0;
}

/* ---- Data-selection controls (stacked column inside .app-sidebar) ------- */

.data-bar-row {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.data-bar-field,
.data-bar-field-wide,
.data-bar-action { width: 100%; }

.data-bar-field .form-group,
.data-bar-field .shiny-input-container {
  margin-bottom: 0;
  width: 100%;
}

.data-bar-field label {
  margin-bottom: 0.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brand-ink);
}

.data-bar-field .help-block { margin-bottom: 0; font-size: 0.72rem; }

.data-bar-action .btn { width: 100%; }

/* Mobile: the native bslib sidebar owns its responsive switch (the sidebar
   stacks above the panels via open = list(mobile = "always-above")), so only
   header tweaks remain here. */
@media (max-width: 767.98px) {
  .mspossom-brand .app-title { font-size: 1.15rem; }
  .mspossom-header .navbar-nav { padding-top: 0.5rem; }
}

/* ---- DataTables: minimal branded header(s) --------------------------------
   Light header with a teal rule; works for single-row headers and two-row
   grouped/spanner headers alike. */

table.dataTable thead th {
  background: var(--brand-paper);
  color: var(--brand-ink);
  font-weight: 700;
  border-bottom: 2px solid var(--brand-teal) !important;
}

/* Second header row (e.g. metric row under grouped spanners) */
table.dataTable thead tr + tr th {
  background: #ffffff;
  color: var(--brand-muted);
  font-weight: 600;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--brand-line) !important;
}

table.dataTable tbody tr:hover {
  background: #f0faf7;
}

.dataTables_wrapper .dt-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding-top: 0.5rem;
}

.dataTables_wrapper .dt-bottom .dataTables_info {
  margin-right: auto;
  padding-top: 0;
}

.dataTables_wrapper .dt-bottom .dt-buttons {
  float: none;
}

.dataTables_wrapper .dt-bottom .dataTables_paginate {
  float: none;
  padding-top: 0;
}

.dataTables_wrapper .dt-buttons .dt-button,
.dataTables_wrapper .dt-buttons button.dt-button,
.dataTables_wrapper .dt-buttons a.dt-button,
.dataTables_wrapper .dt-buttons .btn,
.dataTables_wrapper .dt-buttons .btn-secondary {
  background: var(--brand-paper) !important;
  background-color: var(--brand-paper) !important;
  background-image: none !important;
  color: var(--brand-ink) !important;
  border: 1px solid var(--brand-line) !important;
  box-shadow: none !important;
}

.dataTables_wrapper .dt-buttons .dt-button:hover,
.dataTables_wrapper .dt-buttons button.dt-button:hover,
.dataTables_wrapper .dt-buttons a.dt-button:hover,
.dataTables_wrapper .dt-buttons .btn:hover,
.dataTables_wrapper .dt-buttons .btn-secondary:hover {
  background: #ffffff !important;
  background-color: #ffffff !important;
  background-image: none !important;
  color: var(--brand-navy) !important;
  border-color: var(--brand-teal) !important;
}

.crosstab-table-wrap {
  margin-bottom: 1.5rem;
}

.crosstab-plot-wrap {
  clear: both;
  margin-top: 1.5rem;
}

/* ---- Optional components: titles above tables/graphics -------------------
   h5(class = "viz-title", ...) + div(class = "viz-subtitle", ...) */

.viz-title {
  margin-bottom: 0.15rem;
  color: var(--brand-navy);
}

.viz-subtitle {
  margin-bottom: 0.7rem;
  color: var(--brand-muted);
  font-size: 0.78rem;
}

/* ---- Optional components: minimal stat chips ------------------------------
   div(class = "stat-chip-row", <n>x div(class = "stat-chip",
     span(class = "stat-chip-icon", icon(...)),
     div(div(class = "stat-chip-title", ...), div(class = "stat-chip-value", ...)))) */

.stat-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.stat-chip {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--brand-line);
  border-radius: 0.5rem;
  background: #ffffff;
}

.stat-chip-icon {
  font-size: 1rem;
  opacity: 0.75;
}

.stat-chip-title {
  color: var(--brand-muted);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stat-chip-value {
  color: var(--brand-ink);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
}

/* ---- Optional components: hero + numbered steps --------------------------
   <div class="info-hero"> <img class="info-hero-logo"> <div>h3 + p</div> </div>
   <div class="info-steps"> 3x <div class="info-step">
     <div class="info-step-num">1</div> <div>h6 + p</div> </div> </div> */

.info-hero {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.5rem 0 1.25rem;
}

.info-hero-logo {
  height: 96px;
  flex: 0 0 auto;
}

.info-hero h3 {
  font-family: "Fredoka", "Nunito Sans", sans-serif;
  font-weight: 500;
  color: var(--brand-navy);
  margin-bottom: 0.35rem;
}

.info-hero p {
  margin: 0;
  max-width: 62ch;
  color: var(--brand-muted);
}

.info-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-bottom: 1.25rem;
}

.info-step {
  display: flex;
  gap: 0.7rem;
  padding: 0.9rem;
  border: 1px solid var(--brand-line);
  border-radius: 0.5rem;
  background: var(--brand-paper);
}

.info-step-num {
  flex: 0 0 auto;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--brand-teal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.info-step h6 {
  margin: 0 0 0.2rem;
}

.info-step p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--brand-muted);
}

@media (max-width: 767px) {
  .info-steps {
    grid-template-columns: 1fr;
  }

  .info-hero {
    flex-direction: column;
    text-align: center;
  }
}
/* ---- Bundled Nunito Sans (offline) --------------------------------------- */
/* Served locally from mspossom/fonts/ so nothing is fetched from
   fonts.googleapis.com at render time. Azure App Service blocks that egress,
   which was failing every app's first render (the start.sh warm-up). */
@font-face {
  font-family: "Nunito Sans"; font-style: normal; font-weight: 400;
  font-display: swap;
  src: url("fonts/nunito-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito Sans"; font-style: normal; font-weight: 600;
  font-display: swap;
  src: url("fonts/nunito-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito Sans"; font-style: normal; font-weight: 700;
  font-display: swap;
  src: url("fonts/nunito-sans-700.woff2") format("woff2");
}
