/* MBX's own styles. Everything here reads its colours from styles/theme.css,
   so it follows the light and dark themes automatically.
   Blazor Blueprint components bring their own styles; this file covers the
   page frame, page headings, and the sign-in pages (which are plain HTML forms). */

*,
::before,
::after {
    border-color: var(--border);
}

/* A slightly smaller base size makes every screen more compact. */
html {
    font-size: 15px;
}

html,
body {
    background: var(--background);
    color: var(--foreground);
    font-family: var(--font-sans, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
    -webkit-font-smoothing: antialiased;
}

h1:focus {
    outline: none;
}

/* ---- page frame (inside the signed-in layout) ---- */

.mbx-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 2.75rem;
    flex-shrink: 0;
    padding: 0 0.75rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.mbx-header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Pages use the full width of the window, with tight margins. */
.mbx-main {
    flex: 1;
    min-width: 0;
    padding: 0.875rem 1rem 1.25rem;
}

.mbx-page-head {
    margin-bottom: 0.75rem;
}

.mbx-title {
    font-size: 1.25rem;
    line-height: 1.625rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.mbx-subtitle {
    margin-top: 0.125rem;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.mbx-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
}

.mbx-text {
    font-size: 0.875rem;
    line-height: 1.5rem;
}

.mbx-muted {
    color: var(--muted-foreground);
}

.mbx-link {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.mbx-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    margin: 0 0.375rem 0.375rem 0;
    border-radius: 9999px;
    border: 1px solid var(--border);
    background: var(--secondary);
    color: var(--secondary-foreground);
    font-size: 0.75rem;
    font-weight: 500;
}

.mbx-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.5rem;
    padding: 3rem 1.5rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted-foreground);
}

.mbx-empty strong {
    color: var(--foreground);
    font-size: 1rem;
    font-weight: 600;
}

/* ---- forms and lists on signed-in pages ---- */

.mbx-page-head-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

/* Fields flow into as many columns as the window has room for. */
.mbx-form {
    display: grid;
    gap: 0.625rem 0.875rem;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
    align-items: start;
}

.mbx-form .mbx-actions,
.mbx-form .mbx-span {
    grid-column: 1 / -1;
}

.mbx-form .mbx-field {
    display: grid;
    gap: 0.375rem;
    margin-bottom: 0;
}

.mbx-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.mbx-section {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.mbx-section-title {
    font-size: 1rem;
    font-weight: 600;
}

.mbx-section-text {
    margin: 0.125rem 0 0.625rem;
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.mbx-readonly {
    font-size: 0.875rem;
    padding: 0.5rem 0;
}

.mbx-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.625rem;
    margin-bottom: 0.625rem;
}

.mbx-filters .mbx-field {
    display: grid;
    gap: 0.375rem;
    margin-bottom: 0;
}

.mbx-filter-grow {
    flex: 1 1 16rem;
    max-width: 26rem;
}

.mbx-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.mbx-note {
    margin-top: 0.75rem;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* ---- detail screens: titled panels that fill the width ---- */

/* Panels pack into as many columns as fit, each column filling from the top,
   so a short panel sits directly under the one above with no gap. */
.mbx-panels {
    /* Up to four columns, never narrower than 19rem, stretched to fill the page.
       Four, not five: the screen has six panels and they pack into four columns,
       so a fifth would sit empty on a wide monitor. */
    columns: 4 19rem;
    column-gap: 0.625rem;
}

.mbx-panel {
    break-inside: avoid;
    margin-bottom: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--card-foreground);
}

.mbx-panel textarea {
    min-height: 9rem;
}

.mbx-panel-title {
    padding: 0.375rem 0.625rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.mbx-panel-body {
    display: grid;
    gap: 0.5rem 0.625rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 0.625rem;
}

.mbx-panel-body .mbx-field {
    display: grid;
    gap: 0.25rem;
    margin-bottom: 0;
    min-width: 0;
}

.mbx-panel-body .mbx-span {
    grid-column: 1 / -1;
}

.mbx-checks {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.mbx-checkline {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.mbx-head-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.mbx-meta {
    margin-top: 0.625rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.mbx-banner {
    margin: 0 0 0.625rem;
}

/* ---- compact tables and one-line forms inside panels ---- */

.mbx-panel-full {
    margin-top: 0;
}

.mbx-panel-full .mbx-table + .mbx-table,
.mbx-panel-full .mbx-inline-form + .mbx-table {
    margin-top: 0.25rem;
}

.mbx-panel-pad {
    padding: 0.625rem;
}

.mbx-inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.625rem;
}

.mbx-grow {
    flex: 1 1 18rem;
    min-width: 0;
}

/* A drop-down that keeps a sensible width inside a one-line form. */
.mbx-fixed {
    flex: 0 0 12rem;
    width: 12rem;
}

.mbx-table .mbx-col-main {
    width: 100%;
}

.mbx-table .mbx-col-half {
    width: 50%;
}

.mbx-subhead {
    margin: 0.875rem 0 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
}

.mbx-subhead:first-child {
    margin-top: 0;
}

.mbx-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.mbx-table th {
    padding: 0.3125rem 0.5rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
    white-space: nowrap;
}

.mbx-table td {
    padding: 0.3125rem 0.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.mbx-table tr:last-child td {
    border-bottom: 0;
}

.mbx-table .mbx-nowrap {
    white-space: nowrap;
}

.mbx-table .mbx-row-actions {
    white-space: nowrap;
    text-align: right;
}

.mbx-table .mbx-row-actions > * {
    margin-left: 0.25rem;
}

/* ---- detail screens: heading that stays put, type strip, warnings ---- */

/* The name and the Save button stay at the top while the page scrolls. */
.mbx-sticky {
    position: sticky;
    top: 0;
    z-index: 5;
    margin: -0.875rem -1rem 0.625rem;
    padding: 0.625rem 1rem 0.5rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.mbx-sticky.mbx-page-head {
    margin-bottom: 0.625rem;
}

.mbx-unsaved {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--destructive);
    white-space: nowrap;
}

/* One slim row of tick boxes under the heading. */
.mbx-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.375rem 1.125rem;
    margin-bottom: 0.625rem;
    padding: 0.4375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
}

.mbx-strip-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted-foreground);
}

.mbx-strip-gap {
    width: 1px;
    align-self: stretch;
    background: var(--border);
}

.mbx-alert-warning {
    border-color: var(--ring);
}

.mbx-alert .mbx-alert-title {
    font-weight: 600;
}

.mbx-push-right {
    margin-left: auto;
}

/* ---- tabs under a detail screen ---- */

.mbx-tabs {
    margin-top: 0.25rem;
}

/* Inside a tab the tab itself is the title, so the panel's own title is hidden. */
.mbx-tabs .mbx-panel-full > .mbx-panel-title {
    display: none;
}

.mbx-tabs .mbx-panel-full {
    margin-top: 0.375rem;
    margin-bottom: 0;
}

.mbx-empty-tight {
    margin-top: 0.375rem;
    padding: 1.25rem 1rem;
}

/* ---- side menu extras ---- */

.mbx-brand-mark {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: calc(var(--radius) - 2px);
    background: var(--sidebar-primary);
    color: var(--sidebar-primary-foreground);
}

.mbx-brand-text {
    display: grid;
    line-height: 1.15;
    text-align: left;
}

.mbx-brand-text strong {
    font-size: 0.9rem;
    font-weight: 600;
}

.mbx-brand-text small {
    font-size: 0.72rem;
    color: var(--muted-foreground);
}

.mbx-user {
    padding: 0.5rem 0.5rem 0.25rem;
    border-top: 1px solid var(--sidebar-border);
    overflow: hidden;
}

.mbx-user-name {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mbx-user-role {
    font-size: 0.72rem;
    color: var(--muted-foreground);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mbx-signout {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem;
    border-radius: calc(var(--radius) - 2px);
    font-size: 0.875rem;
    text-align: left;
    color: var(--sidebar-foreground);
    background: transparent;
    cursor: pointer;
}

.mbx-signout:hover {
    background: var(--sidebar-accent);
    color: var(--sidebar-accent-foreground);
}

/* ---- sign-in pages (plain HTML forms, no interactivity) ---- */

.mbx-account {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--muted);
}

.mbx-account-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
}

.mbx-account-brand span {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.mbx-account-card {
    width: 100%;
    max-width: 26rem;
    padding: 1.75rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    background: var(--card);
    color: var(--card-foreground);
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 8px 24px rgb(0 0 0 / 0.06);
}

.mbx-account-card h1 {
    font-size: 1.25rem;
    line-height: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.mbx-account-card p {
    margin-top: 0.375rem;
    font-size: 0.875rem;
    line-height: 1.375rem;
    color: var(--muted-foreground);
}

.mbx-account-card form {
    margin-top: 1.25rem;
}

.mbx-field {
    margin-bottom: 1rem;
}

.mbx-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.mbx-input {
    display: block;
    width: 100%;
    height: 2.5rem;
    padding: 0 0.75rem;
    border: 1px solid var(--input);
    border-radius: calc(var(--radius) - 2px);
    background: transparent;
    color: inherit;
    font-size: 0.875rem;
}

.mbx-input:focus {
    outline: 2px solid var(--ring);
    outline-offset: 1px;
}

.mbx-hint {
    margin-top: 0.375rem;
    font-size: 0.75rem;
    line-height: 1.125rem;
    color: var(--muted-foreground);
}

.mbx-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.mbx-check input {
    width: 1rem;
    height: 1rem;
    accent-color: var(--primary);
}

.mbx-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 2.5rem;
    padding: 0 1rem;
    border-radius: calc(var(--radius) - 2px);
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
}

.mbx-button:hover {
    opacity: 0.9;
}

.mbx-alert {
    margin-top: 1rem;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) - 2px);
    background: var(--muted);
    font-size: 0.875rem;
    line-height: 1.375rem;
}

.mbx-alert ul {
    margin: 0;
    padding-left: 1.1rem;
    list-style: disc;
}

.mbx-alert-error {
    border-color: var(--destructive);
    color: var(--destructive);
    background: transparent;
}

.mbx-alert-success {
    border-color: var(--primary);
}

.mbx-account-foot {
    margin-top: 1rem;
    font-size: 0.8125rem;
    text-align: center;
}

/* Field-level validation messages written by Blazor's form validation. */
.validation-message {
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--destructive);
}

.mbx-input.invalid {
    border-color: var(--destructive);
}

/* ---- framework bits ---- */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    padding: 0.75rem 1.25rem;
    background: var(--destructive);
    color: var(--destructive-foreground);
    font-size: 0.875rem;
}

#blazor-error-ui .dismiss {
    position: absolute;
    right: 1rem;
    top: 0.6rem;
    cursor: pointer;
}

.blazor-error-boundary {
    padding: 1rem;
    border-radius: var(--radius);
    background: var(--destructive);
    color: var(--destructive-foreground);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ---- list screens: the extra filters behind "More filters" ---- */

.mbx-more-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
    gap: 0.5rem 0.625rem;
    align-items: end;
    padding: 0.625rem;
    margin-bottom: 0.625rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
}

.mbx-more-filters .mbx-field {
    display: grid;
    gap: 0.25rem;
    margin-bottom: 0;
}

.mbx-more-filters-action {
    justify-items: start;
}

/* ---- read-only screens: label and value pairs inside a panel ---- */

.mbx-facts {
    display: grid;
    grid-template-columns: 7.25rem minmax(0, 1fr);
    gap: 0.25rem 0.625rem;
    margin: 0;
    padding: 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
}

.mbx-facts dt {
    color: var(--muted-foreground);
}

.mbx-facts dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.mbx-panel-text {
    padding: 0.625rem;
    font-size: 0.8125rem;
    line-height: 1.25rem;
    white-space: pre-wrap;
}

/* The one-line summary under a read-only page's heading. */
.mbx-summary {
    font-size: 0.8125rem;
}

.mbx-summary .mbx-strip-label {
    margin-right: 0.25rem;
}

/* ---- panels in fixed rows, for screens that follow a set arrangement ---- */

.mbx-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.625rem;
    margin-bottom: 0.625rem;
}

.mbx-row > .mbx-panel {
    margin-bottom: 0;
}

.mbx-row-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mbx-row-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Narrower windows: two across, then one. */
@media (max-width: 80rem) {
    .mbx-row-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 48rem) {
    .mbx-row-4,
    .mbx-row-3 {
        grid-template-columns: minmax(0, 1fr);
    }
}

.mbx-span-2 {
    grid-column: span 2;
}

@media (max-width: 48rem) {
    .mbx-span-2 {
        grid-column: auto;
    }
}

/* Extra labels and links inside one value: "Garland  State: TX  Zip: 75041". */
.mbx-fact-sub {
    margin-left: 0.75rem;
    margin-right: 0.25rem;
    color: var(--muted-foreground);
}

.mbx-fact-link {
    margin-left: 0.5rem;
    font-size: 0.75rem;
}

/* HDX colours these two labels. */
.mbx-facts dt.mbx-fact-est {
    color: #4f8ff7;
    font-weight: 600;
}

.mbx-facts dt.mbx-fact-actual {
    color: var(--destructive);
    font-weight: 600;
}

/* A wider label column, for the long labels on the Totals tab. */
.mbx-facts-wide {
    grid-template-columns: 12.5rem minmax(0, 1fr);
}

/* Number columns in a table line up on the right. */
.mbx-table th.mbx-num,
.mbx-table td.mbx-num {
    text-align: right;
    white-space: nowrap;
}

/* A status on the Shipments list, filled with HDX's colour for that status.
   The fills are light, so the text is always dark, in both themes. */
.mbx-status-cell {
    display: block;
    margin: -0.125rem 0;
    padding: 0.1875rem 0.5rem;
    border-radius: 0.25rem;
    color: #1c1c1a;
    font-weight: 500;
    white-space: nowrap;
}

/* ---- dashboard ---- */

.mbx-tiles {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 0.625rem;
    margin-bottom: 0.625rem;
}

.mbx-tile {
    margin-bottom: 0;
}

.mbx-tile-number {
    display: block;
    padding: 0.5rem 0.625rem 0.75rem;
    text-align: center;
    font-size: 2.25rem;
    line-height: 2.5rem;
    font-weight: 600;
    color: #4f8ff7;
    text-decoration: none;
}

.mbx-tile-number:hover {
    text-decoration: underline;
}

.mbx-tile-number.mbx-tile-alert {
    color: var(--destructive);
}

.mbx-row-6 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    align-items: start;
}

@media (max-width: 100rem) {
    .mbx-tiles {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .mbx-row-6 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 48rem) {
    .mbx-tiles,
    .mbx-row-6 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ---- a panel of label and field pairs (the editable shipment screen) ---- */

.mbx-form-facts {
    grid-template-columns: 6.5rem minmax(0, 1fr);
    align-items: center;
    gap: 0.3125rem 0.5rem;
}

/* Several things can share one row: two time boxes, a box and a button. */
.mbx-form-facts dd > span {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    min-width: 0;
}

.mbx-form-facts dd > span > input,
.mbx-form-facts dd > span > select,
.mbx-form-facts dd > span > div {
    flex: 1 1 4rem;
    min-width: 0;
}

.mbx-form-facts .mbx-fact-sub,
.mbx-form-facts .mbx-fact-link {
    flex: 0 0 auto;
    margin-left: 0.25rem;
}

.mbx-form-facts .mbx-fixed {
    flex: 0 0 auto;
}

/* ---- a window that opens over the page ---- */

.mbx-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 1rem;
    background: rgb(0 0 0 / 0.55);
}

.mbx-modal {
    width: min(64rem, 100%);
    max-height: calc(100vh - 6rem);
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    padding: 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--card-foreground);
}

.mbx-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.mbx-modal-scroll {
    overflow: auto;
    min-height: 0;
}
