/*
 * Budget Officer buttons.
 *
 * Visual styling only, scoped to the Budget Officer pages so no other role's
 * buttons change. Each Budget Officer page marks its top-level elements (the
 * page, its modals and drawers) with .bo-ui. Two modals are built by the
 * page scripts and mounted on <body>, outside the page, so they are listed
 * by id.
 *
 * Kaiadmin sets the solid button colours with !important, so the colours
 * here need !important too. Each variant only sets --bo-* variables; the
 * shared rules below turn them into background, border and text colours.
 * Loaded after dark-mode.css.
 */

.bo-ui .btn,
#ors_no_modal .btn,
#fund_cluster_no_modal .btn {
  --bo-bg: transparent;
  --bo-fg: inherit;
  --bo-bd: transparent;
  --bo-bg-hover: var(--bo-bg);
  --bo-fg-hover: var(--bo-fg);
  --bo-bd-hover: var(--bo-bd);
  --bo-bg-active: var(--bo-bg-hover);
  --bo-ring: rgba(21, 114, 232, 0.28);
  --bo-shadow: none;

  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.005em;
  border-width: 1px;
  border-radius: 6px;
  opacity: 1;
  box-shadow: var(--bo-shadow);
  transition: background-color 0.15s ease, border-color 0.15s ease,
    color 0.15s ease, box-shadow 0.15s ease;
}

.bo-ui .btn-sm,
#ors_no_modal .btn-sm,
#fund_cluster_no_modal .btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 5px;
}

/* Icons sit on the text's centre line instead of its baseline. */
.bo-ui .btn > i,
.bo-ui .btn > .btn-label > i,
#ors_no_modal .btn > i,
#fund_cluster_no_modal .btn > i {
  font-size: 0.95em;
  vertical-align: -0.05em;
}

/* Realignment monitoring buttons are drawn by their page script with no
   spacing class on the icon; give them the same gap as .me-1. */
.bo-ui .monitoring_view_request_btn > i,
.bo-ui .monitoring_view_approved_btn > i,
.bo-ui .view_remarks_btn > i {
  margin-right: 0.25rem;
}

/* ------------------------------------------------------------ colours */
.bo-ui .btn:not(.btn-link),
#ors_no_modal .btn:not(.btn-link),
#fund_cluster_no_modal .btn:not(.btn-link) {
  background: var(--bo-bg) !important;
  border-color: var(--bo-bd) !important;
  color: var(--bo-fg) !important;
}

/* Kaiadmin fades every button to 0.8 opacity on hover and focus, which
   washes the colour out. Darken the colour instead. */
.bo-ui .btn:not(.btn-link):hover,
#ors_no_modal .btn:not(.btn-link):hover,
#fund_cluster_no_modal .btn:not(.btn-link):hover {
  background: var(--bo-bg-hover) !important;
  border-color: var(--bo-bd-hover) !important;
  color: var(--bo-fg-hover) !important;
  opacity: 1;
}

.bo-ui .btn:not(.btn-link):active,
.bo-ui .btn:not(.btn-link).active,
.bo-ui .btn:not(.btn-link).show,
#ors_no_modal .btn:not(.btn-link):active,
#fund_cluster_no_modal .btn:not(.btn-link):active {
  background: var(--bo-bg-active) !important;
  border-color: var(--bo-bd-hover) !important;
  color: var(--bo-fg-hover) !important;
  box-shadow: none;
}

.bo-ui .btn:focus,
#ors_no_modal .btn:focus,
#fund_cluster_no_modal .btn:focus {
  opacity: 1;
  box-shadow: var(--bo-shadow);
}

.bo-ui .btn:focus-visible,
#ors_no_modal .btn:focus-visible,
#fund_cluster_no_modal .btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 3px var(--bo-ring);
}

/* Disabled keeps its own colours, never the hover ones. */
.bo-ui .btn:disabled,
.bo-ui .btn.disabled,
#ors_no_modal .btn:disabled,
#fund_cluster_no_modal .btn:disabled {
  opacity: 0.55;
  box-shadow: none;
}

.bo-ui .btn:not(.btn-link):disabled:hover,
.bo-ui .btn:not(.btn-link).disabled:hover,
#ors_no_modal .btn:not(.btn-link):disabled:hover,
#fund_cluster_no_modal .btn:not(.btn-link):disabled:hover {
  background: var(--bo-bg) !important;
  border-color: var(--bo-bd) !important;
  color: var(--bo-fg) !important;
  opacity: 0.55;
}

/* ------------------------------------------------- light mode variants */

/* Primary: forward, save, view PDF. The strongest emphasis. */
.bo-ui .btn-primary,
#ors_no_modal .btn-primary,
#fund_cluster_no_modal .btn-primary {
  --bo-bg: #1572e8;
  --bo-bd: #1572e8;
  --bo-fg: #ffffff;
  --bo-bg-hover: #1263cc;
  --bo-bd-hover: #1263cc;
  --bo-bg-active: #0f55b0;
  --bo-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

/* Success: receive, approve, update. A calmer green than Kaiadmin's. */
.bo-ui .btn-success {
  --bo-bg: #23a047;
  --bo-bd: #23a047;
  --bo-fg: #ffffff;
  --bo-bg-hover: #1d8a3c;
  --bo-bd-hover: #1d8a3c;
  --bo-bg-active: #187533;
  --bo-ring: rgba(35, 160, 71, 0.28);
  --bo-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

/* Warning: edit, return. Dark text keeps the amber readable. */
.bo-ui .btn-warning {
  --bo-bg: #f5a93b;
  --bo-bd: #f5a93b;
  --bo-fg: #3b2604;
  --bo-bg-hover: #e8992a;
  --bo-bd-hover: #e8992a;
  --bo-bg-active: #d98b1f;
  --bo-ring: rgba(245, 169, 59, 0.35);
  --bo-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

/* Danger: delete and the red Cancel buttons. Muted, not alarming. */
.bo-ui .btn-danger {
  --bo-bg: #dc4c54;
  --bo-bd: #dc4c54;
  --bo-fg: #ffffff;
  --bo-bg-hover: #c63f47;
  --bo-bd-hover: #c63f47;
  --bo-bg-active: #ad353c;
  --bo-ring: rgba(220, 76, 84, 0.28);
  --bo-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

/* Secondary: Close and Cancel. Neutral, so the action beside it leads. */
.bo-ui .btn-secondary,
#ors_no_modal .btn-secondary,
#fund_cluster_no_modal .btn-secondary {
  --bo-bg: #f1f4f8;
  --bo-bd: #d5dce5;
  --bo-fg: #344054;
  --bo-bg-hover: #e6ebf1;
  --bo-bd-hover: #c3ccd8;
  --bo-fg-hover: #1d2939;
  --bo-bg-active: #dce3eb;
  --bo-ring: rgba(100, 116, 139, 0.28);
}

/* Light: the search buttons and the greyed "not yet" placeholders. */
.bo-ui .btn-light {
  --bo-bg: #ffffff;
  --bo-bd: #d5dce5;
  --bo-fg: #344054;
  --bo-bg-hover: #f3f6f9;
  --bo-bd-hover: #c3ccd8;
  --bo-fg-hover: #1d2939;
  --bo-bg-active: #e9eef3;
  --bo-ring: rgba(100, 116, 139, 0.28);
}

/* Outline buttons: transparent, with coloured text and border, and only a
   soft tint on hover instead of Bootstrap's full fill.

   Small action buttons in tables, cards and drawers (Edit, Delete, View PDF,
   View Details, On Hold, the greyed placeholders) are drawn the same way
   even where their markup says btn-warning / btn-danger / btn-primary, so a
   row of them reads as a set of outlines rather than coloured blocks. These
   keep their solid colour, as the main action of their dialog or drawer:
   small buttons in a modal footer, the drawer's Forward, and Generate TUPAD
   Voucher. */
.bo-ui .btn-outline-primary,
.bo-ui .btn-sm.btn-primary:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-fg: #1263cc;
  --bo-bd: #9fc2f1;
  --bo-bg: transparent;
  --bo-bg-hover: rgba(21, 114, 232, 0.07);
  --bo-bd-hover: #5f9cec;
  --bo-fg-hover: #0f55b0;
  --bo-bg-active: rgba(21, 114, 232, 0.13);
  --bo-ring: rgba(21, 114, 232, 0.28);
  --bo-shadow: none;
}

.bo-ui .btn-outline-success,
.bo-ui .btn-sm.btn-success:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-fg: #1b7f38;
  --bo-bd: #9fd4ad;
  --bo-bg: transparent;
  --bo-bg-hover: rgba(35, 160, 71, 0.07);
  --bo-bd-hover: #5bb874;
  --bo-fg-hover: #166b2f;
  --bo-bg-active: rgba(35, 160, 71, 0.13);
  --bo-ring: rgba(35, 160, 71, 0.28);
  --bo-shadow: none;
}

.bo-ui .btn-outline-warning,
.bo-ui .btn-sm.btn-warning:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-fg: #a35f00;
  --bo-bd: #edc68a;
  --bo-bg: transparent;
  --bo-bg-hover: rgba(232, 153, 42, 0.09);
  --bo-bd-hover: #e3a547;
  --bo-fg-hover: #8a5000;
  --bo-bg-active: rgba(232, 153, 42, 0.16);
  --bo-ring: rgba(245, 169, 59, 0.35);
  --bo-shadow: none;
}

.bo-ui .btn-outline-danger,
.bo-ui .btn-sm.btn-danger:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-fg: #c03a42;
  --bo-bd: #eeaeb1;
  --bo-bg: transparent;
  --bo-bg-hover: rgba(220, 76, 84, 0.07);
  --bo-bd-hover: #e07d83;
  --bo-fg-hover: #a33139;
  --bo-bg-active: rgba(220, 76, 84, 0.13);
  --bo-ring: rgba(220, 76, 84, 0.28);
  --bo-shadow: none;
}

/* Info is only used for the small View Details / drawer buttons. */
.bo-ui .btn-outline-info,
.bo-ui .btn-info {
  --bo-fg: #0f6fae;
  --bo-bd: #a3cff2;
  --bo-bg: transparent;
  --bo-bg-hover: rgba(72, 171, 247, 0.09);
  --bo-bd-hover: #6bb8f3;
  --bo-fg-hover: #0b5a8f;
  --bo-bg-active: rgba(72, 171, 247, 0.16);
  --bo-ring: rgba(72, 171, 247, 0.32);
  --bo-shadow: none;
}

.bo-ui .btn-outline-secondary,
.bo-ui .btn-sm.btn-light:not(.modal-footer *),
.bo-ui .btn-sm.btn-secondary:not(.modal-footer *) {
  --bo-fg: #475467;
  --bo-bd: #d0d7e1;
  --bo-bg: transparent;
  --bo-bg-hover: rgba(100, 116, 139, 0.07);
  --bo-bd-hover: #a4aebd;
  --bo-fg-hover: #1d2939;
  --bo-bg-active: rgba(100, 116, 139, 0.13);
  --bo-ring: rgba(100, 116, 139, 0.28);
  --bo-shadow: none;
}

/* Bootstrap's .shadow-sm is !important; outline buttons stay flat. The
   focus ring has to be !important as well to show through it. */
.bo-ui .btn.shadow-sm {
  box-shadow: none !important;
}

.bo-ui .btn.shadow-sm:focus-visible {
  box-shadow: 0 0 0 3px var(--bo-ring) !important;
}

/* Link buttons (Remarks, ADL No.) stay links: only a focus ring. */
.bo-ui .btn-link {
  font-weight: 500;
  box-shadow: none;
}

/* The search button sits flush against its input: square its joined side
   so the field and button read as one control. */
.bo-ui .input-group > .btn,
.bo-ui .input-group > .input-group-append > .btn {
  padding-top: 5px;
  padding-bottom: 5px;
}

/* The Bootstrap 4 style wrapper span is inline, which leaves the button
   shorter than the field. As a flex box it lets the button fill the row. */
.bo-ui .input-group > .input-group-append {
  display: flex;
}

.bo-ui .input-group > .input-group-append:last-child > .btn {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* Dialog close (x): a clear focus ring, nothing else. */
.bo-ui .btn-close:focus,
#ors_no_modal .btn-close:focus,
#fund_cluster_no_modal .btn-close:focus {
  box-shadow: none;
}

.bo-ui .btn-close:focus-visible,
#ors_no_modal .btn-close:focus-visible,
#fund_cluster_no_modal .btn-close:focus-visible {
  box-shadow: 0 0 0 3px rgba(21, 114, 232, 0.28);
}

/* Modal footers: even spacing between the buttons. */
.bo-ui .modal-footer,
#ors_no_modal .modal-footer,
#fund_cluster_no_modal .modal-footer {
  gap: 0.5rem;
}

.bo-ui .modal-footer > *,
#ors_no_modal .modal-footer > *,
#fund_cluster_no_modal .modal-footer > * {
  margin: 0;
}

/* DataTables paging buttons. */
.bo-ui .dt-paging .dt-paging-button {
  border-radius: 5px !important;
  font-size: 12px;
}

/* -------------------------------------------------- dark mode variants */
html[data-bs-theme="dark"] .bo-ui .btn,
html[data-bs-theme="dark"] #ors_no_modal .btn,
html[data-bs-theme="dark"] #fund_cluster_no_modal .btn {
  --bo-ring: rgba(124, 180, 255, 0.35);
}

/* Solid colours are a step deeper than in light mode so they sit on the
   dark surfaces instead of glowing. */
html[data-bs-theme="dark"] .bo-ui .btn-primary,
html[data-bs-theme="dark"] #ors_no_modal .btn-primary,
html[data-bs-theme="dark"] #fund_cluster_no_modal .btn-primary {
  --bo-bg: #2468c9;
  --bo-bd: #2f74d6;
  --bo-fg: #f8fafc;
  --bo-bg-hover: #2c76de;
  --bo-bd-hover: #3c82e4;
  --bo-bg-active: #1f5bb0;
  --bo-shadow: none;
}

html[data-bs-theme="dark"] .bo-ui .btn-success {
  --bo-bg: #1d7f3d;
  --bo-bd: #238a45;
  --bo-fg: #f0fdf4;
  --bo-bg-hover: #228e46;
  --bo-bd-hover: #2a9a50;
  --bo-bg-active: #196f35;
  --bo-ring: rgba(74, 200, 115, 0.32);
  --bo-shadow: none;
}

html[data-bs-theme="dark"] .bo-ui .btn-warning {
  --bo-bg: #c98a2b;
  --bo-bd: #d39433;
  --bo-fg: #1c1305;
  --bo-bg-hover: #d79a38;
  --bo-bd-hover: #e0a544;
  --bo-bg-active: #b97c22;
  --bo-ring: rgba(243, 192, 107, 0.35);
  --bo-shadow: none;
}

html[data-bs-theme="dark"] .bo-ui .btn-danger {
  --bo-bg: #b83a42;
  --bo-bd: #c4444c;
  --bo-fg: #fef2f2;
  --bo-bg-hover: #c8444c;
  --bo-bd-hover: #d34f57;
  --bo-bg-active: #a3323a;
  --bo-ring: rgba(242, 135, 141, 0.32);
  --bo-shadow: none;
}

html[data-bs-theme="dark"] .bo-ui .btn-secondary,
html[data-bs-theme="dark"] #ors_no_modal .btn-secondary,
html[data-bs-theme="dark"] #fund_cluster_no_modal .btn-secondary,
html[data-bs-theme="dark"] .bo-ui .btn-light {
  --bo-bg: var(--tupad-dark-surface-3);
  --bo-bd: #3a4964;
  --bo-fg: var(--tupad-dark-text);
  --bo-bg-hover: #2f3d57;
  --bo-bd-hover: #475a7a;
  --bo-fg-hover: var(--tupad-dark-text-strong);
  --bo-bg-active: #34445f;
  --bo-ring: rgba(148, 163, 184, 0.35);
}

html[data-bs-theme="dark"] .bo-ui .btn-outline-primary,
html[data-bs-theme="dark"] .bo-ui .btn-sm.btn-primary:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-ring: rgba(124, 180, 255, 0.35);
  --bo-shadow: none;
  --bo-bg: transparent;
  --bo-fg: var(--tupad-dark-link);
  --bo-bd: rgba(124, 180, 255, 0.4);
  --bo-bg-hover: rgba(124, 180, 255, 0.12);
  --bo-bd-hover: rgba(124, 180, 255, 0.7);
  --bo-fg-hover: #a9cdff;
  --bo-bg-active: rgba(124, 180, 255, 0.18);
}

html[data-bs-theme="dark"] .bo-ui .btn-outline-success,
html[data-bs-theme="dark"] .bo-ui .btn-sm.btn-success:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-shadow: none;
  --bo-bg: transparent;
  --bo-fg: #6fd49a;
  --bo-bd: rgba(111, 212, 154, 0.38);
  --bo-bg-hover: rgba(111, 212, 154, 0.12);
  --bo-bd-hover: rgba(111, 212, 154, 0.65);
  --bo-fg-hover: #96e2b6;
  --bo-bg-active: rgba(111, 212, 154, 0.18);
  --bo-ring: rgba(111, 212, 154, 0.32);
}

html[data-bs-theme="dark"] .bo-ui .btn-outline-warning,
html[data-bs-theme="dark"] .bo-ui .btn-sm.btn-warning:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-shadow: none;
  --bo-bg: transparent;
  --bo-fg: #f3c06b;
  --bo-bd: rgba(243, 192, 107, 0.38);
  --bo-bg-hover: rgba(243, 192, 107, 0.12);
  --bo-bd-hover: rgba(243, 192, 107, 0.65);
  --bo-fg-hover: #f7d394;
  --bo-bg-active: rgba(243, 192, 107, 0.18);
  --bo-ring: rgba(243, 192, 107, 0.32);
}

html[data-bs-theme="dark"] .bo-ui .btn-outline-danger,
html[data-bs-theme="dark"] .bo-ui .btn-sm.btn-danger:not(.modal-footer *):not(#drawer_forward_btn):not(.generate_ob_dv_btn) {
  --bo-shadow: none;
  --bo-bg: transparent;
  --bo-fg: #f2878d;
  --bo-bd: rgba(242, 135, 141, 0.38);
  --bo-bg-hover: rgba(242, 135, 141, 0.12);
  --bo-bd-hover: rgba(242, 135, 141, 0.65);
  --bo-fg-hover: #f6a9ad;
  --bo-bg-active: rgba(242, 135, 141, 0.18);
  --bo-ring: rgba(242, 135, 141, 0.32);
}

html[data-bs-theme="dark"] .bo-ui .btn-outline-info,
html[data-bs-theme="dark"] .bo-ui .btn-info {
  --bo-ring: rgba(140, 200, 248, 0.32);
  --bo-bg: transparent;
  --bo-fg: #8cc8f8;
  --bo-bd: rgba(140, 200, 248, 0.38);
  --bo-bg-hover: rgba(140, 200, 248, 0.12);
  --bo-bd-hover: rgba(140, 200, 248, 0.65);
  --bo-fg-hover: #b5dcfb;
  --bo-bg-active: rgba(140, 200, 248, 0.18);
}

html[data-bs-theme="dark"] .bo-ui .btn-outline-secondary,
html[data-bs-theme="dark"] .bo-ui .btn-sm.btn-light:not(.modal-footer *),
html[data-bs-theme="dark"] .bo-ui .btn-sm.btn-secondary:not(.modal-footer *) {
  --bo-bg: transparent;
  --bo-fg: #cbd5e1;
  --bo-bd: #475569;
  --bo-bg-hover: rgba(148, 163, 184, 0.1);
  --bo-bd-hover: #64748b;
  --bo-fg-hover: var(--tupad-dark-text-strong);
  --bo-bg-active: rgba(148, 163, 184, 0.16);
  --bo-ring: rgba(148, 163, 184, 0.35);
}

html[data-bs-theme="dark"] .bo-ui .btn-close:focus-visible,
html[data-bs-theme="dark"] #ors_no_modal .btn-close:focus-visible,
html[data-bs-theme="dark"] #fund_cluster_no_modal .btn-close:focus-visible {
  box-shadow: 0 0 0 3px rgba(124, 180, 255, 0.35);
}

/* ------------------------------------------------------- small screens */
@media (max-width: 575.98px) {
  .bo-ui .btn,
  #ors_no_modal .btn,
  #fund_cluster_no_modal .btn {
    padding: 6px 12px;
    font-size: 12.5px;
  }

  .bo-ui .btn-sm,
  #ors_no_modal .btn-sm,
  #fund_cluster_no_modal .btn-sm {
    padding: 4px 8px;
    font-size: 11.5px;
  }

  /* Long footer labels wrap onto a second row instead of overflowing. */
  .bo-ui .modal-footer,
  #ors_no_modal .modal-footer,
  #fund_cluster_no_modal .modal-footer {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}
