/* Our rules on top of AdminLTE 4. AdminLTE's own stylesheet is never edited - it is a pinned
   vendor file, and replacing it must stay a download rather than a merge.

   This reproduces the skin-sea-black palette the application has always used, expressed through
   AdminLTE 4's and Bootstrap 5's CSS variables rather than copied as literals, so that rebranding
   per client later is a matter of changing the values at the top. */

:root {
  /* The installation's branding (Access -> Branding) arrives as --brand-* variables from
     /branding/getcss, loaded before this file. The sea-black palette, taken from
     css/skins/skin-sea-black.css, is the fallback when it is missing. */
  --lma-brand:          var(--brand-primary, #2A5A63);   /* header and logo background */
  --lma-brand-dark:     var(--brand-primary-dark, #28565F);
  --lma-brand-accent:   #2A5A86;
  --lma-sidebar-bg:     var(--brand-sidebar-bg, #222d32);
  --lma-sidebar-link:   var(--brand-sidebar-text, #b8c7ce);
  --lma-sidebar-active: var(--brand-sidebar-active-bg, #1e282c);
  --lma-sidebar-submenu:var(--brand-sidebar-submenu-bg, #2C3B41);   /* flyout and open-submenu background */

  --bs-primary:     var(--lma-brand);
  --bs-primary-rgb: 42, 90, 99;
}

/* Header: the old one was solid #2A5A63 with white text. */
.app-header.navbar {
  background-color: var(--lma-brand) !important;
  border-bottom-color: var(--lma-brand-dark);
}
.app-header.navbar .nav-link,
.app-header.navbar .navbar-nav .nav-link { color: #ffffff; }
.app-header.navbar .nav-link:hover { color: #f6f6f6; background: rgba(0, 0, 0, .1); }

/* Sidebar: dark, with the brand colour as the active marker on the left edge. */
.app-sidebar { background-color: var(--lma-sidebar-bg); }
.sidebar-brand { background-color: var(--lma-brand-dark); }
.sidebar-brand .brand-link { color: #ffffff; }
.app-sidebar .nav-link { color: var(--lma-sidebar-link); }
.app-sidebar .nav-link:hover,
.app-sidebar .nav-link.active {
  color: #ffffff;
  background: var(--lma-sidebar-active);
  border-left: 3px solid var(--lma-brand);
}

/* Buttons that used btn-primary were the brand colour before; keep that. */
.btn-primary {
  --bs-btn-bg: var(--lma-brand);
  --bs-btn-border-color: var(--lma-brand);
  --bs-btn-hover-bg: var(--lma-brand-dark);
  --bs-btn-hover-border-color: var(--lma-brand-dark);
  --bs-btn-active-bg: var(--lma-brand-dark);
  --bs-btn-active-border-color: var(--lma-brand-dark);
  /* disabled keeps the brand colour, faded - Bootstrap's own is its default blue */
  --bs-btn-disabled-bg: var(--lma-brand);
  --bs-btn-disabled-border-color: var(--lma-brand);
  --bs-btn-disabled-opacity: .45;
}

/* The open-in-new-tab twin each menu row carries: visible on hover, so it does not compete with
   the label. The old menu floated it right at all times; this is quieter and does the same job. */
.app-sidebar .nav-item { position: relative; }
.app-sidebar .nav-newtab {
  position: absolute; inset-inline-end: .5rem; top: .45rem;
  padding: .15rem; line-height: 1; color: var(--lma-sidebar-link);
  opacity: 0; transition: opacity .15s;
}
.app-sidebar .nav-item:hover > .nav-newtab,
.app-sidebar .nav-newtab:focus-visible { opacity: .75; }
.app-sidebar .nav-newtab:hover { opacity: 1; }

/* Dense tables: these screens are lists of money, and default row padding costs about three rows
   of visible data per screen on a laptop. */
.table-dense > :not(caption) > * > * { padding-top: .3rem; padding-bottom: .3rem; }

/* Numbers line up on the decimal rather than the first digit. */
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ============================================================================================
   The collapsed sidebar's hover flyouts.

   AdminLTE 4's own answer to a mini sidebar is to expand the whole thing when the pointer touches
   it. This application has always done the AdminLTE 2 thing instead: the strip stays narrow, and
   hovering one item opens THAT item's submenu beside it, with the section name as a header and
   the open-in-new-tab icon on each row. sidebar-without-hover on <body> switches AdminLTE's
   version off; everything below builds ours.

   TWO THINGS THAT BIT, both invisible to measurement - the elements had the right coordinates
   while nothing appeared on screen:

   1. .sidebar-wrapper is overflow-x:hidden and 74px wide when collapsed, so a flyout at left:100%
      is CLIPPED. It has to be allowed out. Collapsed, the menu is eleven icons and does not need
      to scroll, so overflow:visible costs nothing there; expanded, AdminLTE's own rules apply
      again because every selector here is scoped to .sidebar-mini.sidebar-collapse.

   2. The header must not be the <p> inside the link. Making that absolute takes it out of the
      flow and the row shrinks from 43px to 35px - the "jumping" when the pointer crosses it.
      The header is a ::before on the submenu instead, reading data-section off it, so nothing in
      the link moves at all.
   ============================================================================================ */

/* the mark shows only when collapsed - AdminLTE sets display:inline-block on .logo-xs there */
.app-sidebar .logo-xs { display: none; }
.sidebar-mini.sidebar-collapse .app-sidebar .brand-mark.logo-xs {
  display: inline-block;
  width: 100%;
  text-align: center;
  font-weight: 600;
  color: #fff;
}
.app-sidebar .brand-image.logo-xs { max-height: 2rem; }

/* 1. let the flyout out of the narrow strip */
.sidebar-mini.sidebar-collapse .app-sidebar .sidebar-wrapper { overflow: visible; }
.sidebar-mini.sidebar-collapse .app-sidebar .sidebar-menu > .nav-item { position: relative; }

/* 2. the submenu, beside the strip. Nothing in the link is touched, so no row changes height. */
.sidebar-mini.sidebar-collapse .app-sidebar .sidebar-menu > .nav-item:hover > .nav-treeview {
  display: block;
  position: absolute;
  inset-inline-start: 100%;
  top: 0;
  z-index: 1040;
  width: 15rem;
  padding: 0 0 .25rem;
  background: var(--lma-sidebar-submenu, #2C3B41);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4);
}

/* the section name, as the flyout's header */
.sidebar-mini.sidebar-collapse .app-sidebar .sidebar-menu > .nav-item:hover > .nav-treeview::before {
  content: attr(data-section);
  display: block;
  padding: .6rem 1rem;
  margin-bottom: .25rem;
  font-weight: 600;
  white-space: nowrap;
  color: #fff;
  background: var(--lma-brand);
}

.sidebar-mini.sidebar-collapse .app-sidebar .sidebar-menu > .nav-item:hover > .nav-treeview .nav-link {
  width: auto;
  white-space: nowrap;
}
/* Inside a flyout the label is wanted, whatever AdminLTE did to it in the strip - and it does
   three separate things to hide it. width:0 and visibility are the obvious two; the third is an
   animation, fadeOut with animation-fill-mode:both, which pins opacity at 0 and survives any
   amount of overriding the other two. Undoing the animation is what actually makes the text
   appear; without it the row renders with its icons and an invisible label. */
.sidebar-mini.sidebar-collapse .app-sidebar .sidebar-menu > .nav-item:hover > .nav-treeview .nav-link p {
  display: inline-block;
  width: auto;
  visibility: visible;
  opacity: 1;
  animation: none;
}

/* the open-in-new-tab icon: always visible inside a flyout, where there is room for it */
.sidebar-mini.sidebar-collapse .app-sidebar .nav-treeview .nav-newtab { opacity: .75; }
.sidebar-mini.sidebar-collapse .app-sidebar .nav-treeview .nav-newtab:hover { opacity: 1; }

/* ============================================================================================
   The brand: mark and title.

   AdminLTE's .brand-image carries its own left and right margins, which inside a 74px strip put
   the logo 37px from the left edge and 5px from the right - visibly off-centre, and the reason it
   looked shifted. The link is also flush against the edge when the sidebar is open, so the title
   sat hard against the border with no logo beside it.
   ============================================================================================ */

.app-sidebar .brand-link {
  display: flex;
  align-items: center;
  gap: .625rem;
  height: 3.5rem;
  padding: 0 1rem;
  overflow: hidden;
  color: #fff;
  text-decoration: none;
}
.app-sidebar .brand-image {
  width: 2rem;
  height: 2rem;
  margin: 0;            /* AdminLTE's own margins are what pushed it off centre */
  flex: 0 0 auto;
  object-fit: contain;
}
.app-sidebar .brand-text {
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: .01em;
  white-space: nowrap;
}

/* collapsed: the mark alone, centred in the strip */
.sidebar-mini.sidebar-collapse .app-sidebar .brand-link {
  justify-content: center;
  padding: 0;
  gap: 0;
}
.sidebar-mini.sidebar-collapse .app-sidebar .brand-mark.logo-xs {
  width: auto;          /* was 100%, which fought the centring */
}

/* ============================================================================================
   Content that fits the window.

   The card sat flush under the header with no gap, 20px of padding each side, and ran 37px past
   the bottom of the window so the whole page scrolled.

   Two earlier attempts at this were worse than the problem. Flexing the chain down into
   DataTables' own structure made its button row stretch across the width and left the scroll body
   unconstrained at 23953px; removing the height cap without giving the chain a definite height
   expanded it to all 580 rows. DataTables' scrollY already works - it just needs a better number
   than the 65vh that correctTableHeight puts there, so that is all this changes.

   A screen opts in with card-fill on its card.
   ============================================================================================ */

/* even, modest padding instead of 8px + 12px nested */
.app-content > .container-fluid { padding: .5rem; }

.card.card-fill { margin-bottom: 0; }

/* 24rem is the header, the padding and the card's own chrome - tabs, the button row, the table
   head, the info and pagination line. Erring small is harmless: a little space under the table.
   Erring large brings back the page scroll, which is the thing being fixed. !important because
   base-vm.js sets the height inline and an inline style wins otherwise. */
/* The height is set by fitTables() in the layout, measured per screen. A constant cannot work
   here: payment/list carries a date-range form above its table and needs 173px less than the
   loan list, and any single number is wrong for one of them. Only the cap is lifted here. */
.dataTables_scrollBody { max-height: none !important; }

/* ---- the surface cards sit on ----
   .app-content is transparent and the body resolves to white, so on a screen that is one large
   card - vars, logs, the reports - the card was white on white and read as no card at all: its
   border fell outside the window and there was nothing to see it against. */
/* An explicit value, not --bs-tertiary-bg: that resolves to #f8f9fa, which against a white card
   is a difference you have to look for. The card should be obvious without looking. */
body.layout-fixed .app-main { background: #eceff3; }

/* and give the cards an edge that reads at a glance */
.app-content .card,
.app-content .box,
.app-content .nav-tabs-custom {
  border-color: #dde3ea;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .04);
}

/* ============================================================================================
   DENSITY

   These are screens for reading rows of money, and the application was running at a 16px base
   with 35px table rows - sixteen loans on a 959px window. Everything below is one decision:
   show more without making it harder to read. Measured rather than judged by eye, before and
   after, on the same window.

   One place to change it: --lma-font-base. The old layout's inline style="font-size:16px" is
   gone, because an inline style beats every rule here.
   ============================================================================================ */

:root { --lma-font-base: 14px; }

body { font-size: var(--lma-font-base); }

/* tables: the thing there is most of */
.app-content table.dataTable,
.app-content .table { font-size: .875rem; }
.app-content table.dataTable td,
.app-content table.dataTable th,
.app-content .table > :not(caption) > * > * { padding: .25rem .5rem; }
.app-content table.dataTable thead th {
  font-size: .8125rem;
  font-weight: 600;
  /* headers wrap, as on prod: the realty list has fourteen columns, and one-line headers pushed
     it past the card into a sideways scrollbar. Bottom-aligned so one- and two-line headers
     share a baseline. */
  white-space: normal;
  vertical-align: bottom;
  color: var(--bs-secondary-color, #6c757d);
  background: var(--bs-tertiary-bg, #f8f9fa);
}

/* the chrome around a table: every row of it costs a row of data */
.dataTables_wrapper .row { --bs-gutter-y: 0; }
.dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate { font-size: .8125rem; }
.dataTables_filter input, .dataTables_length select { padding: .15rem .4rem; font-size: .8125rem; }
.dt-buttons .btn { padding: .2rem .6rem; font-size: .8125rem; }
.page-link { padding: .2rem .5rem; font-size: .8125rem; }

/* cards and toolbars */
.app-content .card-body,
.app-content .box-body { padding: .75rem; }
.nav-tabs-custom > .tab-content { padding: .75rem; }
.nav-tabs-custom > .nav-tabs > li > a { padding: .45rem .85rem; font-size: .875rem; }
.app-content .btn { padding: .3rem .7rem; font-size: .875rem; }
.app-content .btn > .bi { font-size: .95rem; }

/* form controls on the screens as well as in dialogs */
.app-content .form-control,
.app-content .form-select { padding: .25rem .55rem; font-size: .875rem; min-height: calc(1.5em + .5rem + 2px); }
.app-content label { font-size: .8125rem; margin-bottom: .15rem; }

/* btn-info: Bootstrap's own is a bright cyan that belongs to nothing else on the page. A quiet
   brand-tinted button instead - it marks secondary actions such as "open this loan". */
.btn-info {
  --bs-btn-color: var(--lma-brand);
  --bs-btn-bg: rgba(42, 90, 99, .1);
  --bs-btn-border-color: rgba(42, 90, 99, .25);
  --bs-btn-hover-color: #fff;
  --bs-btn-hover-bg: var(--lma-brand);
  --bs-btn-hover-border-color: var(--lma-brand);
  --bs-btn-active-color: #fff;
  --bs-btn-active-bg: var(--lma-brand-dark);
  --bs-btn-active-border-color: var(--lma-brand-dark);
}

/* ---- Table toolbar: Copy / CSV / Excel and the search box on one line ----
   The views build their tables with dom: 'Bfrtip' - no Bootstrap rows round the controls - and
   the old DataTables stylesheet floated the buttons left and the search right. The Bootstrap 5
   integration has no floats, so each control took a line of its own. The wrapper becomes a
   wrapping flex row: buttons and length on the left, search pushed right, info and pager sharing
   the bottom line, and everything else (the table, the scroll area) a full-width line of its own. */
.dataTables_wrapper:has(> .dt-buttons, > .dataTables_filter) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: .5rem;
}
.dataTables_wrapper:has(> .dt-buttons, > .dataTables_filter) > * { flex: 0 0 100%; min-width: 0; }
.dataTables_wrapper:has(> .dt-buttons, > .dataTables_filter) > :is(.dt-buttons, .dataTables_length, .dataTables_filter, .dataTables_info, .dataTables_paginate) {
  flex: 0 0 auto;
  width: auto;
  margin-bottom: .375rem;
}
.dataTables_wrapper:has(> .dt-buttons, > .dataTables_filter) > :is(.dataTables_filter, .dataTables_paginate) { margin-inline-start: auto; }
.dataTables_wrapper:has(> .dt-buttons, > .dataTables_filter) > .dataTables_filter label { margin: 0; }
.dataTables_wrapper:has(> .dt-buttons, > .dataTables_filter) > .dataTables_processing { flex: none; }

/* Sort arrows on the header text's own line. DataTables centres them in the cell, which was
   right while every header was one line; with headers that wrap (as on prod) a two- or
   three-line header left the arrows floating above a bottom-aligned label. */
.app-content table.dataTable thead > tr > th:is(.sorting, .sorting_asc, .sorting_desc, .sorting_asc_disabled, .sorting_desc_disabled)::before { top: auto; bottom: 14px; }
.app-content table.dataTable thead > tr > th:is(.sorting, .sorting_asc, .sorting_desc, .sorting_asc_disabled, .sorting_desc_disabled)::after { top: auto; bottom: 5px; }

/* ---- frosted until the bindings are applied ----
   The layout puts lma-booting on <body> and lifts it on the first ko.applyBindings (see the
   script after knockout in _layout.adminlte.cshtml). Until then the role- and state-driven parts
   of a screen are all shown at once, so the screen is blurred and not clickable rather than
   showing controls that are about to disappear. */
body.lma-booting .app-content,
body.lma-booting .app-sidebar .sidebar-wrapper {   /* the menu's items are role-bound too */
  filter: blur(3px);
  opacity: .6;
  pointer-events: none;
  user-select: none;
}
.app-content,
.app-sidebar .sidebar-wrapper { transition: filter .2s ease-out, opacity .2s ease-out; }

/* ---- notices (showNotice in helpers.js) ----
   Top centre, over everything including dialogs, gone by themselves after six seconds. */
.lma-notices {
  position: fixed;
  inset-block-start: 4.25rem;
  inset-inline: 0;
  z-index: 2000;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.lma-notice {
  pointer-events: auto;
  max-width: min(40rem, calc(100vw - 2rem));
  margin: 0;
  padding-block: .6rem;
  font-size: .9375rem;
  transition: opacity .4s ease-out, transform .4s ease-out;
  animation: lma-notice-in .2s ease-out;
}
.lma-notice-out { opacity: 0; transform: translateY(-.5rem); }
@keyframes lma-notice-in { from { opacity: 0; transform: translateY(-.5rem); } }

/* Wide reports (16+ columns - the perspective report has 20) get slightly tighter cells: the
   perspective report came out 20px wider than a 1650px card and scrolled sideways for it.
   The class is set once by helpers.js when DataTables initialises the table. NOT a
   :has(th:nth-child(16)) selector: that made the browser re-test every cell of every table on
   every change - 0.9 s per style recalculation in the loan card, several per tab switch, which
   froze the card for tens of seconds (measured 21.11.2026). */
.app-content .lma-wide table.dataTable > * > tr > :is(td, th) { padding-inline: .35rem; }

/* ---- while a dialog is open, the page's own tables are not laid out ----
   The loan card opens over the loan list: 580 rows, ~7000 cells, behind the backdrop. Every
   re-layout inside the dialog - a tab switch, DataTables measuring its columns - laid that list
   out again too: 0.3 s per column measurement, 0.1 s per style recalculation, several per tab
   switch (measured 21.11.2026; with the list skipped, 18 ms and 8 ms). content-visibility keeps
   the list's box and size, so nothing behind the dialog moves; helpers.js sets the class when a
   dialog starts opening and clears it when the last one starts closing, before anything can
   measure the list again. */
body.lma-dialog-open .dataTables_scrollBody:not(.modal .dataTables_scrollBody) {
  content-visibility: hidden;
}

/* ---- a filter bar: the fields of a list's header on one wrapping line (logs) ----
   Fixed widths instead of Bootstrap columns, so they do not stretch apart on a wide window and
   the whole filter fits one line down to a ~1300px content area. The "delete older than" pair
   goes to the right end of the line. */
.lma-filterbar { flex: 0 0 100%; display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 .75rem; }
.lma-filterbar > .form-group { flex: 0 0 auto; margin-bottom: .25rem; }
.lma-filterbar > .lma-f-date { width: 9.5rem; }
.lma-filterbar > .lma-f-select { width: 10.5rem; }
.lma-filterbar > .lma-f-btn { width: 7.5rem; }
.lma-filterbar > .lma-f-push { margin-inline-start: auto; }
/* a label longer than its field keeps one line and sets the width; the date itself stays narrow */
.lma-filterbar > .lma-f-label-wide { width: auto; }
.lma-filterbar > .lma-f-label-wide > label { white-space: nowrap; }
.lma-filterbar > .lma-f-label-wide > .input-group { width: 9.5rem; }

/* ---- choose-file buttons ----
   The browser's own <input type="file"> wrote "Choose File / No file chosen" in the browser's
   language, not the screen's. The input is now hidden inside a paperclip button (a <label>, so a
   click still opens the file dialog) whose tooltip comes from AppStrings; the chosen files are
   listed under it as before. */
.lma-file-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 2.5rem; cursor: pointer; }
.lma-file-btn:focus-within { box-shadow: 0 0 0 .2rem rgba(var(--bs-secondary-rgb), .35); }
.lma-file-btn.disabled { pointer-events: none; opacity: .5; }
