/* BMSS theme: the exact colours the Yii application rendered, on AdminLTE 4.
 *
 * ---------------------------------------------------------------------------
 * Where these colours come from
 * ---------------------------------------------------------------------------
 * views/layouts/header.php applied `background-color:#9fcf67` inline in seven
 * places -- the logo, both logo spans, the top navbar and the user panel
 * header. #9fcf67 is the IEBC green, and was verified as the ONLY hex colour
 * appearing anywhere in the Yii layout files.
 *
 * Everything else (the dark sidebar, the link colours) came from AdminLTE 2's
 * `skin-blue`. AdminLTE 4 has no skins -- it themes through CSS custom
 * properties and Bootstrap 5's colour modes -- so skin-blue's palette is
 * reproduced explicitly below. The values are not approximations: they were
 * read out of the AdminLTE 2.4.18 skin-blue.css this file replaces.
 *
 *     sidebar background        #222d32
 *     section header            #4b646f on #1a2226
 *     sidebar links             #b8c7ce
 *     hover / active            #ffffff on #1e282c
 *     submenu links             #8aa4af
 *
 * The result is intended to be indistinguishable from the old UI at a glance,
 * which is the whole reason AdminLTE was kept through the port: 121 staff
 * already know this screen.
 */

:root {
  --bmss-accent: #9fcf67;
  /* A darker shade for hover states. AdminLTE's own hovers are blue and would
   * clash with the green header -- in the original that was visible as the
   * navbar links flashing blue on hover. */
  --bmss-accent-dark: #8ab854;
  /* The dark green used for text on the accent, the progress bar, the skip
   * link and focus rings. */
  --bmss-ink: #1d3307;

  /* skin-blue, reproduced. */
  --bmss-sidebar-bg: #222d32;
  --bmss-sidebar-link: #b8c7ce;
  --bmss-sidebar-hover-bg: #1e282c;
  --bmss-sidebar-header-bg: #1a2226;
  --bmss-sidebar-header-fg: #4b646f;
  --bmss-sidebar-submenu-link: #8aa4af;
}

/* ---------------------------------------------------------------------------
 * Header and brand -- the green surfaces
 * ------------------------------------------------------------------------ */
.app-header {
  background-color: var(--bmss-accent);
  border-bottom-color: var(--bmss-accent-dark);
}

/* Bootstrap 5 drives navbar link colour through these variables, so setting
 * them is preferable to overriding each link state by selector. */
.app-header {
  --bs-navbar-color: var(--bs-body-color);
  --bs-navbar-hover-color: var(--bs-body-color);
  --bs-navbar-active-color: var(--bs-body-color);
  --bs-navbar-brand-color: var(--bs-body-color);
  --bs-navbar-brand-hover-color: var(--bs-body-color);
}

.app-header .nav-link:hover,
.app-header .nav-link:focus,
.app-header .nav-link.active,
.app-header .nav-item.show > .nav-link {
  background-color: var(--bmss-accent);
  color: var(--bmss-ink);
}

/* The brand block sits in the sidebar in AdminLTE 4 (it was in the header in
 * v2), but it kept the green in the original and keeps it here. */
.app-sidebar .sidebar-brand {
  background-color: var(--bmss-accent);
}

.app-sidebar .brand-link,
.app-sidebar .brand-link:hover,
.app-sidebar .brand-link:focus {
  background-color: var(--bmss-accent);
  color: #fff;
}

/* The logo images are transparent PNGs sized for the AdminLTE header. */
.brand-link .brand-image {
  vertical-align: middle;
  margin-right: 4px;
}

/* ---------------------------------------------------------------------------
 * Sidebar -- skin-blue's palette, expressed as AdminLTE 4 variables
 * ------------------------------------------------------------------------ */
.app-sidebar {
  background-color: var(--bmss-sidebar-bg);

  --lte-sidebar-color: var(--bmss-sidebar-link);
  --lte-sidebar-hover-color: #fff;
  --lte-sidebar-hover-bg: var(--bmss-sidebar-hover-bg);
  --lte-sidebar-active-color: #fff;
  --lte-sidebar-menu-active-color: #fff;
  --lte-sidebar-menu-active-bg: var(--bmss-sidebar-hover-bg);
  --lte-sidebar-header-color: var(--bmss-sidebar-header-fg);
  --lte-sidebar-submenu-color: var(--bmss-sidebar-submenu-link);
  --lte-sidebar-submenu-hover-color: #fff;
  --lte-sidebar-submenu-hover-bg: var(--bmss-sidebar-hover-bg);
  --lte-sidebar-submenu-active-color: #fff;
  --lte-sidebar-submenu-active-bg: var(--bmss-sidebar-hover-bg);
}

/* skin-blue gave the section labels their own darker band, which the variable
 * above cannot express (it sets only the text colour). */
.app-sidebar .nav-header {
  background-color: var(--bmss-sidebar-header-bg);
  color: var(--bmss-sidebar-header-fg);
}

/* The sign-out control is a form button styled as a menu row -- see base.html
 * for why logout is POST-only. Without this it renders as a bare button. */
.app-sidebar .nav-link-button {
  background: none;
  border: 0;
  width: 100%;
  text-align: left;
  color: var(--bmss-sidebar-link);
}

.app-sidebar .nav-link-button:hover {
  background-color: var(--bmss-sidebar-hover-bg);
  color: #fff;
}

/* ---------------------------------------------------------------------------
 * Login page
 * ------------------------------------------------------------------------ */
/* main-login.php set `style="width:800px"` on the login box and
 * `background-color:#9fcf67` on <body>. The width lives here rather than
 * inline so it can degrade on small screens -- the original was a hard 800px
 * and overflowed on a phone. */
.bmss-login-body {
  background-color: var(--bmss-accent);
}

/* ---------------------------------------------------------------------------
 * Login screen: Bootstrap 3 metrics, reproduced
 * ------------------------------------------------------------------------
 * The AdminLTE 2 -> 4 upgrade moved this screen off Bootstrap 3, and Bootstrap
 * 5 is simply bigger: a 16px base instead of 14px, taller inputs, larger
 * headings. Nothing was "wrong", but the result was no longer the screen 121
 * staff know, and this layout had already been corrected twice before the
 * upgrade -- so the values are pinned here against the original source rather
 * than left to whatever the framework defaults to next.
 *
 * Measured from views/layouts/main-login.php and
 * modules/users/views/security/login.php in the Yii app, plus the
 * AdminLTE 2.4.18 and Bootstrap 3.4.1 stylesheets that shipped with it:
 *
 *   .login-box   width 800px (inline override), margin 7% auto
 *   column       col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3
 *   base font    14px
 *   h5           14px
 *   .panel-title 16px, no margin
 *   panel head   #f5f5f5 background, #ddd border, 10px 15px padding
 *   panel body   15px padding
 *   label        font-weight 700, 5px bottom margin
 *   .form-control  34px tall, 6px 12px padding, 14px, 1px solid #ccc, 4px radius
 *   panel/card   3px radius, 1px solid #ddd, 0 1px 1px rgba(0,0,0,.05)
 *
 * NOTE WHY EACH SIZE IS RESTATED IN PIXELS rather than setting a 14px base and
 * letting it cascade: Bootstrap 5 sizes components in `rem`, which is
 * ROOT-relative, so a font-size on .login-page does not shrink .form-control
 * at all. Only explicit overrides work. That is also why these are scoped to
 * .login-page -- the rest of the application stays on Bootstrap 5 defaults.
 */

/* AdminLTE 4 centres the box vertically with flex; AdminLTE 2 placed it 7%
 * from the top and let the page grow. Restores the original position. */
.login-page.bmss-login-body {
  display: block;
  min-height: 100vh;
}

.bmss-login-box {
  width: 800px;
  max-width: 96vw;
  /* AdminLTE 2's .login-box margin, which the Yii layout did not override. */
  margin: 7% auto;
}

/* Bootstrap 3's base was 14px. Set on the page for anything that inherits. */
.login-page.bmss-login-body {
  font-size: 14px;
}

/* The heading sat directly on the green background in the original, at the
 * Bootstrap 3 h5 size of 14px -- not Bootstrap 5's 1.25rem/20px. */
.bmss-login-box .bmss-login-heading {
  color: var(--bmss-ink);
  margin-top: 8px;
  font-size: 14px;
}

/* .panel-title was 16px with no margin. */
.bmss-login-box .bmss-login-panel-title {
  font-size: 16px;
  margin: 0;
}

/* .panel-default > .panel-heading */
.bmss-login-box .card-header {
  padding: 10px 15px;
  background-color: #f5f5f5;
  border-bottom: 1px solid #ddd;
  color: #333;
}

/* .panel-default */
.bmss-login-box .card {
  border: 1px solid #ddd;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, .05);
}

/* .panel-body */
.bmss-login-box .card-body {
  padding: 15px;
}

/* Bootstrap 3 labels were BOLD. Bootstrap 5 dropped that, which is one of the
 * more noticeable differences on a two-field form. */
.bmss-login-box label,
.bmss-login-box .form-label {
  font-weight: 700;
  margin-bottom: 5px;
  font-size: 14px;
}

/* .form-control */
.bmss-login-box .form-control {
  height: 34px;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.42857143;
  color: #555;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* .btn / .btn-primary at Bootstrap 3 sizing. The colour is left to
 * Bootstrap 5 -- the original used the stock primary blue too. */
.bmss-login-box .btn {
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.42857143;
  border-radius: 4px;
}

/* .form-group spacing was 15px; Bootstrap 5's mb-3 is 16px. */
.bmss-login-box .mb-3 {
  margin-bottom: 15px !important;
}

/* The original checkbox was an unstyled input inside its label, with no
 * indent. Bootstrap 5's .form-check indents by 1.5em and restyles the box. */
.bmss-login-box .form-check {
  padding-left: 0;
  margin-bottom: 15px;
  min-height: auto;
}
.bmss-login-box .form-check-input {
  float: none;
  margin-left: 0;
  margin-right: 4px;
  border-radius: 0;
}
.bmss-login-box .form-check-label {
  font-weight: 700;
  font-size: 14px;
}

/* ---------------------------------------------------------------------------
 * Loading feedback and accessibility
 * ------------------------------------------------------------------------ */

/* Global HTMX progress bar. Fixed at the top so it is visible wherever the
 * swap happens on the page -- a spinner next to the widget is easy to miss on
 * a long grid. */
#bmss-loading {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 2000; opacity: 0; transition: opacity .15s ease;
  pointer-events: none;
}
#bmss-loading.active { opacity: 1; }
#bmss-loading .bar {
  height: 100%; width: 35%;
  background: var(--bmss-ink);
  animation: bmss-indeterminate 1.1s ease-in-out infinite;
}
@keyframes bmss-indeterminate {
  0%   { margin-left: -35%; }
  100% { margin-left: 100%; }
}

/* Respect a user's reduced-motion preference rather than animating at them. */
@media (prefers-reduced-motion: reduce) {
  #bmss-loading .bar { animation: none; width: 100%; }
}

/* Skip link: hidden until focused, which is the point -- it exists for
 * keyboard users, who would otherwise tab the entire sidebar on every page
 * before reaching the table. */
.bmss-skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 3000;
  padding: 10px 16px; background: var(--bmss-ink); color: #fff;
  text-decoration: none;
}
.bmss-skip-link:focus {
  left: 0; outline: 3px solid #fff;
}

/* The aria-live region must stay in the accessibility tree -- Bootstrap 5's
 * .visually-hidden does this correctly, but the rule is kept explicit because
 * display:none here would silence every HTMX swap announcement. */
#hx-announce {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* Visible keyboard focus. Bootstrap 5 is better than 3 here, but its focus
 * ring is the blue --bs-primary, which clashes with the green header. */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--bmss-ink) !important;
  outline-offset: 1px;
}

/* ---------------------------------------------------------------------------
 * Breadcrumbs and the navbar mark -- parity items from the Yii layout
 * ------------------------------------------------------------------------ */
/* Yii rendered Breadcrumbs::widget() inside .content-header, right-aligned by
 * AdminLTE 2's own rule. Reproduced here rather than left to Bootstrap 5's
 * default block flow, which would push the page title down. */
.bmss-breadcrumb {
  float: right;
  margin: -24px 0 0 0;
  padding: 0;
  background: transparent;
  font-size: 12px;
}
.bmss-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  padding: 0 6px;
}

@media (max-width: 575.98px) {
  /* Stack rather than overlap the title on a phone, which the original did
   * not have to handle because the layout was not responsive here. */
  .bmss-breadcrumb { float: none; margin: 6px 0 0 0; }
}

/* budget_logo.png sat at the navbar's natural height in AdminLTE 2's 50px
 * header. Constrained so a larger source image cannot stretch the bar. */
.bmss-navbar-logo {
  max-height: 34px;
  width: auto;
  margin-left: 8px;
}

/* ---------------------------------------------------------------------------
 * Colour theme control and the Sign out button (navbar)
 * ------------------------------------------------------------------------
 * The theme itself is Bootstrap 5.3's data-bs-theme on <html>, set by static/js/theme-init.js
 * before first paint and changed by static/js/theme.js. Only the control's look lives here. */
.iebc-theme-icon { display: none; }
html[data-theme-choice="light"] .iebc-theme-icon-light,
html[data-theme-choice="dark"] .iebc-theme-icon-dark,
html[data-theme-choice="auto"] .iebc-theme-icon-auto { display: inline-block; }

[data-theme-set][aria-checked="true"] {
  font-weight: 600;
  background-color: var(--bs-dropdown-link-hover-bg);
}
[data-theme-set][aria-checked="true"]::after { content: "\2713"; margin-left: .6rem; }

/* A visible, labelled Sign out button on the coloured header (an icon alone on a phone). */
.iebc-signout {
  color: var(--bs-body-color);
  border: 1px solid currentColor;
  background: transparent;
}
.iebc-signout:hover, .iebc-signout:focus-visible {
  color: var(--bmss-ink);
  background: var(--bmss-accent);
  border-color: var(--bmss-accent-dark);
}
