﻿html {
    height: 100%;
}

/* Fluent UI v5 injects `body { height: 100dvh; overflow: hidden }` for its own FluentLayout, where
   an inner region scrolls. The AdminLTE shell scrolls the document instead, so with Fluent's rule
   in force no page taller than the screen could be scrolled by wheel or touch. `html > body`
   outranks Fluent's `body` but not its `body:has(.prevent-scroll)`, which still locks the page
   behind an open dialog. */
html > body {
    height: auto;
    min-height: 100%;
    overflow: visible;
}

/* Bootstrap (AdminLTE) sets the page colours from data-bs-theme; the Fluent typeface stays, so
   the shell and the Fluent form controls inside it read as one app. */
body {
    font-family: var(--fontFamilyBase), system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* AdminLTE shell (see MainLayout). */
.app-header .nav-link.btn {
    display: inline-flex;
    align-items: center;
    border: 0;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.user-avatar {
    display: inline-grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bs-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.sidebar-brand .brand-link {
    gap: 10px;
    color: var(--bs-emphasis-color);
}

/* The MFVP logo is drawn on white, so it sits on a white tile in the dark sidebar and dark theme too. */
.brand-logo {
    height: 34px;
    width: auto;
    padding: 2px 4px;
    border-radius: 6px;
    background: #fff;
    object-fit: contain;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-menu .nav-link > p {
    margin: 0;
}

/* Content fills the space beside the sidebar, as in AdminLTE; a centred max-width left wide
   empty bands on large screens. Forms set their own readable width (.form-page). */
.app-content > .page-shell {
    padding: 20px 12px 40px;
}

/* Forms stay at a readable width, aligned left under the page title rather than centred. */
.page-shell .form-page {
    max-width: 1040px;
}

/* The submit row, as an AdminLTE card footer: buttons grouped on one bar under the form. */
.form-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 16px 20px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    box-shadow: 0 0 1px rgba(var(--bs-body-color-rgb), 0.125), 0 1px 3px rgba(var(--bs-body-color-rgb), 0.2);
}

/* Sign-in and the emailed approve/reject pages, outside the AdminLTE shell. */
.plain-shell {
    min-height: 100vh;
}

.plain-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.plain-brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--bs-emphasis-color);
    font-weight: 600;
    font-size: 1.05rem;
    text-decoration: none;
}

.plain-shell > .page-shell {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 24px 64px;
}

.narrow-form {
    max-width: 460px;
    margin: 0 auto;
}

/* Fluent 2 cards default to 12px padding; the forms here read better with more room. */
.page-shell .fluent-card {
    padding: 20px;
}

/* Blazor focuses the page heading after navigation; it does not need a focus ring. */
h1:focus {
    outline: none;
}

.page-title {
    margin: 0;
    font-size: var(--fontSizeBase600);
    line-height: var(--lineHeightBase600);
    font-weight: var(--fontWeightSemibold);
}

.muted {
    color: var(--colorNeutralForeground3);
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

/* FluentStack lays its children out at content width; page sections should fill the shell. */
.page-shell .fluent-stack-horizontal,
.page-shell .fluent-stack-vertical {
    width: 100%;
}

.field-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    width: 100%;
}

.field-grid-3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.badge-gap {
    margin-inline-start: 8px;
}

/* Request lists */
.list-header {
    flex-wrap: wrap;
    row-gap: 12px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px 16px;
    align-items: end;
    width: 100%;
}

.filter-grid .filter-wide {
    grid-column: span 2;
}

.filter-grid .filter-reset {
    justify-self: start;
}

.grid-scroll {
    width: 100%;
    overflow-x: auto;
}

.grid-scroll .fluent-data-grid {
    min-width: 760px;
}

a.grid-link {
    color: var(--colorBrandForeground1);
    font-weight: var(--fontWeightSemibold);
    text-decoration: none;
}

a.grid-link:hover {
    text-decoration: underline;
}

.print-only {
    display: none;
}

@media print {
    @page {
        size: A4 landscape;
        margin: 12mm;
    }

    body,
    .app-main,
    .app-wrapper,
    .bg-body-tertiary {
        background: #fff !important;
        color: #000 !important;
    }

    /* Only the content prints: the AdminLTE grid would otherwise keep a sidebar-wide gap. */
    .app-wrapper {
        display: block !important;
    }

    .app-header,
    .app-sidebar,
    .app-footer,
    .sidebar-overlay,
    .no-print,
    #blazor-error-ui,
    #components-reconnect-modal {
        display: none !important;
    }

    .page-shell {
        max-width: none;
        padding: 0;
    }

    .print-only {
        display: block;
        font: 10pt/1.4 "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    }

    .print-title {
        margin: 0 0 4px;
        font-size: 16pt;
    }

    .print-meta {
        margin: 0 0 12px;
        color: #555;
    }

    .print-table {
        width: 100%;
        border-collapse: collapse;
    }

    .print-table th,
    .print-table td {
        border: 1px solid #bbb;
        padding: 4px 6px;
        text-align: left;
        vertical-align: top;
    }

    .print-table th {
        background: #eee !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .print-table td.num {
        text-align: right;
        white-space: nowrap;
    }

    .print-table thead {
        display: table-header-group;
    }

    .print-table tr {
        break-inside: avoid;
    }
}

@media (max-width: 640px) {
    .field-grid {
        grid-template-columns: 1fr;
    }

    .filter-grid .filter-wide {
        grid-column: auto;
    }

    .plain-shell > .page-shell {
        padding: 16px 16px 48px;
    }

    .plain-header {
        padding: 10px 16px;
    }
}

/* Signature capture */
/* A signature is a line on a page, not a banner: past this width the pad (and the Upload/Clear
   buttons beside its label) stretched across the whole screen. */
.signature-host {
    width: 100%;
    max-width: 640px;
}

.signature-upload {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: var(--borderRadiusMedium);
    cursor: pointer;
    white-space: nowrap;
}

.signature-upload input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.signature-upload:hover {
    background: var(--colorNeutralBackground2);
}

.signature-upload:has(input:focus-visible) {
    outline: 2px solid var(--bs-primary, #0d6efd);
}

.signature-upload:has(input:disabled) {
    opacity: 0.5;
}

.signature-pad {
    border: 1px dashed var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusMedium);
    background: var(--colorNeutralBackground1);
    touch-action: none;
    width: 100%;
    height: 160px;
    display: block;
    cursor: crosshair;
}

.signature-pad.signed {
    border-style: solid;
    border-color: var(--colorBrandStroke1);
}

.signature-image {
    max-width: 240px;
    max-height: 90px;
    background: #fff;
    border: 1px solid var(--colorNeutralStroke1);
    border-radius: var(--borderRadiusMedium);
    padding: 4px;
}

.attachment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--colorNeutralStroke2);
}

.attachment-row:last-child {
    border-bottom: none;
}

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Dashboards ------------------------------------------------------------------------------ */

.dashboard-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.small-box .small-box-icon svg {
    width: 70px;
    height: 70px;
}

/* The footer takes the tile's own text colour: the default link blue vanishes on a blue tile. */
.small-box > .small-box-footer {
    color: inherit;
    text-decoration: none;
}

.small-box > a.small-box-footer:hover,
.small-box > a.small-box-footer:focus-visible {
    text-decoration: underline;
}

/* Chart colours. Series 1/2 (blue, orange) and the status steps are the validated dataviz
   palette; dark mode uses its own steps, checked against the dark card surface (#212529). */
:root,
[data-bs-theme=light] {
    --viz-series-1: #2a78d6;
    --viz-series-2: #eb6834;
    --viz-grid: #e9ecef;
    --viz-baseline: #ced4da;
}

[data-bs-theme=dark] {
    --viz-series-1: #3987e5;
    --viz-series-2: #d95926;
    --viz-grid: #343a40;
    --viz-baseline: #495057;
}

:root {
    --viz-status-good: #0ca30c;
    --viz-status-warning: #fab219;
    --viz-status-critical: #d03b3b;
}

.viz {
    margin: 0;
}

.viz-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 12px;
    font-size: 0.8125rem;
    color: var(--bs-secondary-color);
}

.viz-legend-item {
    display: inline-flex;
    align-items: center;
}

.viz-swatch {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-radius: 2px;
}

/* Column chart: the plot leaves 44px on the left for the tick labels. */
.viz-plot {
    position: relative;
    height: 220px;
    margin: 12px 0 0 44px;
}

.viz-grid,
.viz-columns {
    position: absolute;
    inset: 0;
}

.viz-gridline {
    position: absolute;
    left: 0;
    right: 0;
    border-top: 1px solid var(--viz-grid);
}

.viz-gridline[style^="bottom:0%"] {
    border-top-color: var(--viz-baseline);
}

.viz-tick {
    position: absolute;
    right: 100%;
    padding-right: 8px;
    transform: translateY(-50%);
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.viz-columns {
    display: flex;
    align-items: flex-end;
}

.viz-group {
    position: relative;
    display: flex;
    flex: 1;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
    height: 100%;
    border-radius: 4px;
    cursor: default;
}

.viz-group:hover,
.viz-group:focus-visible {
    background: rgba(var(--bs-body-color-rgb), 0.04);
    outline: none;
}

.viz-col {
    position: relative;
    width: min(24px, 36%);
    border-radius: 4px 4px 0 0;
}

.viz-group:hover .viz-col,
.viz-group:focus-visible .viz-col {
    filter: brightness(1.1);
}

.viz-cap {
    position: absolute;
    bottom: 100%;
    left: 50%;
    padding-bottom: 2px;
    transform: translateX(-50%);
    font-size: 0.75rem;
    color: var(--bs-body-color);
    white-space: nowrap;
}

.viz-tip {
    position: absolute;
    top: 8px;
    left: calc(50% + 16px);
    z-index: 5;
    display: none;
    min-width: 140px;
    padding: 8px 10px;
    font-size: 0.8125rem;
    white-space: nowrap;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    pointer-events: none;
}

.viz-group.tip-left .viz-tip {
    left: auto;
    right: calc(50% + 16px);
}

.viz-group:hover .viz-tip,
.viz-group:focus-visible .viz-tip {
    display: block;
}

.viz-tip-title {
    margin-bottom: 4px;
    color: var(--bs-secondary-color);
}

.viz-tip-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.viz-tip-name {
    color: var(--bs-secondary-color);
}

.viz-key {
    display: inline-block;
    width: 12px;
    height: 2px;
    border-radius: 1px;
}

.viz-xaxis {
    display: flex;
    margin-left: 44px;
    padding-top: 6px;
    font-size: 0.75rem;
    color: var(--bs-secondary-color);
}

.viz-xaxis > span {
    flex: 1;
    text-align: center;
}

.viz-table {
    margin-top: 12px;
}

.viz-table summary {
    font-size: 0.8125rem;
    color: var(--bs-link-color);
    cursor: pointer;
}

.viz-table table {
    margin-top: 8px;
    font-variant-numeric: tabular-nums;
}

/* Horizontal bar list: label, bar, value at the tip. */
.viz-barlist {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.viz-barlist li {
    display: grid;
    grid-template-columns: minmax(90px, 38%) 1fr;
    align-items: center;
    gap: 12px;
}

.viz-barlist-label {
    overflow: hidden;
    font-size: 0.875rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.viz-barlist-track {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.viz-barlist-bar {
    flex: none;
    min-width: 2px;
    height: 14px;
    background: var(--viz-series-1);
    border-radius: 0 4px 4px 0;
}

.viz-barlist-value {
    font-size: 0.8125rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Status part-to-whole: one bar, 2px surface gaps between segments. */
.viz-stack {
    display: flex;
    gap: 2px;
    height: 16px;
    overflow: hidden;
    border-radius: 4px;
}

.viz-stack-seg {
    flex-basis: 0;
    min-width: 4px;
}

.viz-stack-legend {
    display: grid;
    gap: 10px;
    margin: 18px 0 0;
    padding: 0;
    list-style: none;
}

.viz-stack-legend li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
}

.viz-stack-name {
    flex: 1;
}

/* Keep the caption/progress above the native file input visually, while allowing taps
   through to the input itself. iOS must receive a direct user gesture to open Photos. */
.attachment-picker .inputfile-content {
    pointer-events: none;
}

.attachment-picker input[type="file"] {
    cursor: pointer;
}

.approver-selection-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
}

.approver-selection-row > span {
    overflow-wrap: anywhere;
    min-width: 0;
}

.approver-selection-actions {
    display: flex;
    gap: 4px;
}
