/**
 * Bootstrap 3 float-grid compatibility (UpgradeBs3ToBs5_plan.md Phase 4/5).
 *
 * BS3 columns were floats, so legacy markup freely nests col-* inside plain
 * divs (no .row). BS5 columns only get placed by their flex .row parent, so
 * those orphaned columns stack vertically. Restore the BS3 behavior for
 * columns NOT inside a .row: float them left (BS5 still sets their width).
 * Columns inside a real .row are untouched. :where() keeps specificity at
 * zero so page CSS always wins.
 *
 * An element that is ITSELF a .row (legacy "col-md-12 row" combos) is never
 * floated: BS5 rows are flex containers, and a floated one makes the next
 * sibling squeeze into the float's leftover width instead of clearing it.
 *
 * Parent height collapse matches BS3 too (legacy pages carry their own
 * .clearfix divs). DELETE once every page nests columns in .row properly.
 */
:where(:not(.row)) > :is(.col, .col-auto, .col-1, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-10, .col-11, .col-12):not(.row) {
    float: left;
}

/*
 * BS3 only floated a column AT ITS BREAKPOINT AND UP — below it the div was a
 * plain full-width block. Floating unconditionally made e.g. a lone col-md-12
 * (no width rule below 768px) shrink-to-fit its content on phones and push
 * the page wider than the viewport. Mirror BS3's media scoping instead.
 */
@media (min-width: 576px) {
    :where(:not(.row)) > :is(.col-sm, .col-sm-auto, .col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12):not(.row) {
        float: left;
    }
}
@media (min-width: 768px) {
    :where(:not(.row)) > :is(.col-md, .col-md-auto, .col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12):not(.row) {
        float: left;
    }
}
@media (min-width: 992px) {
    :where(:not(.row)) > :is(.col-lg, .col-lg-auto, .col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12):not(.row) {
        float: left;
    }
}
@media (min-width: 1200px) {
    :where(:not(.row)) > :is(.col-xl, .col-xl-auto, .col-xl-1, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-10, .col-xl-11, .col-xl-12):not(.row) {
        float: left;
    }
}

/*
 * The bundled select2 build has no !important on its .select2-hidden-accessible
 * rule, so later width rules (e.g. AdminLTE's .fs_input { width: 100%; })
 * re-expand the visually-hidden native select to full viewport width, adding
 * horizontal page scroll on every page with a select2 filter. Re-assert the
 * modern select2 hiding contract.
 */
select.select2-hidden-accessible {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0 0 0 0) !important;
    border: 0 !important;
}

/*
 * AdminLTE declares .input-group { margin-bottom: 15px !important; } which
 * defeats Bootstrap's own .mb-0 utility purely by cascade order. Give the
 * utility a higher-specificity escape hatch so BS5 grid gutters can own the
 * spacing.
 */
.input-group.mb-0 {
    margin-bottom: 0 !important;
}

/*
 * .margintop10 is used on hundreds of legacy form blocks as the vertical
 * rhythm between fields, but no stylesheet ever defines it (the BS3-era
 * .form-group margin used to mask that). Without it, on-border floating
 * labels rise straight into the element above. Restore the helper.
 */
.margintop10 {
    margin-top: 10px;
}

/*
 * BS3 gave every .form-group a 15px bottom margin; BS5 dropped the class.
 * Legacy blocks still wrapped in the old float-label-control plugin markup
 * (toggles, radio groups, un-converted inputs) were designed around it.
 * Restore it there only — converted floating fields don't carry the class.
 */
.form-group.float-label-control {
    margin-bottom: 15px;
}
