/* ============================================================
   SmartAdmin Bootstrap 5 - Forms
   CSS Module: Input Fields, Validation, Checkboxes, Radio
   ============================================================ */

/* Form Controls */
.form-control,
.form-select,
.form-range {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  background-clip: padding-box;
  border: 1px solid var(--bs-gray-300);
  border-radius: var(--bs-border-radius);
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.form-control:focus,
.form-select:focus {
  color: var(--bs-body-color);
  background-color: var(--bs-body-bg);
  border-color: var(--bs-primary);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(33, 150, 243, 0.25);
}

.form-control:disabled,
.form-select:disabled {
  background-color: var(--bs-gray-100);
  opacity: 1;
  cursor: not-allowed;
}

.form-control::placeholder {
  color: var(--bs-gray-500);
  opacity: 1;
}

/* Form Sizes */
.form-control-sm {
  min-height: calc(1.5em + 0.5rem + 2px);
  padding: 0.25rem 0.5rem;
  font-size: 0.875rem;
  border-radius: var(--bs-border-radius);
}

.form-control-lg {
  min-height: calc(1.5em + 1rem + 2px);
  padding: 0.75rem 1rem;
  font-size: 1.25rem;
  border-radius: var(--bs-border-radius-lg);
}

/* Textarea */
textarea.form-control {
  min-height: 5rem;
  resize: vertical;
}

textarea.form-control-sm {
  min-height: 2.5rem;
}

textarea.form-control-lg {
  min-height: 7.5rem;
}

/* Select */
.form-select {
  padding-right: 4.125rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
}

.form-select:focus {
  border-color: var(--bs-primary);
  box-shadow: 0 0 0 0.2rem rgba(33, 150, 243, 0.25);
}

/* Form Groups */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: inherit;
}

.form-group label.required::after {
  content: " *";
  color: var(--bs-danger);
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--bs-gray-600);
  font-size: 0.875rem;
}

/* Form Row */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-row.row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -0.5rem;
  margin-left: -0.5rem;
}

.form-row .col {
  padding-right: 0.5rem;
  padding-left: 0.5rem;
}

/* Input Groups */
.input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
}

.input-group > .form-control,
.input-group > .form-select {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
  color: var(--bs-body-color);
  text-align: center;
  white-space: nowrap;
  background-color: var(--bs-gray-100);
  border: 1px solid var(--bs-gray-300);
  border-radius: var(--bs-border-radius);
}

[data-bs-theme="dark"] .input-group-text {
  background-color: var(--bs-gray-700);
  border-color: var(--bs-gray-600);
}

.input-group-prepend {
  display: flex;
  margin-right: -1px;
}

.input-group-append {
  display: flex;
  margin-left: -1px;
}

.input-group-prepend .btn,
.input-group-prepend .input-group-text,
.input-group-append .btn,
.input-group-append .input-group-text {
  border-radius: var(--bs-border-radius);
}

/* Checkboxes & Radio Buttons */
.form-check {
  display: block;
  min-height: 1.5rem;
  padding-left: 1.5rem;
  margin-bottom: 0.125rem;
}

.form-check-input {
  float: left;
  margin-left: -1.5rem;
  margin-top: 0.3em;
  accent-color: var(--bs-primary);
  cursor: pointer;
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--bs-gray-300);
  border-radius: 0.25em;
  appearance: none;
  background-color: var(--bs-body-bg);
  background-image: none;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border-color: var(--bs-gray-300);
  transition: border-color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.form-check-input:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

.form-check-input:checked::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
}

.form-check-input:focus {
  border-color: var(--bs-primary);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(33, 150, 243, 0.25);
}

.form-check-input:disabled {
  pointer-events: none;
  filter: none;
  opacity: 0.5;
}

.form-check-label {
  margin-bottom: 0;
  cursor: pointer;
}

.form-check-inline {
  display: inline-block;
  margin-right: 1rem;
}

/* Radio */
.form-check-input[type="radio"] {
  border-radius: 50%;
}

/* Switch */
.form-switch .form-check-input {
  width: 2.5em;
  margin-left: -2.5em;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3cpath stroke='%23fff' d='M-3 0a3 3 0 0 0 6 0'/%3e%3c/svg%3e");
  background-position: left center;
  border-radius: 2em;
  transition: background-position 0.15s ease-in-out;
}

.form-switch .form-check-input:checked {
  background-position: right center;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3cpath stroke='%23fff' d='M3 0a3 3 0 0 0-6 0'/%3e%3c/svg%3e");
}

/* Validation States */
.form-control.is-valid,
.form-select.is-valid {
  border-color: var(--bs-success);
}

.form-control.is-valid:focus,
.form-select.is-valid:focus {
  border-color: var(--bs-success);
  box-shadow: 0 0 0 0.2rem rgba(76, 175, 80, 0.25);
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--bs-danger);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
  border-color: var(--bs-danger);
  box-shadow: 0 0 0 0.2rem rgba(244, 67, 54, 0.25);
}

.valid-feedback,
.invalid-feedback {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  font-weight: 500;
}

.valid-feedback {
  color: var(--bs-success);
}

.invalid-feedback {
  color: var(--bs-danger);
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback {
  display: block;
}

.was-validated .form-control:valid ~ .valid-feedback,
.form-control.is-valid ~ .valid-feedback {
  display: block;
}

/* Fieldset */
fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

legend {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: inherit;
  color: inherit;
}

/* Range Input */
.form-range {
  width: 100%;
  height: 1.5rem;
  padding: 0;
  background-color: transparent;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.form-range::-webkit-slider-thumb {
  width: 1.25rem;
  height: 1.25rem;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bs-primary);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-range::-webkit-slider-thumb:active {
  background-color: #90caf9;
  box-shadow: 0 0 0 0.5rem rgba(33, 150, 243, 0.25);
}

.form-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 0.5rem;
  color: transparent;
  cursor: pointer;
  background-color: var(--bs-gray-300);
  border-color: transparent;
  border-radius: 1rem;
}

.form-range::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  background: var(--bs-primary);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-range::-moz-range-thumb:active {
  background-color: #90caf9;
  box-shadow: 0 0 0 0.5rem rgba(33, 150, 243, 0.25);
}

.form-range::-moz-range-track {
  background-color: transparent;
  border-color: transparent;
}

.form-range::-moz-range-progress {
  background-color: var(--bs-primary);
  border-radius: 1rem;
  height: 0.5rem;
}
