/**
 * Modern Form Styles for Bootstrap 5.3+
 * Enhanced form controls with modern design patterns
 */

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

/* Modern Form Labels */
.form-label {
  display: inline-block;
  margin-bottom: 0.625rem;
  font-weight: 600;
  color: #343a40;
  font-size: 0.9375rem;
  letter-spacing: 0.3px;
}

.form-label.required::after {
  content: ' *';
  color: #cd201f;
  font-weight: 700;
}

/* Modern Form Controls */
.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 400;
  line-height: 1.5;
  color: #495057;
  background-color: #ffffff;
  background-clip: padding-box;
  border: 1px solid #dce3e8;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-control:focus,
.form-select:focus {
  color: #495057;
  background-color: #ffffff;
  border-color: #467fcf;
  outline: 0;
  box-shadow: 0 0 0 0.25rem rgba(70, 127, 207, 0.15);
}

.form-control::placeholder {
  color: #adb5bd;
  opacity: 1;
}

/* Form Control Sizes */
.form-control-sm,
.form-select-sm {
  min-height: calc(1.5em + 0.75rem + 2px);
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
}

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

/* Modern Textarea */
textarea.form-control {
  min-height: calc(1.5em + 1.5rem + 2px);
  resize: vertical;
}

/* Modern Select */
.form-select {
  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;
  padding-right: 2.5rem;
}

.form-select:focus {
  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='%23467fcf' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* Modern Checkboxes */
.form-check {
  display: block;
  min-height: 1.5rem;
  padding-left: 1.75rem;
  margin-bottom: 0.75rem;
}

.form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  margin-left: -1.75rem;
  vertical-align: top;
  background-color: #fff;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  border: 2px solid #dce3e8;
  border-radius: 0.375rem;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.form-check-input:checked {
  background-color: #467fcf;
  border-color: #467fcf;
  box-shadow: 0 2px 8px rgba(70, 127, 207, 0.3);
}

.form-check-input[type="checkbox"]:checked {
  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='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/%3e%3c/svg%3e");
}

.form-check-input:focus {
  border-color: #467fcf;
  box-shadow: 0 0 0 0.25rem rgba(70, 127, 207, 0.15);
}

.form-check-label {
  margin-bottom: 0;
  cursor: pointer;
  font-weight: 500;
  color: #495057;
}

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

.form-check-input[type="radio"]:checked {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23fff'/%3e%3c/svg%3e");
}

/* Modern Switches */
.form-switch .form-check-input {
  width: 2.5rem;
  height: 1.375rem;
  border-radius: 2rem;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba(0,0,0,.25)'/%3e%3c/svg%3e");
  background-position: left center;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.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%3ccircle r='3' fill='%23fff'/%3e%3c/svg%3e");
}

/* Modern Input Groups */
.input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

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

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.5;
  color: #495057;
  text-align: center;
  white-space: nowrap;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border: 1px solid #dce3e8;
}

.input-group-text i {
  color: #467fcf;
}

/* Mobile responsiveness */
@media (max-width: 575.98px) {
  .input-group {
    flex-direction: column;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
    border-radius: 0.75rem;
  }

  .input-group > .form-control,
  .input-group > .form-select {
    width: 100%;
    flex: 1 1 100%;
    min-height: 42px;
    border-radius: 0 !important;
    border-left: 1px solid #ced4da !important;
    border-right: 1px solid #ced4da !important;
  }

  .input-group > .form-control:first-child,
  .input-group > .form-select:first-child {
    border-top-left-radius: 0.75rem !important;
    border-top-right-radius: 0.75rem !important;
  }

  .input-group > .form-control:last-child,
  .input-group > .form-select:last-child {
    border-bottom-left-radius: 0.75rem !important;
    border-bottom-right-radius: 0.75rem !important;
  }

  .input-group-text {
    width: 100%;
    justify-content: center;
    border-left: 1px solid #dce3e8;
    border-right: 1px solid #dce3e8;
    border-top-left-radius: 0.75rem;
    border-top-right-radius: 0.75rem;
  }
}

/* Modern Floating Labels */
.form-floating {
  position: relative;
}

.form-floating > .form-control,
.form-floating > .form-select {
  height: calc(3.5rem + 2px);
  padding: 1rem 0.75rem;
}

.form-floating > label {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  padding: 1rem 0.75rem;
  pointer-events: none;
  border: 1px solid transparent;
  transform-origin: 0 0;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: #6c757d;
}

.form-floating > .form-control:focus ~ label,
.form-floating > .form-control:not(:placeholder-shown) ~ label,
.form-floating > .form-select ~ label {
  opacity: 0.65;
  transform: scale(0.85) translateY(-0.5rem) translateX(0.15rem);
  color: #467fcf;
}

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

.form-range::-webkit-slider-thumb {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: -0.375rem;
  background: linear-gradient(135deg, #467fcf 0%, #5d92e0 100%);
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(70, 127, 207, 0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  appearance: none;
  cursor: pointer;
}

.form-range::-webkit-slider-thumb:hover {
  box-shadow: 0 4px 12px rgba(70, 127, 207, 0.4);
  transform: scale(1.1);
}

.form-range::-webkit-slider-runnable-track {
  width: 100%;
  height: 0.5rem;
  color: transparent;
  cursor: pointer;
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  border-color: transparent;
  border-radius: 1rem;
}

.form-range::-moz-range-thumb {
  width: 1.25rem;
  height: 1.25rem;
  background: linear-gradient(135deg, #467fcf 0%, #5d92e0 100%);
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 2px 8px rgba(70, 127, 207, 0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.form-range::-moz-range-track {
  width: 100%;
  height: 0.5rem;
  cursor: pointer;
  background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
  border-color: transparent;
  border-radius: 1rem;
}

/* Modern File Input */
.form-control[type="file"] {
  overflow: hidden;
}

.form-control[type="file"]:not(:disabled):not([readonly]) {
  cursor: pointer;
}

/* Form Validation States */
.form-control.is-valid,
.form-select.is-valid {
  border-color: #5eba00;
  box-shadow: 0 0 0 0.25rem rgba(94, 186, 0, 0.15);
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: #cd201f;
  box-shadow: 0 0 0 0.25rem rgba(205, 32, 31, 0.15);
}

.valid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #5eba00;
  font-weight: 600;
}

.invalid-feedback {
  display: none;
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #cd201f;
  font-weight: 600;
}

.is-valid ~ .valid-feedback,
.is-invalid ~ .invalid-feedback {
  display: block;
}

/* Modern Form Text Helper */
.form-text {
  margin-top: 0.5rem;
  font-size: 0.875rem;
  color: #6c757d;
  font-weight: 500;
}

/* Modern Form Row */
.form-row {
  display: flex;
  flex-wrap: wrap;
  margin-right: -0.5rem;
  margin-left: -0.5rem;
}

.form-row > .col,
.form-row > [class*="col-"] {
  padding-right: 0.5rem;
  padding-left: 0.5rem;
}

/* Disabled State */
.form-control:disabled,
.form-select:disabled {
  background-color: #e9ecef;
  opacity: 0.6;
  cursor: not-allowed;
}

/* Readonly State */
.form-control[readonly] {
  background-color: #f8f9fa;
  opacity: 0.8;
}

/* Modern Color Picker */
.form-control[type="color"] {
  width: 3rem;
  height: 3rem;
  padding: 0.25rem;
  border-radius: 0.5rem;
}

.form-control[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.form-control[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 0.375rem;
}

/* Responsive Adjustments */
@media (max-width: 575.98px) {
  .form-control,
  .form-select {
    font-size: 0.875rem;
  }
  
  .form-label {
    font-size: 0.875rem;
  }
  
  .input-group-text {
    font-size: 0.875rem;
    padding: 0.625rem 0.875rem;
  }
}
