/*
 * Fieldset legends (checkboxes, radios, …) — same size as details/summary
 * field-group titles. Bootstrap reboot sets legend to 1.5rem; keep form
 * groups quiet by default. Child themes may enlarge selectively.
 */
fieldset legend,
fieldset .fieldset-legend {
  font-size: 1rem;
  line-height: 1.5;
}

fieldset.card > legend.card-header {
  margin-bottom: 0;
}

/*
 * Checkout panes are already cards. Nested fieldsets (payment method,
 * billing, …) must not look like cards-in-cards.
 */
.commerce-checkout-flow .checkout-pane.card {
  padding: 0;
}

.checkout-pane fieldset.card {
  border: 0;
  box-shadow: none;
  background-color: transparent;
  margin-bottom: 1.25rem;
}

.checkout-pane fieldset.card:last-child {
  margin-bottom: 0;
}

.checkout-pane fieldset.card > legend.card-header {
  float: none;
  width: 100%;
  padding: 0 0 0.5rem;
  margin-bottom: 0.5rem;
  background-color: transparent;
  border: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.checkout-pane fieldset.card > .fieldset-wrapper.card-body {
  padding: 0;
}

/*
 * Shared control height for text inputs and input-group addons.
 * Do NOT force height on standalone .form-select — with Bootstrap's
 * appearance:none that breaks Chromium native dropdown positioning
 * (popup overlaps the control; mouseup picks a random option).
 * Price/currency selects keep a fixed height via commerce-price.css
 * and the .input-group rules below.
 */
:root {
  --dkit-control-height: calc(1.5em + 0.75rem + 2px);
}

.form-control:not(textarea):not([type="file"]):not([type="range"]):not([type="color"]) {
  box-sizing: border-box;
  height: var(--dkit-control-height);
  min-height: var(--dkit-control-height);
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
  line-height: 1.5;
}

.input-group {
  align-items: stretch;
  width: auto;
  max-width: 100%;
  flex-wrap: nowrap;
}

.input-group > .form-control,
.input-group > .form-select {
  /* Keep Bootstrap flex grow; do not force width:auto (breaks height stretch). */
  flex: 1 1 auto;
  width: 1%;
  min-width: 6rem;
  height: var(--dkit-control-height);
  min-height: var(--dkit-control-height);
  margin-bottom: 0;
}

.input-group > .input-group-text,
.input-group > .field-prefix.input-group-text,
.input-group > .field-suffix.input-group-text {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  height: var(--dkit-control-height);
  min-height: var(--dkit-control-height);
  padding-top: 0;
  padding-bottom: 0;
  line-height: 1.5;
}

.form-item-editor-format label {
  margin-right: 0.5rem;
}

.form-item label.form-required::after,
.form-required::after {
  content: '*';
  color: var(--bs-danger);
  margin-left: 0.15em;
}

.views-exposed-form .form-select {
  width: 100%;
}

/* Exposed filters: horizontal row on desktop, stack on small screens. */
.views-exposed-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.views-exposed-form > .form-item {
  flex: 0 0 auto;
  width: auto;
  max-width: 16rem;
  margin-bottom: 0;
}

.views-exposed-form > .form-actions {
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  margin-bottom: 0;
}

@media (max-width: 767.98px) {
  .views-exposed-form > .form-item,
  .views-exposed-form > .form-actions {
    flex: 1 1 100%;
    max-width: 100%;
  }
}

.views-exposed-form .form-item,
.views-exposed-form .form-actions {
  margin-bottom: 0;
}

button.link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bs-link-color);
  text-decoration: underline;
}

button.link:hover {
  color: var(--bs-link-hover-color);
}

/* Checkboxes and radios inside tables (tableselect, VBO, Views UI listings).
   Bootstrap's .form-check indents the input with padding + negative margin,
   which pushes the control outside the table cell. Reset it so the control
   stays centred within the cell. */
td .form-check,
th .form-check,
td .form-item,
th .form-item {
  margin-bottom: 0;
  padding-left: 0;
  min-height: 0;
}

td .form-check .form-check-input,
th .form-check .form-check-input,
td .form-check-input,
th .form-check-input,
td .form-checkbox,
th .form-checkbox,
td .form-radio,
th .form-radio {
  float: none;
  margin: 0;
}

td .form-check-label,
th .form-check-label {
  margin-left: 0.375rem;
}
