/* Dasuni brand navy — single source of truth. Previously hardcoded as
   #171D64 in ~16 places across this file. Kept the same value across
   light and dark themes — the navbar and footer use navy regardless of
   page theme to preserve brand identity. */
:root {
    --brand-navy: #171D64;
}

html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

/* App-shell layout. The header and footer are always on screen; only the
   work area between them scrolls. <body> is a fixed-height (100vh) flex
   column that itself never scrolls — the middle .content-scroll region owns
   the vertical scrollbar. This mirrors the desktop-app / Microsoft Access
   feel the system replaces: persistent window chrome wrapping a scrolling
   work area, consistent on every route. */
:root {
    --footer-height: 3.5rem;
}

html, body {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header and footer keep their natural height and never shrink, so they stay
   pinned to the top and bottom of the viewport. position:relative + z-index
   keeps them (and the navbar dropdown) painted above the work area. */
header,
footer.footer {
    flex-shrink: 0;
    position: relative;
    z-index: 1030;
}

/* The scrolling work area. flex:1 fills the gap between header and footer;
   min-height:0 is required so the flex item may shrink below its content
   size and actually scroll. overflow-x:hidden contains the .content-escape
   100vw breakout (wide PO tables) without a horizontal document scrollbar. */
.content-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Breakout utility: lets a child of a centered .container expand to the
   full viewport width without changing its parent's layout. Used for wide
   grids (PO index etc.) so the page chrome stays aligned with every
   other route while only the table escapes the container cap. */
.content-escape {
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
}

/* Grid index pages delegate vertical scroll to the AG Grid widget, which
   sizes itself to fit the work area. Hide the work-area scrollbar on those
   routes so it doesn't render a second redundant track alongside the
   grid's own. */
body.po-index-page .content-scroll {
    overflow: hidden;
}

/* Make the grid work area a flex column so the AG Grid host fills the space
   between the page heading/controls and the app footer, rather than the fixed
   74vh the views request inline. A fixed viewport-relative height overflows on
   short screens — heading + controls + 74vh grid is taller than the work area
   — and because .content-scroll is overflow:hidden here, the overflow (the
   grid's own pagination/footer bar) gets clipped behind the pinned app footer.
   Flex-filling sizes the grid to exactly the room available, so its footer is
   always on screen at any height. The inline height is overridden below. */
body.po-index-page .content-wrap {
    height: 100%;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.po-index-page main {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* .grid-fill marks the breakout that hosts the AG Grid itself — toolbars
   also escape to full width (plain .content-escape) but must not stretch. */
body.po-index-page .content-escape.grid-fill {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

body.po-index-page .content-escape.grid-fill > div {
    flex: 1 1 auto;
    min-height: 0;
    height: auto !important;   /* override the inline 72/74vh from the views */
}

/* Printing: undo the app-shell so the full document flows onto paper rather
   than clipping to the single screen of the scroll region. */
@media print {
    body {
        display: block;
        height: auto;
        overflow: visible;
    }

    .content-scroll {
        overflow: visible;
    }
}


header {
    font-family: 'Nirmala UI';
    font-weight: bold;
    background-color: var(--brand-navy);
}

/* Navbar page title (set via ViewData["HeaderTitle"], see _Layout). Takes the
   brand slot on inner pages; ellipsize rather than wrap if it ever overflows
   next to the account dropdown. */
header .navbar-page-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
}

/* Header action buttons (the HeaderActions section — e.g. Copy PO Number) sit
   inline next to the page title. Strip the leaked vertical margin from the
   global `button { margin: 5px }` rule so the button's box doesn't exceed the
   title's line height and grow the navbar on those pages. */
header .navbar .btn {
    margin-top: 0;
    margin-bottom: 0;
}

footer {
    background-color: var(--brand-navy);
}

h1 {
    font-family: 'Nirmala UI';
    font-size: 36px;
    font-weight: bold;
    color: var(--brand-navy);
}

/* Home page section headers (United Kingdom / United States / Global / Admin)
   sized to match the navbar brand wordmark rather than the 36px default h1. */
h1.card-title {
    font-size: 1.25rem;
}

h3 {
    font-family: 'Nirmala UI';
    font-size: 24px;
    font-weight: bold;
    color: var(--brand-navy);
    padding-top: 10px;
}

/* In dark mode (data-bs-theme="dark" on <html>) the brand-navy heading
   colour sits on Bootstrap's near-black --bs-body-bg and effectively
   disappears. Swap to Bootstrap's emphasis colour token, which resolves
   to the right contrast value for the active theme automatically.
   No-op today because there's no page-level theme switcher yet; lays
   the groundwork for the parked theme picker. */
[data-bs-theme="dark"] h1,
[data-bs-theme="dark"] h3 {
    color: var(--bs-emphasis-color);
}

/* Dark-mode button edges. Brand-navy (#171D64) buttons sitting on
   Bootstrap's dark page bg (~#212529) have very low contrast — the
   navy slabs nearly merge into the page. A soft white rim gives every
   button a defined edge without the harsh #0d6efd that Bootstrap's
   .btn-primary variant applies (which was only landing on the three
   submit buttons, leaving the four anchor buttons unbordered →
   inconsistent). One rule covers both <a class="btn"> and
   <button class="btn[-primary]"> so all home-page buttons look the same. */
[data-bs-theme="dark"] a.btn,
[data-bs-theme="dark"] button.btn {
    --bs-btn-border-color: rgba(255, 255, 255, 0.2);
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.35);
}

div.flex-box {
    display: flex;
    flex-wrap: wrap;
    padding-bottom: 20px;
}

h2.clientdivheader {
    width: 100%;
    color: #FFFFFF;
    background-color: var(--brand-navy);
    border-top-left-radius: 25px;
    border-top-right-radius: 25px;
    padding: 5px;
    /* Smaller heading to conserve space — matches the PO Allocation card. */
    font-size: 1.2rem;
    margin-bottom: 0;
    /* Centre the title + "+" together horizontally (and vertically) as one
       group, so the "+" doesn't trail off the end of the centred text. */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* The "+" add-circle inside a section header is 36px by default, which forces
   the (now small) header bar taller. Render it as a small equal-sided circle
   with the glyph flex-centred; scoped to .clientdivheader so other pages' "+"
   are unchanged. */
h2.clientdivheader a.w3-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    padding: 0;
    font-size: 1.1rem;
    line-height: 1;
    vertical-align: middle;
}

div.clientdiv {
    border-style: solid;
    border-color: var(--brand-navy);
    border-width: 1px;
    border-radius: 25px;
    margin-bottom: 20px;
    overflow: auto;
}

div.clientdivcontent {
    margin-left: 15px;
    margin-right:15px
}

/* Client Detail — the two per-client PO grids (UK / US) sit side by side and
   wrap to stacked on narrow screens. Each grid gets a fixed height so AG Grid
   can virtualise/scroll its rows. */
.po-grids {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.po-grids > .clientdiv {
    flex: 1 1 0;
    min-width: 340px;
}

.po-client-grid {
    height: 340px;
    width: 100%;
}

/* The per-client list-section grids on Client/Detail (Contacts, Services,
   Related Clients, Client Emails). Fixed height so AG Grid scrolls its rows. */
.cs-grid {
    height: 300px;
    width: 100%;
}

/* Auto-height variant (Services / Related Clients / Client Emails): the grid
   sizes to its rows via domLayout:autoHeight, but is capped at the old fixed
   height and scrolls beyond it — so sparse sections don't waste space. */
.cs-grid-auto {
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
}

/* Keep the empty/sparse state compact: shrink the "No Rows To Show" overlay
   band so an empty section is only a thin strip under its header. */
.cs-grid-auto .ag-overlay-no-rows-wrapper {
    padding: 0.4rem;
}
.cs-grid-auto .ag-overlay-no-rows-center {
    margin: 0;
}

/* Drop the header bar's default bottom margin so the grid sits flush against
   it (no strip of card background showing between the header and the grid) —
   for the PO grids and any card whose header is immediately followed by a grid. */
.po-grids .clientdivheader,
.clientdivheader:has(+ .cs-grid) {
    margin-bottom: 0;
}

div.table {
    overflow-y:auto;
}

/* Labels */

label {
    font-weight:bold;
}

div.form-group {
    padding-bottom: 15px
}

/* Links — brand keeps Bootstrap's default size so the Home page wordmark
   matches the page titles that occupy the same slot on sub pages. */
a.navbar-brand {
    color: #FFFFFF;
}

a.nav-link {
    font-size: 20px;
    color: #FFFFFF;
    padding-bottom: 0px;
}

/* Visibly muted state for any element gated by role — used by both the
   manually-disabled Admin nav link in _Layout.cshtml and the AdminOnlyTagHelper
   that gates [admin-only] anchors/buttons across Index/Detail views. Keyed off
   aria-disabled="true" rather than a class so we get one rule that covers
   .nav-link, .w3-btn, .w3-circle, and any future button class consistently. */
[aria-disabled="true"] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Theme switcher in the user dropdown. The ✓ next to the selected option
   is shown via JS by toggling visibility; the default is hidden so all
   three rows have stable layout regardless of which is selected. */
.dropdown-item .theme-check {
    visibility: hidden;
}

/* PO Edit form: labels sit to the LEFT of their controls so every input lines
   up flush in one column — a table-style two-column layout done with CSS grid
   (label column + control column). Help text and validation messages drop
   below the control, aligned with it. Multi-column groups inside a .row (the
   date pair and the cost triples) revert to the default stacked layout so they
   aren't squashed into the narrow grid columns. */
.po-form .form-group {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: center;
    column-gap: 1rem;
    margin-bottom: 0;
    line-height: 1.25;
}

.po-form .form-group > label {
    margin-bottom: 0;
}

.po-form .form-group > small,
.po-form .form-group > .text-danger {
    grid-column: 2;
}

/* Checkboxes sit at the start of the value column — left-aligned with the other
   inputs, not stretched or centred across it. */
.po-form .form-group input[type="checkbox"] {
    justify-self: start;
    width: auto;
}

/* A group of linked inputs sharing one form-group's value column (e.g.
   Cost x Quantity = Total): inline on one line, each with its own inline label,
   the inputs sharing the available width. */
.po-form .form-group .inline-fields {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.po-form .form-group .inline-fields .form-control {
    flex: 1 1 5rem;
    min-width: 4rem;
}

.po-form .form-group .inline-fields > label {
    margin-bottom: 0;
    white-space: nowrap;
}

.po-form .row .form-group {
    display: block;
}

/* Cost/tax fields: keep the three columns, but put the label to the LEFT of the
   input (rather than stacked above it). Scoped to .po-details so the accounts
   checkbox row is unaffected. The label sizes to its text so the narrow columns
   keep as much room as possible for the input. The "Fields under review" row
   (Foreign Net/Tax/Total) sits outside .po-details but wants the same treatment,
   so it opts in via .row.fields-under-review. */
.po-form .po-details .row .form-group,
.po-form .row.fields-under-review .form-group {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 0.5rem;
}

/* Compact density — trim Bootstrap's default vertical padding so the long PO
   form fits far more on screen with less scrolling. Applies to the Tom Select
   control too so it stays the same height as the plain inputs. */
.po-form .form-control,
.po-form .form-group .btn {
    padding-top: 0.05rem;
    padding-bottom: 0.05rem;
    min-height: auto;
}

.po-form .form-text {
    margin-top: 0.1rem;
    font-size: 0.8rem;
}

.po-form h2 {
    font-size: 1.4rem;
    margin-top: 0.85rem;
    margin-bottom: 0.4rem;
}

.po-form fieldset {
    margin-top: 0.5rem;
}

/* Allocation + Approval Document as a card floated into the form's top-right
   empty space; the single-column fields flow down the left and under it. Keeps
   the field layout unchanged (no two-column split). */
.po-form .po-side-float {
    float: right;
    width: 20rem;
    margin: 0 0 1rem 1.5rem;   /* breathing room to the left of and below the card */
}

.po-form .po-side-card {
    border: 1px solid var(--brand-navy);
    border-radius: 12px;
    padding: 0 1rem 1rem;
    overflow: hidden;   /* clip the header bar's corners to the card radius */
}

/* Navy filled header bar (same treatment as the .clientdivheader cards), kept
   at the card's small heading size. Negative side/top margins bleed it to the
   card edges; the card's overflow:hidden rounds its top corners. */
.po-form .po-side-card h2 {
    font-size: 1.2rem;
    margin: 0 -1rem 1rem;
    padding: 0.4rem 1rem;
    color: #FFFFFF;
    background-color: var(--brand-navy);
    text-align: center;
}

/* Stacked labels inside the narrow card (the main form's 220px label column
   won't fit here). */
.po-form .po-side-card .form-group {
    display: block;
}

.po-form .po-side-card .form-group > label {
    display: block;
    margin-bottom: 0.25rem;
}

/* On narrow screens drop the float so the card spans full width above the fields. */
@media (max-width: 992px) {
    .po-form .po-side-float {
        float: none;
        width: 100%;
        margin-left: 0;
    }
}

/* PO Edit: keep the header (PO number + Update) pinned at the top while the
   fields scroll. We rely on the page's existing .content-scroll region, so the
   scrollbar stays at the viewport edge and the fields keep their full width
   (an inner-scroll container would steal the scrollbar's width from them).
   Zeroing the work-area's top padding means the header sits at the very top on
   load, so it pins with no initial movement. */
body.po-edit-page main {
    /* Bootstrap's .py-3 sets padding-top with !important, so match it to keep
       the header flush with the top of the scroll region (no pre-pin shift). */
    padding-top: 0 !important;
}

.po-edit-sticky {
    position: sticky;
    top: 0;
    z-index: 1020;
    background-color: var(--bs-body-bg);
    padding: 0.5rem 0;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--bs-border-color);
}

/* Update reads as clearly disabled (a muted grey, not a faded primary) when
   there are no pending changes. */
#po-update-btn:disabled,
#cs-update-btn:disabled {
    background-color: var(--bs-secondary-bg);
    border-color: var(--bs-border-color);
    color: var(--bs-secondary-color);
    opacity: 1;
}

/* Hide the inline "New" create buttons when their section is disabled — the
   read-only PO view, or the accounts section for non-admins — rather than
   showing a greyed, useless button. */
fieldset[disabled] [data-inline-create],
fieldset[disabled] [data-po-match-date] {
    display: none;
}

/* Modified-field cue (set by po-dirty-fields.js): marks any control whose value
   differs from its on-load value, so the user can see what they've changed
   before saving. A faint translucent amber tint that reads on both light and
   dark themes — applied uniformly to inputs, textareas and selects. */
.field-modified {
    background-color: rgba(240, 173, 78, 0.18);
}

.field-modified:focus {
    background-color: rgba(240, 173, 78, 0.22);
}

/* A custom background-color on a native <select> makes the browser paint the
   option popup with that colour over white — in dark theme the theme's light
   option text then sits on a near-white strip and is unreadable. Pin the
   options back to the theme's own colours so the dropdown stays readable while
   the closed control keeps the amber tint. */
select.field-modified option {
    background-color: var(--bs-body-bg);
    color: var(--bs-body-color);
}

/*a {
    color: #FFFFFF;
    text-decoration: none;
}

a:hover {
    color: #FFFFFF;
}*/

/* Top navbar link hover effect — text shifts right + » chevron reveals.
   Strictly scoped to .navbar-nav > .nav-item > .nav-link so the effect
   only fires on Home / Admin / About, not on every <li><span> in the
   app. Previously a bare `li span` selector that bled into dropdown
   menus — making the theme picker's tick span sprout a chevron on
   hover, and (because of `li:hover span { color: #FFFFFF }`) turning
   the tick white-on-white-bg in light mode. */
.navbar-nav > .nav-item > .nav-link span {
    cursor: pointer;
    display: inline-block;
    position: relative;
    transition: 0.5s;
}

.navbar-nav > .nav-item > .nav-link span::after {
    content: '\00bb';
    position: absolute;
    opacity: 0;
    top: 0;
    right: -20px;
    transition: 0.5s;
}

.navbar-nav > .nav-item:hover > .nav-link span {
    color: #FFFFFF;
    padding-right: 25px;
}

.navbar-nav > .nav-item:hover > .nav-link span::after {
    opacity: 1;
    right: 0;
}

/* Buttons */
button {
    display: inline-block;
    font-family: 'Nirmala UI';
    font-size: 18px;
    font-weight: bold;
    color: #FFFFFF;
    background-color: var(--brand-navy);
    padding: 10px;
    border-radius: 4px;
    padding: 20px;
    transition: all 0.5s;
    cursor: pointer;
    margin: 5px;
}

button span {
    cursor: pointer;
    display: inline-block;
}

/* Hover affordance: lighten the button in place. filter:brightness changes no
   box dimensions, so it never reflows neighbours (the old `»` chevron grew the
   button via padding-right and shifted adjacent controls). */
button:hover {
    filter: brightness(1.3);
}

.btn-link {
    border: none;
    outline: none;
    background: none;
    cursor: pointer;
    color: #0000EE;
    padding: 0;
    text-decoration: underline;
    font-family: inherit;
    font-size: inherit;
}

/* ASP Buttons */
a.btn {
    display: inline-block;
    font-family: 'Nirmala UI';
    font-size: 18px;
    font-weight: bold;
    color: #FFFFFF;
    background-color: var(--brand-navy);
    border-radius: 4px;
    padding: 20px;
    transition: all 0.5s;
    cursor: pointer;
    margin: 5px;
}

a.btn span {
    cursor: pointer;
    display: inline-block;
}

/* Bootstrap 5.3 redefined `.btn:hover` to read `background-color` from
   `var(--bs-btn-hover-bg)`, which is undefined for a plain `.btn` (no
   .btn-primary/.btn-danger variant) — it resolves to transparent. That
   makes anchor buttons fade their brand-navy bg to white on hover, and
   the white span text disappears against the white page. Mirror the
   matching `button.btn:hover` rule below so anchor buttons keep their
   colours on hover/focus. */
a.btn:hover,
a.btn:focus,
a.btn:focus-visible,
a.btn:active {
    background-color: var(--brand-navy);
    color: #FFFFFF;
    filter: brightness(1.3);
}

/* Form Buttons */
button.btn {
    display: inline-block;
    font-family: 'Nirmala UI';
    font-size: 18px;
    font-weight: bold;
    color: #FFFFFF;
    background-color: var(--brand-navy);
    border-radius: 4px;
    /*padding: 20px;*/
    transition: all 0.5s;
    cursor: pointer;
    /* No asymmetric margin-top: it left every <button class="btn"> sitting
       ~5px below adjacent text/titles in flex or centered containers (navbar
       Copy PO Number, toolbar buttons, the "New Item" submit). The bare
       `button { margin: 5px }` rule keeps symmetric spacing so flex
       align-items:center centres the button against its neighbours. */
}

button.btn span {
    cursor: pointer;
    display: inline-block;
}

/* White text on the navy hover fill so outline variants can't land on their
   dark hover text colour (Bootstrap's .btn-outline-light:hover is black —
   that was the "weird black" on the navbar Copy PO Number button). */
button.btn:hover {
    background-color: var(--brand-navy);
    color: #FFFFFF;
    filter: brightness(1.3);
}

/* Form Circle Buttons */
a.w3-circle {
    text-decoration: none;
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: 5px;
    display: inline-block;
    font-family: 'Nirmala UI';
    font-size: 36px;
    font-weight: bold;
    color: #FFFFFF;
    background-color: var(--brand-navy);
    border-radius: 100px;
    /*padding: 20px;*/
    /*transition: all 0.5s;*/
    cursor: pointer;
    text-align: center;
}

/* Table Buttons */
a.w3-btn {
    text-decoration: none;
    padding-left: 10px;
    padding-right: 10px;
    display: inline-block;
    font-family: 'Nirmala UI';
    font-size: 18px;
    font-weight: bold;
    color: #FFFFFF;
    background-color: var(--brand-navy);
    border-radius: 4px;
    /*padding: 20px;*/
    /*transition: all 0.5s;*/
    cursor: pointer;
    text-align: center;
}

/* --- Third-party control reset -------------------------------------------
   AG Grid renders its own native <button> elements for the grid (header
   menus, column show/hide, paging). The brand button rules above use bare
   `button` / `button span` selectors that predate the grid and were never
   meant to reach it, so they leak the Nirmala-UI font, white text, margins
   and — most visibly — the `»` hover chevron (`button span:after`) onto
   every grid icon button. Neutralise those within the grid wrapper and the
   body-appended AG Grid popups (menus, dropdowns); the grid's own
   stylesheet then controls its appearance. The intended `»` reveal still
   fires on real app buttons (home page, form submits, etc.). */
.ag-root-wrapper button,
.ag-popup button {
    font-family: inherit;
    font-size: inherit;
    font-weight: inherit;
    color: inherit;
    margin: 0;
}

.ag-root-wrapper button span::after,
.ag-popup button span::after {
    content: none;
}

/* The brand effect also pads the span right by 25px on hover to make room
   for the reveal; with no chevron here that just leaves an empty gap, so
   drop the shift (and its transition) for grid controls. */
.ag-root-wrapper button span,
.ag-popup button span,
.ag-root-wrapper button:hover span,
.ag-popup button:hover span {
    padding-right: 0;
    transition: none;
}
