/* ============================================================================
   TREND — legacy skin.

   Reproduces the look of the old WebForms app (Default.master + style.css) by
   overriding Bootstrap's CSS variables rather than fighting its rules. Values
   were transcribed by hand from the legacy design; see LEGACY-UI-REFERENCE.md.
   ========================================================================= */

:root {
    --trend-bg: #f3f3f3;
    --trend-text: #212020;
    --trend-heading: #151515;
    --trend-accent: #8dad18; /* olive green links */
    --trend-button: #ffa20f; /* orange buttons */
    --trend-button-border: #d7b9c9;
    --trend-blue: #4392ca; /* report/heading accent */
    --trend-rule: #c7c7c7; /* header divider, footer top border */
    --trend-muted: #9f9f9f;
    --trend-grid-header: #e6e6e6;
    --trend-width: 980px;

    /* Bootstrap overrides — everything downstream inherits these. */
    --bs-body-font-family: Arial, Helvetica, sans-serif;
    --bs-body-font-size: 1rem;
    --bs-body-line-height: 1.4;
    --bs-body-color: var(--trend-text);
    --bs-body-bg: var(--trend-bg);
    --bs-link-color: var(--trend-accent);
    --bs-link-hover-color: var(--trend-accent);
    --bs-border-color: var(--trend-rule);
    --bs-border-radius: 0;
    --bs-border-radius-sm: 0;
    --bs-border-radius-lg: 0;
}

/* The legacy app was a flat 12px Arial page. Scaling the root down keeps
   Bootstrap's rem-based spacing in proportion instead of leaving 16px gaps
   around 12px text. */
html {
    font-size: 12px;
    position: relative;
    min-height: 100%;
}

body {
    background: var(--trend-bg);
    color: var(--trend-text);
    font-family: Arial, Helvetica, sans-serif;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--trend-heading);
    font-weight: bold;
}

h1, .h1 { font-size: 2rem; }   /* ~24px, matches legacy .body h2 */
h2, .h2 { font-size: 1.75rem; }
h3, .h3 { font-size: 1.4rem; }
h4, .h4 { font-size: 1.2rem; }

small, .small, .text-muted {
    font-size: 0.917rem; /* ~11px */
}

.text-muted {
    color: var(--trend-muted) !important;
}

a {
    color: var(--trend-accent);
    text-decoration: underline;
}

a:hover {
    color: var(--trend-accent);
    text-decoration: underline;
}

/* ---------------------------------------------------------------- layout -- */

/* Fixed-width centred column, echoing the legacy .body_resize. */
.trend-wrap {
    width: var(--trend-width);
    margin: 0 auto;
    padding: 0 10px;
}

.trend-header {
    background: var(--trend-bg);
    border-bottom: 1px solid var(--trend-rule);
    margin-bottom: 15px;
}

.trend-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 34px;
    padding-top: 6px;
}

.trend-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--trend-heading);
    text-decoration: none;
    letter-spacing: 1px;
}

.trend-brand:hover {
    color: var(--trend-heading);
    text-decoration: none;
}

/* Horizontal text menu — the most recognisable legacy element. Fixed-width
   centred items, bold on hover/current, no colour change. */
/* Seven 126px items = 882px, inside the 960px content width. */
.trend-menu {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

.trend-menu li {
    margin: 0;
    padding: 0;
}

.trend-menu a {
    display: block;
    width: 126px;
    text-align: center;
    padding: 8px 0;
    color: var(--trend-heading);
    font-size: 1rem;
    text-decoration: none;
}

.trend-menu a:hover,
.trend-menu a.active {
    color: var(--trend-heading);
    font-weight: bold;
    text-decoration: none;
    background: #e9e9e9;
}

/* Right-floated login/logout status, as the legacy LoginStatus control was. */
.trend-loginstatus {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    color: var(--trend-heading);
}

.trend-footer {
    border-top: 1px solid var(--trend-rule);
    margin-top: 30px;
    padding: 10px 0 20px;
    color: var(--trend-muted);
    font-size: 0.917rem;
}

/* --------------------------------------------------------------- buttons -- */

/* The orange outset button is a distinctive legacy cue — applied to every
   Bootstrap button variant so no page needs changing. */
.btn,
.btn-primary,
.btn-success,
.btn-outline-primary {
    --bs-btn-color: #000;
    --bs-btn-bg: var(--trend-button);
    --bs-btn-border-color: var(--trend-button-border);
    --bs-btn-hover-color: #000;
    --bs-btn-hover-bg: #ffb23a;
    --bs-btn-hover-border-color: var(--trend-button-border);
    --bs-btn-active-color: #000;
    --bs-btn-active-bg: #e8930d;
    --bs-btn-active-border-color: var(--trend-button-border);
    --bs-btn-disabled-color: #666;
    --bs-btn-disabled-bg: #e0d3c0;
    --bs-btn-disabled-border-color: var(--trend-button-border);
    border-style: outset;
    border-width: 2px;
    border-radius: 0;
    font-size: 1rem;
    text-decoration: none;
}

.btn:active,
.btn.active {
    border-style: inset;
}

/* Secondary actions (Clear, Cancel) keep the outset shape but drop the orange,
   so the primary action on a page still stands out. */
.btn-secondary,
.btn-outline-secondary,
.btn-light,
.btn-outline-light {
    --bs-btn-color: #000;
    --bs-btn-bg: #dcdcdc;
    --bs-btn-border-color: #cfcfcf;
    --bs-btn-hover-color: #000;
    --bs-btn-hover-bg: #e8e8e8;
    --bs-btn-hover-border-color: #cfcfcf;
    --bs-btn-active-color: #000;
    --bs-btn-active-bg: #cccccc;
    --bs-btn-active-border-color: #cfcfcf;
}

.btn-danger,
.btn-outline-danger {
    --bs-btn-color: #fff;
    --bs-btn-bg: #a52a2a;
    --bs-btn-border-color: #8a2222;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #bb3232;
    --bs-btn-hover-border-color: #8a2222;
}

.btn:focus, .btn:active:focus,
.btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: 0 0 0 2px rgba(141, 173, 24, 0.5);
    border-color: var(--trend-accent);
}

/* ----------------------------------------------------------------- forms -- */

.form-control,
.form-select {
    border: 1px solid #b5b5b5;
    border-radius: 0;
    background: #fff;
    font-size: 1rem;
    padding: 2px 4px;
}

.form-label {
    margin-bottom: 2px;
    color: var(--trend-heading);
    font-weight: bold;
    font-size: 1rem;
}

/* Panels: the legacy app grouped fields in plain boxes with a shaded caption
   bar, not rounded cards. */
.card {
    border: 1px solid var(--trend-rule);
    border-radius: 0;
    background: #fff;
}

.card-header {
    background: var(--trend-grid-header);
    border-bottom: 1px solid var(--trend-rule);
    border-radius: 0;
    color: var(--trend-heading);
    font-weight: bold;
    padding: 5px 8px;
}

/* ----------------------------------------------------------------- grids -- */

/* Stands in for the old DevExpress "Glass" grid: shaded header row, gridlines
   on every cell, subtle row banding. */
.table {
    /* Bootstrap 5.3 resolves cell colour as
       --bs-table-color-state ?? --bs-table-color-type ?? --bs-table-color, and
       .table-striped/.table-hover set the -type layer — so overriding the base
       alone leaves cells pure black. All three variants need the body colour. */
    --bs-table-color: var(--trend-text);
    --bs-table-striped-color: var(--trend-text);
    --bs-table-hover-color: var(--trend-text);
    --bs-table-active-color: var(--trend-text);
    --bs-table-bg: #fff;
    --bs-table-striped-bg: #f7f7f7;
    --bs-table-hover-bg: #eef3dc; /* pale tint of the olive accent */
    --bs-table-border-color: var(--trend-rule);
    border: 1px solid var(--trend-rule);
    font-size: 1rem;
    margin-bottom: 10px;
}

.table > thead > tr > th {
    background: var(--trend-grid-header);
    color: var(--trend-heading);
    font-weight: bold;
    border-bottom: 1px solid var(--trend-rule);
    white-space: nowrap;
    padding: 5px 6px;
}

.table > tbody > tr > td {
    padding: 3px 6px;
    vertical-align: middle;
}

.table > :not(caption) > * > * {
    border-width: 1px;
}

/* Legacy grids had no dark header; neutralise Bootstrap's if a page uses it. */
.table .table-dark,
.table > thead.table-dark > tr > th {
    --bs-table-bg: var(--trend-grid-header);
    --bs-table-color: var(--trend-heading);
    background: var(--trend-grid-header);
    color: var(--trend-heading);
}

/* Pager: plain text links rather than Bootstrap's pill buttons. */
.pagination {
    --bs-pagination-color: var(--trend-accent);
    --bs-pagination-bg: transparent;
    --bs-pagination-border-color: var(--trend-rule);
    --bs-pagination-hover-color: var(--trend-accent);
    --bs-pagination-hover-bg: #e9e9e9;
    --bs-pagination-active-bg: var(--trend-accent);
    --bs-pagination-active-border-color: var(--trend-accent);
    --bs-pagination-border-radius: 0;
    font-size: 1rem;
}

/* Note: the legacy right-aligned label-left field layout was tried and reverted.
   It needs a single wide column; inside these two-column cards an 85px caption
   collapses col-3 inputs to ~25px, wraps captions mid-word, and clips the date
   fields. Reinstating it means making the form one column first. */

/* ------------------------------------------------------------------ tabs -- */

/* Bootstrap's active tab uses the body background, which is now the same grey as
   the page — so the selected tab vanished. Shade the inactive tabs and give the
   active one a white, raised face instead. */
.nav-tabs {
    --bs-nav-tabs-border-color: var(--trend-rule);
    --bs-nav-tabs-border-radius: 0;
    --bs-nav-link-color: var(--trend-heading);
    --bs-nav-link-hover-color: var(--trend-heading);
    --bs-nav-tabs-link-active-color: var(--trend-heading);
    --bs-nav-tabs-link-active-bg: #fff;
    --bs-nav-tabs-link-active-border-color: var(--trend-rule) var(--trend-rule) #fff;
}

.nav-tabs .nav-link {
    background: var(--trend-grid-header);
    border: 1px solid var(--trend-rule);
    margin-right: 2px;
    padding: 4px 12px;
    text-decoration: none;
}

.nav-tabs .nav-link.active {
    font-weight: bold;
}

/* ---------------------------------------------------------------- alerts -- */

.alert {
    border-radius: 0;
    border: 1px solid var(--trend-rule);
    padding: 6px 10px;
}

.alert-info {
    --bs-alert-bg: #eef3dc;
    --bs-alert-border-color: var(--trend-accent);
    --bs-alert-color: var(--trend-text);
}

.badge {
    border-radius: 0;
}

.alert-danger {
    --bs-alert-bg: #fbe3e3;
    --bs-alert-border-color: #a94442;
    --bs-alert-color: #a94442;
}

/* ------------------------------------------------------------ validation -- */

/* The summary tag helper always emits its container, so without this an empty red
   box would sit above the form on every page load. */
.validation-summary-valid {
    display: none;
}

.validation-summary-errors ul {
    margin: 0;
    padding-left: 18px;
}

/* Bootstrap styles its own .is-invalid, but the unobtrusive validation scripts
   apply these class names instead — so nothing marked the offending field and a
   rejected Save looked like a Save that did nothing at all. */
.input-validation-error {
    border-color: #a94442;
    background: #fff5f5;
}

.field-validation-error {
    color: #a94442;
    display: block;
}
