/* ============================================================
   FIPS Forms — global modern form kit
   Applies to every Bootstrap form in the admin app.
   Loaded after fips-theme.css so it always wins.
   ============================================================ */

/* ---------- Field shells ---------- */
.form-control,
.custom-select,
.form-select,
textarea.form-control,
select.form-control,
input.form-control,
.form-control-file {
  border: 1.5px solid #d8e0d9 !important;
  border-radius: 12px !important;
  font-size: 0.9rem !important;
  font-weight: 500;
  color: #22302a !important;
  background: #fff !important;
  padding: 0.65rem 0.95rem !important;
  min-height: 44px !important;
  height: auto !important;
  line-height: 1.35;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-shadow: 0 1px 2px rgba(10, 56, 20, 0.03);
}
textarea.form-control {
  min-height: 110px;
  padding-top: 0.75rem !important;
  resize: vertical;
}
.form-control-sm,
select.form-control-sm,
input.form-control-sm {
  min-height: 36px;
  padding: 0.4rem 0.75rem !important;
  font-size: 0.82rem !important;
  border-radius: 10px !important;
}
.form-control-lg {
  min-height: 52px;
  padding: 0.8rem 1.1rem !important;
  font-size: 1rem !important;
  border-radius: 14px !important;
}

.form-control:hover,
.custom-select:hover,
.form-select:hover {
  border-color: #b8c9bb !important;
}
.form-control:focus,
.custom-select:focus,
.form-select:focus,
.form-control:focus-visible {
  border-color: #1a5c2e !important;
  box-shadow: 0 0 0 4px rgba(26, 92, 46, 0.12) !important;
  outline: 0 !important;
  background: #fff !important;
}
.form-control::placeholder,
.form-control::-webkit-input-placeholder {
  color: #9aa79d !important;
  font-weight: 450;
  opacity: 1;
}
.form-control:disabled,
.form-control[readonly],
.custom-select:disabled {
  background: #f4f7f4 !important;
  color: #6b7a6e !important;
  border-color: #e6ede7 !important;
  cursor: not-allowed;
  opacity: 1;
}

/* ---------- Labels & help ---------- */
label,
.col-form-label,
.form-label,
.control-label {
  font-weight: 700 !important;
  font-size: 0.82rem !important;
  color: #37473c !important;
  letter-spacing: 0.01em;
  margin-bottom: 0.4rem !important;
}
.col-form-label { padding-top: calc(0.65rem + 1.5px); }
.form-text,
.help-block,
small.form-text,
.text-muted.form-hint {
  font-size: 0.78rem !important;
  color: #7d8a80 !important;
  margin-top: 0.35rem;
  display: block;
}
.required::after,
label .text-danger,
.form-group.required > label::after {
  content: none;
}
label .text-danger,
.required-star {
  color: #c0392b !important;
  font-weight: 800;
}

/* ---------- Form groups / spacing ---------- */
.form-group,
.mb-3.form-field,
.form-row > [class*="col-"] {
  margin-bottom: 1.1rem;
}
.form-group:last-child { margin-bottom: 0; }
.form-row { margin-left: -0.5rem; margin-right: -0.5rem; }
.form-row > [class*="col-"] { padding-left: 0.5rem; padding-right: 0.5rem; }

/* ---------- Input groups ---------- */
.input-group {
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(10, 56, 20, 0.03);
}
.input-group > .form-control,
.input-group > .custom-select,
.input-group > .form-select {
  box-shadow: none;
}
.input-group-text {
  background: #f4f8f5 !important;
  border: 1.5px solid #d8e0d9 !important;
  color: #5a6a5f !important;
  font-size: 0.85rem !important;
  font-weight: 600;
  border-radius: 12px !important;
  padding: 0.55rem 0.85rem;
}
.input-group > .input-group-prepend > .input-group-text,
.input-group > .input-group-append > .input-group-text,
.input-group-prepend .input-group-text,
.input-group-append .input-group-text {
  border-radius: 12px;
}
.input-group > .form-control:not(:first-child),
.input-group > .custom-select:not(:first-child) {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}
.input-group > .form-control:not(:last-child),
.input-group > .custom-select:not(:last-child) {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
}
.input-group-prepend .input-group-text {
  border-top-right-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-right: 0 !important;
}
.input-group-append .input-group-text,
.input-group-append .btn {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
}
.input-group .btn {
  border-radius: 12px !important;
  min-height: 44px;
}
.input-group-append .btn:last-child {
  border-top-left-radius: 0 !important;
  border-bottom-left-radius: 0 !important;
  border-top-right-radius: 12px !important;
  border-bottom-right-radius: 12px !important;
}

/* ---------- Checkboxes / radios / switches ---------- */
.custom-control {
  padding-left: 1.85rem;
  min-height: 1.5rem;
  margin-bottom: 0.55rem;
}
.custom-control-label {
  font-weight: 600 !important;
  font-size: 0.875rem !important;
  color: #37473c !important;
  padding-top: 0.1rem;
  cursor: pointer;
}
.custom-control-label::before {
  width: 1.15rem !important;
  height: 1.15rem !important;
  top: 0.15rem !important;
  left: -1.85rem !important;
  border: 1.5px solid #c3d1c5 !important;
  background: #fff !important;
  border-radius: 6px !important;
  box-shadow: none !important;
}
.custom-radio .custom-control-label::before {
  border-radius: 50% !important;
}
.custom-control-label::after {
  top: 0.15rem !important;
  left: -1.85rem !important;
  width: 1.15rem !important;
  height: 1.15rem !important;
}
.custom-control-input:checked ~ .custom-control-label::before {
  background: #0a3814 !important;
  border-color: #0a3814 !important;
}
.custom-control-input:focus ~ .custom-control-label::before {
  box-shadow: 0 0 0 3px rgba(26, 92, 46, 0.15) !important;
}
.custom-switch .custom-control-label::before {
  width: 2.1rem !important;
  height: 1.2rem !important;
  border-radius: 999px !important;
  left: -2.55rem !important;
  top: 0.2rem !important;
}
.custom-switch .custom-control-label::after {
  width: 0.9rem !important;
  height: 0.9rem !important;
  border-radius: 50% !important;
  left: -2.4rem !important;
  top: 0.35rem !important;
  background: #fff !important;
}
.custom-switch .custom-control-input:checked ~ .custom-control-label::after {
  transform: translateX(0.9rem);
}
.custom-switch { padding-left: 2.7rem; }

/* Native checkbox/radio fallback */
input[type="checkbox"]:not(.custom-control-input),
input[type="radio"]:not(.custom-control-input) {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: #0a3814;
  cursor: pointer;
  vertical-align: middle;
  margin-right: 0.4rem;
}

/* ---------- File inputs ---------- */
.custom-file-label,
.form-control-file {
  border-radius: 12px !important;
}
.custom-file-label {
  border: 1.5px solid #d8e0d9 !important;
  background: #fafcfa !important;
  height: 44px;
  padding: 0.65rem 0.95rem;
  color: #5a6a5f;
  font-weight: 600;
}
.custom-file-label::after {
  background: #0a3814 !important;
  color: #fff !important;
  border-radius: 0 11px 11px 0 !important;
  height: calc(100% + 2px);
  padding: 0.65rem 0.95rem;
  font-weight: 700;
}
input[type="file"].form-control {
  padding: 0.45rem 0.75rem !important;
}

/* ---------- Validation ---------- */
.was-validated .form-control:invalid,
.form-control.is-invalid,
.was-validated .custom-select:invalid,
.custom-select.is-invalid {
  border-color: #c0392b !important;
  background-image: none !important;
  padding-right: 0.95rem !important;
}
.was-validated .form-control:invalid:focus,
.form-control.is-invalid:focus {
  box-shadow: 0 0 0 4px rgba(192, 57, 43, 0.12) !important;
}
.was-validated .form-control:valid,
.form-control.is-valid {
  border-color: #1a5c2e !important;
  background-image: none !important;
  padding-right: 0.95rem !important;
}
.was-validated .form-control:valid:focus,
.form-control.is-valid:focus {
  box-shadow: 0 0 0 4px rgba(26, 92, 46, 0.12) !important;
}
.invalid-feedback,
.valid-feedback {
  font-size: 0.78rem !important;
  font-weight: 600;
  margin-top: 0.35rem;
}
.invalid-feedback { color: #c0392b !important; }
.valid-feedback { color: #1a5c2e !important; }

/* ---------- Form cards / sections (common patterns) ---------- */
.card form .card-body,
.card .card-body form,
form .card-body {
  padding: 1.35rem 1.4rem;
}
.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #eef1ee;
}
.form-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: 0;
}
.form-section-header,
.form-section-title {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: #0a3814;
  margin: 0 0 1rem;
  padding-bottom: 0.55rem;
  border-bottom: 2px solid #e8f5ed;
}
.form-section-header i,
.form-section-title i {
  color: #1a5c2e;
}

/* Sticky / footer action bars on forms */
.card-footer form,
form .card-footer,
.form-actions,
.fips-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
  padding-top: 1rem;
  margin-top: 0.5rem;
  border-top: 1px solid #e6ede7;
}
.form-actions--start,
.fips-form-actions--start { justify-content: flex-start; }
.form-actions--between,
.fips-form-actions--between { justify-content: space-between; }

/* Keep action buttons on one baseline — never overlap */
.fips-form-actions__group,
.form-actions__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}
.fips-form-actions .btn,
.fips-form-actions a.btn,
.fips-form-actions__group .btn,
.fips-form-actions__group a.btn,
.form-actions .btn,
.form-actions a.btn {
  float: none !important;
  position: static !important;
  margin: 0 !important;
  flex: 0 0 auto;
  width: auto !important;
  max-width: 100%;
  align-self: center;
  transform: none;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  line-height: 1.25;
  /* Same border box on primary + secondary so they share a baseline */
  border-width: 1px !important;
  border-style: solid !important;
}
/* Never resurrect intentionally hidden step/action buttons */
.fips-form-actions .btn.d-none,
.fips-form-actions a.btn.d-none,
.fips-form-actions__group .btn.d-none,
.form-actions .btn.d-none,
.fips-form-actions [hidden],
.fips-form-actions__group [hidden],
.form-actions [hidden] {
  display: none !important;
}
.fips-form-actions .btn:hover,
.fips-form-actions a.btn:hover,
.fips-form-actions__group .btn:hover,
.form-actions .btn:hover {
  transform: translateY(-1px);
}

@media (max-width: 576px) {
  .fips-form-actions,
  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .fips-form-actions__group,
  .form-actions__group {
    margin-left: 0;
    flex-direction: column;
    width: 100%;
  }
  .fips-form-actions .btn,
  .fips-form-actions a.btn,
  .fips-form-actions__group .btn,
  .fips-form-actions__group a.btn,
  .form-actions .btn,
  .form-actions a.btn {
    width: 100% !important;
    justify-content: center;
  }
}

/* ---------- Select2 (global polish) ---------- */
.select2-container { width: 100% !important; }
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
  border: 1.5px solid #d8e0d9 !important;
  border-radius: 12px !important;
  min-height: 44px !important;
  background: #fff !important;
  box-shadow: 0 1px 2px rgba(10, 56, 20, 0.03);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 42px !important;
  padding-left: 0.95rem !important;
  color: #22302a !important;
  font-weight: 500;
  font-size: 0.9rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 42px !important;
  right: 8px;
}
.select2-container--default .select2-selection--multiple {
  padding: 0.35rem 0.5rem !important;
}
.select2-container--default .select2-selection--multiple .select2-selection__choice {
  background: #e8f5ed !important;
  border: 0 !important;
  border-radius: 999px !important;
  color: #0a3814 !important;
  font-weight: 700;
  font-size: 0.78rem;
  padding: 0.2rem 0.55rem;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--multiple {
  border-color: #1a5c2e !important;
  box-shadow: 0 0 0 4px rgba(26, 92, 46, 0.12) !important;
}
.select2-dropdown {
  border: 1px solid #e6ede7 !important;
  border-radius: 12px !important;
  box-shadow: 0 16px 40px rgba(10, 56, 20, 0.14) !important;
  overflow: hidden;
  margin-top: 4px;
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
  background: #0a3814 !important;
  color: #fff !important;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
  border: 1.5px solid #d8e0d9 !important;
  border-radius: 10px !important;
  padding: 0.5rem 0.75rem !important;
}

/* ---------- Filter toolbars (search rows on list pages) ---------- */
.filter-bar,
.filters-row,
.table-filter,
.search-filters,
.card-tools .form-inline {
  gap: 0.55rem;
}
.form-inline .form-control,
.form-inline .custom-select {
  width: auto;
  min-width: 140px;
}
.form-inline .btn { min-height: 44px; }

/* ---------- Modal forms ---------- */
.modal-body .form-group { margin-bottom: 1rem; }
.modal-body .form-control,
.modal-body .custom-select,
.modal-body .form-select {
  min-height: 42px;
}

/* ---------- Dark theme safety ---------- */
body.theme-dark .form-control,
body.theme-dark .custom-select,
body.theme-dark .form-select {
  background: #111827 !important;
  border-color: #374151 !important;
  color: #e5e7eb !important;
}
body.theme-dark label,
body.theme-dark .form-label,
body.theme-dark .col-form-label {
  color: #d1d5db !important;
}
body.theme-dark .input-group-text {
  background: #1f2937 !important;
  border-color: #374151 !important;
  color: #9ca3af !important;
}
