/*
 * Bootstrap 5 forward-compatibility shim  (TEMPORARY — delete in re-theme Phase D)
 *
 * The stylesheet is still Bootstrap 3, but the views are being migrated to BS5
 * class names ahead of the base swap (see docs/BS5-RETHEME-AUDIT.md, Phase A).
 * This file defines the BS5 utility/grid names the views now use, reproducing the
 * BS3 semantics EXACTLY so the migration is pixel-identical on the current hybrid.
 * When real Bootstrap 5 CSS lands (Phase D), BS5 provides all of these natively
 * and this file must be removed.
 *
 * MUST load BEFORE bootstrap.css: the bare `.col-N` rules are base (xs) rules;
 * loading first lets BS3's `.col-sm/md/lg-*` media queries (which come later in the
 * cascade) still win at their breakpoints. Values copied verbatim from bootstrap.css.
 */

/* --- Grid: bare `.col-N` mirrors BS3 `.col-xs-N` (col-xs-* -> col-*) --------- */
.col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
.col-7, .col-8, .col-9, .col-10, .col-11, .col-12 {
  position: relative;
  min-height: 1px;
  padding-left: 15px;
  padding-right: 15px;
}
.col-1, .col-2, .col-3, .col-4, .col-5, .col-6,
.col-7, .col-8, .col-9, .col-10, .col-11 {
  float: left;
}
.col-1  { width: 8.333333333333332%; }
.col-2  { width: 16.666666666666664%; }
.col-3  { width: 25%; }
.col-4  { width: 33.33333333333333%; }
.col-5  { width: 41.66666666666667%; }
.col-6  { width: 50%; }
.col-7  { width: 58.333333333333336%; }
.col-8  { width: 66.66666666666666%; }
.col-9  { width: 75%; }
.col-10 { width: 83.33333333333334%; }
.col-11 { width: 91.66666666666666%; }
.col-12 { width: 100%; }

/* --- Offsets: BS3 `col-{bp}-offset-N` -> BS5 `offset-{bp}-N` (only used ones) - */
@media (min-width: 992px) {
  .offset-md-4 { margin-left: 33.33333333333333%; }
}
@media (min-width: 1200px) {
  .offset-lg-3 { margin-left: 25%; }
  .offset-lg-4 { margin-left: 33.33333333333333%; }
  .offset-lg-8 { margin-left: 66.66666666666666%; }
  .offset-lg-9 { margin-left: 75%; }
}

/* --- Form field spacing: BS3 `.form-group` -> BS5 `.mb-3`. BS5 dropped
   `.form-group` (field wrappers use a margin utility). BS3's form-group was just
   `margin-bottom: 15px`; reproduced here (BS5's real .mb-3 is 1rem/16px — the 1px
   matters to the visual gate, so pin 15px on the hybrid). The per-form overrides
   (#login-form 5px, .items-per-page, .results-empty) move to `.mb-3` in their own
   stylesheets and win by specificity/order. */
.mb-3 {
  margin-bottom: 15px;
}
/* Contextual BS3 `.form-group` rules (inline/horizontal/navbar forms) reproduced
   for `.mb-3` — verbatim from bootstrap.css. Without these, mb-3 fields inside a
   .form-inline (admin tools) or .form-horizontal (admin CRUD forms) reflow. */
@media (min-width: 768px) {
  .form-inline .mb-3,
  .navbar-form .mb-3 {
    display: inline-block;
    margin-bottom: 0;
    vertical-align: middle;
  }
}
@media (max-width: 767px) {
  .navbar-form .mb-3 {
    margin-bottom: 5px;
  }
}
.form-horizontal .mb-3 {
  margin-left: -15px;
  margin-right: -15px;
}
.form-horizontal .mb-3:before,
.form-horizontal .mb-3:after {
  content: " ";
  display: table;
}
.form-horizontal .mb-3:after {
  clear: both;
}

/* --- Form labels/help: BS3 `.control-label` -> BS5 `.form-label`,
   `.help-block` -> `.form-text`. BS3 had NO base `.control-label` rule (a plain
   label outside .form-horizontal was unstyled), so `.form-label` gets no base rule
   — only the contextual + validation rules below, verbatim from bootstrap.css. */
.form-text {
  display: block;
  margin-top: 5px;
  margin-bottom: 10px;
  color: #737373;
}
.form-horizontal .form-label,
.form-horizontal .form-check,
.form-horizontal .form-check-inline {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 7px;
}
@media (min-width: 768px) {
  .form-horizontal .form-label {
    text-align: right;
  }
}
.has-warning .form-text,
.has-warning .form-label { color: #c09853; }
.has-error   .form-text,
.has-error   .form-label { color: #b94a48; }
.has-success .form-text,
.has-success .form-label { color: #468847; }

/* --- Checkboxes: BS3 `.checkbox`/`.checkbox-inline` -> BS5 `.form-check`/
   `.form-check-inline`. NOTE: only the WRAPPER CLASS is migrated here; the BS3 DOM
   (input INSIDE the label) is kept, so these rules reproduce BS3 `.checkbox` exactly.
   The BS5 DOM restructure (input as a `.form-check-input` sibling + `.form-check-label`)
   is a Phase D task — it needs real BS5 form-check CSS to look right. Admin-only
   (offices/form.php, tools/index.php); the gated search filters use custom classes,
   not these. Values verbatim from bootstrap.css .checkbox*. */
.form-check {
  display: block;
  min-height: 20px;
  margin-top: 10px;
  margin-bottom: 10px;
  padding-left: 20px;
  vertical-align: middle;
}
.form-check label {
  display: inline;
  margin-bottom: 0;
  font-weight: normal;
  cursor: pointer;
}
.form-check input[type="checkbox"],
.form-check-inline input[type="checkbox"] {
  float: left;
  margin-left: -20px;
}
.form-check + .form-check {
  margin-top: -5px;
}
.form-check-inline {
  display: inline-block;
  padding-left: 20px;
  margin-bottom: 0;
  vertical-align: middle;
  font-weight: normal;
  cursor: pointer;
}
.form-check-inline + .form-check-inline {
  margin-top: 0;
  margin-left: 10px;
}

/* --- Float utilities: BS3 `.pull-*` -> BS5 `.float-*` ------------------------ */
.float-start { float: left !important; }
.float-end   { float: right !important; }

/* --- Cards: BS3 `.panel`/`.panel-default`/`.panel-heading`/`.panel-body`  ----
   -> BS5 `.card`/`.card-header`/`.card-body`. Every panel in the views is a
   `panel panel-default` (folded into `.card` here) except one dynamic
   `panel-success` in admin_crud/tools/result.php (-> `.card-success`). Values
   copied verbatim from bootstrap.css .panel* rules. */
.card {
  margin-bottom: 20px;
  background-color: #ffffff;
  border: 1px solid #dddddd;              /* .panel border + .panel-default border-color */
  border-radius: 4px;
  -webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}
.card-body {
  padding: 15px;
}
.card-header {
  padding: 10px 15px;
  border-bottom: 1px solid #dddddd;
  border-top-right-radius: 3px;
  border-top-left-radius: 3px;
  color: #333333;                          /* .panel-default > .panel-heading */
  background-color: #f5f5f5;
}
.card-success {
  border-color: #d6e9c6;
}
.card-success > .card-header {
  color: #3c763d;
  background-color: #dff0d8;
  border-color: #d6e9c6;
}

/* --- Buttons: BS3 `.btn-default` -> BS5 `.btn-secondary`. Reproduces BS3's
   btn-default in every state so it is pixel-identical on the hybrid. (The admin
   flat-grey override moves to backend.css `.btn-secondary`.) Values verbatim from
   bootstrap.css .btn-default*. */
.btn-secondary {
  color: #333333;
  background-color: #ffffff;
  border-color: #cccccc;
}
.btn-secondary:hover,
.btn-secondary:focus,
.btn-secondary:active,
.btn-secondary.active,
.open .dropdown-toggle.btn-secondary {
  color: #333333;
  background-color: #ebebeb;
  border-color: #adadad;
}
.btn-secondary:active,
.btn-secondary.active,
.open .dropdown-toggle.btn-secondary {
  background-image: none;
}
.btn-secondary.disabled,
.btn-secondary[disabled],
fieldset[disabled] .btn-secondary {
  background-color: #ffffff;
  border-color: #cccccc;
}

/* --- Images: BS3 `.img-responsive` -> BS5 `.img-fluid` ---------------------- */
/* NB BS3 also set display:block; native BS5 img-fluid does not. Kept here for a
   pixel-identical Phase A; drop the display:block when BS5 lands if it drifts. */
.img-fluid {
  display: block;
  max-width: 100%;
  height: auto;
}
