@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;500;600&display=swap');

/* ==== 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: "Fredoka", "Nunito Sans", sans-serif;
  font-weight: 500;
  font-style: normal;
  font-size: 1.4rem;
  letter-spacing: 0;
  color: #fff;
  vertical-align: middle;
}

/* ---- 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: data-selection sidebar (left) + panels (right) on desktop; on mobile
   the columns stack, sidebar first, so filters sit above the panels. */
.app-body {
  display: flex;
  flex: 1 0 auto;
  align-items: stretch;
}

.app-sidebar {
  flex: 0 0 320px;
  background: var(--brand-paper);
  border-right: 1px solid var(--brand-line);
  padding: 1rem 1.1rem;
}

.sidebar-title {
  font-weight: 700;
  color: var(--brand-navy);
  margin-bottom: 0.75rem;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;   /* let DT/plots shrink instead of overflowing the row */
  padding: 1rem 1.25rem 1.5rem;
}

/* ---- 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%; }

.data-bar-toggle { display: none; }   /* desktop: sidebar always visible */

/* Desktop: force the Bootstrap collapse open regardless of toggle state */
@media (min-width: 768px) {
  .data-bar-collapse.collapse {
    display: block !important;
    height: auto !important;
  }
}

/* Mobile: sidebar stacks above the panels; filters hide behind a toggle so
   the panels stay visible first. */
@media (max-width: 767.98px) {
  .app-body { flex-direction: column; }
  .app-sidebar {
    flex: 1 1 auto;
    border-right: none;
    border-bottom: 1px solid var(--brand-line);
  }
  .sidebar-title { display: none; }   /* the toggle button is the label here */
  .data-bar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
  }
  .data-bar-collapse { margin-top: 0.75rem; }
  .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;
  }
}
