/* ============================================================================
   forms.css - inputs, selects, floating labels.
   Load AFTER components.css.

   .form-control is rendered 490 times across these views, so restyling it is
   what makes every existing form modern. .input-modern / .select-modern /
   .search-modern / .date-modern are the new vocabulary and share the same
   rules, so a page can mix them freely.
   ============================================================================ */

/* ---------------------------------------------------------------------------
   1. FIELD BASE
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .form-control,
[data-bz-theme="dark"] .form-control,
[data-bz-theme="nextgen"] .input-modern,
[data-bz-theme="dark"] .input-modern,
[data-bz-theme="nextgen"] .select-modern,
[data-bz-theme="dark"] .select-modern,
[data-bz-theme="nextgen"] .search-modern,
[data-bz-theme="dark"] .search-modern,
[data-bz-theme="nextgen"] .date-modern,
[data-bz-theme="dark"] .date-modern {
    background-color: var(--bz-surface);
    border: 1px solid var(--bz-border-2);
    border-radius: var(--bz-r-sm);
    color: var(--bz-text);
    font-family: var(--bz-font);
    font-size: 13.5px;
    height: auto;
    min-height: 38px;
    padding: 8px 12px;
    box-shadow: none;
    transition: border-color var(--bz-t) var(--bz-ease),
                box-shadow var(--bz-t) var(--bz-ease),
                background-color var(--bz-t) var(--bz-ease);
}

[data-bz-theme="nextgen"] .form-control:focus,
[data-bz-theme="dark"] .form-control:focus,
[data-bz-theme="nextgen"] .input-modern:focus,
[data-bz-theme="dark"] .input-modern:focus,
[data-bz-theme="nextgen"] .select-modern:focus,
[data-bz-theme="dark"] .select-modern:focus,
[data-bz-theme="nextgen"] .search-modern:focus,
[data-bz-theme="dark"] .search-modern:focus,
[data-bz-theme="nextgen"] .date-modern:focus {
    border-color: var(--bz-primary);
    box-shadow: 0 0 0 3px var(--bz-ring);
    background-color: var(--bz-surface);
    /* The 3px ring IS the focus indicator here, so the global outline would
       double it. Removed only where a ring is guaranteed to be painted. */
    outline: none;
}

[data-bz-theme="nextgen"] .form-control::-webkit-input-placeholder,
[data-bz-theme="dark"] .form-control::-webkit-input-placeholder { color: #9AA8BC; }

[data-bz-theme="nextgen"] .form-control::placeholder,
[data-bz-theme="dark"] .form-control::placeholder { color: #9AA8BC; }

[data-bz-theme="nextgen"] .form-control[disabled],
[data-bz-theme="dark"] .form-control[disabled],
[data-bz-theme="nextgen"] .form-control[readonly],
[data-bz-theme="dark"] .form-control[readonly] {
    background-color: var(--bz-surface-2);
    color: var(--bz-muted);
    cursor: not-allowed;
}

/* Chrome paints autofilled fields a fixed pale yellow that ignores background
   -color. The huge inset shadow is the long-standing way to repaint it; on
   dark it is the difference between a readable field and a white slab. */
[data-bz-theme="dark"] .form-control:-webkit-autofill,
[data-bz-theme="dark"] .form-control:-webkit-autofill:hover,
[data-bz-theme="dark"] .form-control:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 1000px var(--bz-surface) inset;
    -webkit-text-fill-color: var(--bz-text);
}

/* ---------------------------------------------------------------------------
   2. SELECT
   A native select keeps its own arrow; the option LIST is drawn by the OS and
   cannot be styled, which is exactly why design-system.css sets
   color-scheme: dark - that is what makes the dropdown itself dark.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] select.form-control,
[data-bz-theme="dark"] select.form-control,
[data-bz-theme="nextgen"] .select-modern,
[data-bz-theme="dark"] .select-modern { padding-right: 30px; }

[data-bz-theme="dark"] select.form-control option,
[data-bz-theme="dark"] .select-modern option {
    background-color: var(--bz-surface);
    color: var(--bz-text);
}

/* ---------------------------------------------------------------------------
   3. LABELS
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] label,
[data-bz-theme="dark"] label {
    font-family: var(--bz-font);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--bz-text);
    margin-bottom: 6px;
}

[data-bz-theme="nextgen"] .form-group,
[data-bz-theme="dark"] .form-group { margin-bottom: var(--bz-s-4); }

[data-bz-theme="nextgen"] .help-block,
[data-bz-theme="dark"] .help-block { color: var(--bz-muted); font-size: 12px; }

/* Bootstrap validation states, restated so they read on both grounds. */
[data-bz-theme="nextgen"] .has-error .form-control,
[data-bz-theme="dark"] .has-error .form-control {
    border-color: var(--bz-danger);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, .18);
}

[data-bz-theme="nextgen"] .has-error .control-label,
[data-bz-theme="dark"] .has-error .control-label,
[data-bz-theme="nextgen"] .field-validation-error,
[data-bz-theme="dark"] .field-validation-error { color: var(--bz-danger-ink); }

[data-bz-theme="nextgen"] .has-success .form-control,
[data-bz-theme="dark"] .has-success .form-control { border-color: var(--bz-success); }

/* ---------------------------------------------------------------------------
   4. FLOATING LABELS - opt-in.

   Markup:
       <div class="bz-float">
           <input class="form-control" placeholder=" " id="x">
           <label for="x">Customer</label>
       </div>

   The placeholder MUST be a single space. :placeholder-shown is what detects
   emptiness (Chrome 47+), and a field with no placeholder attribute never
   matches it, so the label would stay floated over empty input.
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .bz-float,
[data-bz-theme="dark"] .bz-float {
    position: relative;
    margin-bottom: var(--bz-s-4);
}

[data-bz-theme="nextgen"] .bz-float > .form-control,
[data-bz-theme="dark"] .bz-float > .form-control,
[data-bz-theme="nextgen"] .bz-float > .input-modern,
[data-bz-theme="dark"] .bz-float > .input-modern {
    padding-top: 20px;
    padding-bottom: 6px;
    min-height: 52px;
}

[data-bz-theme="nextgen"] .bz-float > label,
[data-bz-theme="dark"] .bz-float > label {
    position: absolute;
    left: 13px;
    top: 15px;
    margin: 0;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--bz-muted);
    pointer-events: none;
    transform-origin: 0 0;
    transition: transform var(--bz-t) var(--bz-ease), color var(--bz-t) var(--bz-ease);
}

[data-bz-theme="nextgen"] .bz-float > .form-control:focus + label,
[data-bz-theme="dark"] .bz-float > .form-control:focus + label,
[data-bz-theme="nextgen"] .bz-float > .form-control:not(:placeholder-shown) + label,
[data-bz-theme="dark"] .bz-float > .form-control:not(:placeholder-shown) + label {
    transform: translateY(-9px) scale(.80);
    color: var(--bz-primary);
}

/* ---------------------------------------------------------------------------
   5. SECTION CARDS + RESPONSIVE GRID for form grouping
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .form-section,
[data-bz-theme="dark"] .form-section {
    background: var(--bz-surface);
    border: 1px solid var(--bz-border);
    border-radius: var(--bz-r);
    padding: var(--bz-s-5);
    margin-bottom: var(--bz-s-5);
}

[data-bz-theme="nextgen"] .form-section > .form-section-h,
[data-bz-theme="dark"] .form-section > .form-section-h {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--bz-primary);
    padding-bottom: var(--bz-s-3);
    margin-bottom: var(--bz-s-4);
    border-bottom: 1px solid var(--bz-border);
}

/* grid-gap on GRID is Chrome 57+, inside the floor. */
[data-bz-theme="nextgen"] .form-grid,
[data-bz-theme="dark"] .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    grid-gap: var(--bz-s-4);
}

@media (max-width: 767px) {
    [data-bz-theme="nextgen"] .form-grid,
    [data-bz-theme="dark"] .form-grid { grid-template-columns: 1fr; }
}

/* ---------------------------------------------------------------------------
   6. INPUT GROUPS / CHECKBOXES
--------------------------------------------------------------------------- */
[data-bz-theme="nextgen"] .input-group-addon,
[data-bz-theme="dark"] .input-group-addon {
    background-color: var(--bz-surface-2);
    border: 1px solid var(--bz-border-2);
    color: var(--bz-muted);
    border-radius: var(--bz-r-sm);
}

[data-bz-theme="nextgen"] input[type="checkbox"],
[data-bz-theme="dark"] input[type="checkbox"],
[data-bz-theme="nextgen"] input[type="radio"],
[data-bz-theme="dark"] input[type="radio"] { accent-color: var(--bz-primary); }

/* ---------------------------------------------------------------------------
   7. THIRD-PARTY WIDGETS ON DARK

   jQuery UI datepicker and Select2 render into their own detached containers
   appended to <body>, so they inherit the theme attribute from <html> but
   none of the page's own styling. Left alone they stay bright white on a dark
   page - the most visible dark-mode break in a data-entry application.
--------------------------------------------------------------------------- */
[data-bz-theme="dark"] .ui-datepicker,
[data-bz-theme="dark"] .select2-dropdown,
[data-bz-theme="dark"] .select2-container--default .select2-selection--single,
[data-bz-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: var(--bz-surface);
    border-color: var(--bz-border-2);
    color: var(--bz-text);
}

[data-bz-theme="dark"] .ui-datepicker .ui-datepicker-header {
    background: var(--bz-surface-2);
    border-color: var(--bz-border);
    color: var(--bz-text);
}

[data-bz-theme="dark"] .ui-datepicker td a,
[data-bz-theme="dark"] .ui-datepicker td span { color: var(--bz-text); }

[data-bz-theme="dark"] .ui-datepicker td a:hover { background: var(--bz-primary-700); color: #fff; }

[data-bz-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: var(--bz-surface-2);
}

[data-bz-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--bz-primary-700);
    color: #fff;
}

[data-bz-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--bz-text);
}

/* ===========================================================================
   GEOMETRY BELONGS TO STANDARD   [2026-09-12]
   ---------------------------------------------------------------------------
   Same fault as the one recorded in components.css, in the other direction:
   the rule above gives `.form-control` `min-height: 38px; padding: 8px 12px;
   font-size: 13.5px`, against Bootstrap 3's `height: 34px; padding: 6px 12px;
   font-size: 14px`.

   Four extra pixels of height on every field is invisible on a form laid out
   vertically and very visible in a DevExpress grid filter row, where the
   inputs sit inline with the column headers - the row grew and stopped lining
   up with Standard, which is what the side-by-side showed.

   Metrics restored for the bare Bootstrap control; colour and border still
   theme. `-modern` variants keep the full treatment, as above.
   =========================================================================== */
[data-bz-theme="nextgen"] .form-control:not([class*="-modern"]),
[data-bz-theme="dark"] .form-control:not([class*="-modern"]) {
    min-height: 0;
    height: 34px;
    padding: 6px 12px;
    font-size: 14px;
}

/* textarea and select keep auto height - a fixed 34px would clip a multi-line
   textarea and squash a sized <select>. */
[data-bz-theme="nextgen"] textarea.form-control:not([class*="-modern"]),
[data-bz-theme="dark"] textarea.form-control:not([class*="-modern"]),
[data-bz-theme="nextgen"] select[multiple].form-control,
[data-bz-theme="dark"] select[multiple].form-control,
[data-bz-theme="nextgen"] select[size].form-control,
[data-bz-theme="dark"] select[size].form-control {
    height: auto;
}

/* ===========================================================================
   BARE <input>, <textarea> AND <select> EDGES   [2026-09-12]
   ---------------------------------------------------------------------------
   custom/main.css - linked by ERP.Master, PopUp.Master, Vendor.Master and
   ForgotPassword.aspx - declares

       .form-control, input { border: 1px solid #aaa; }

   `.form-control` is themed at the top of this file, so half that rule was
   already handled. The BARE `input` half was not, and nothing else covers it:
   the generator withholds bare element selectors on purpose (a global
   `input { ... !important }` is exactly the kind of rule that cannot be undone
   by any page that needs to differ), and theme-dark-polish.css only names the
   typed forms - input[type="text"], input[type="password"].

   So this is written by hand, deliberately WITHOUT !important and as
   border-colour only. At (0,1,1) it outranks main.css's (0,0,1) without
   outranking anything a component declares for itself, and a colour on an
   element with no border paints nothing - so it can only ever replace an edge
   that is already there.
   =========================================================================== */
[data-bz-theme="dark"] input,
[data-bz-theme="dark"] textarea,
[data-bz-theme="dark"] select {
    border-color: var(--bz-border);
}

[data-bz-theme="dark"] input:focus,
[data-bz-theme="dark"] textarea:focus,
[data-bz-theme="dark"] select:focus {
    border-color: var(--bz-primary);
}
