/* ===================================
   QCheckbox and QRadio - Bootstrap 5 Styling
   Fixes for form-check components
   Uses !important to override legacy Bootstrap 3 styles
   =================================== */

/* Form Check Base */
.form-check {
    display: block !important;
    min-height: 1.5rem !important;
    padding-left: 1.5em !important;
    margin-bottom: 0.125rem !important;
    position: relative !important;
}

.form-check-inline {
    display: inline-block !important;
    margin-right: 1rem !important;
    padding-left: 1.5em !important;
}

/* Radio & Checkbox Inputs - VERY SPECIFIC to override everything */
.form-check .form-check-input,
.form-check-inline .form-check-input,
.form-check input[type="radio"].form-check-input,
.form-check input[type="checkbox"].form-check-input,
.form-check-inline input[type="radio"].form-check-input,
.form-check-inline input[type="checkbox"].form-check-input {
    width: 1em !important;
    height: 1em !important;
    margin-top: 0.25em !important;
    margin-left: -1.5em !important;
    margin-right: 0 !important;
    vertical-align: top !important;
    background-color: #fff !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    border: 1px solid rgba(0, 0, 0, 0.25) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    flex-shrink: 0 !important;
    position: static !important;
    float: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
}

/* ===================================
   FORM VALIDATION - Bootstrap 5
   =================================== */

/* Invalid Feedback */
.invalid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #dc3545;
    font-style: italic;
}

.invalid-feedback.d-block {
    display: block !important;
}

.invalid-feedback i {
    margin-right: 0.25rem;
}

/* Valid Feedback */
.valid-feedback {
    display: none;
    width: 100%;
    margin-top: 0.25rem;
    font-size: 0.875em;
    color: #198754;
}

.valid-feedback.d-block {
    display: block !important;
}

/* Form Control Validation States */
.form-control.is-invalid,
.form-select.is-invalid {
    border-color: #dc3545 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='%23dc3545' stroke='none'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-invalid:focus,
.form-select.is-invalid:focus {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

.form-control.is-valid,
.form-select.is-valid {
    border-color: #198754 !important;
    padding-right: calc(1.5em + 0.75rem);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23198754' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.form-control.is-valid:focus,
.form-select.is-valid:focus {
    border-color: #198754 !important;
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25) !important;
}

/* Form Check Validation */
.form-check-input.is-invalid {
    border-color: #dc3545 !important;
}

.form-check-input.is-invalid:checked {
    background-color: #dc3545 !important;
}

.form-check-input.is-invalid:focus {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}

.form-check-input.is-invalid ~ .form-check-label {
    color: #dc3545;
}

.form-check-input.is-valid {
    border-color: #198754 !important;
}

.form-check-input.is-valid:checked {
    background-color: #198754 !important;
}

.form-check-input.is-valid:focus {
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25) !important;
}

.form-check-input.is-valid ~ .form-check-label {
    color: #198754;
}
}

.form-check-input[type="checkbox"],
.form-check input[type="checkbox"].form-check-input {
    border-radius: 0.25em !important;
}

.form-check-input[type="radio"],
.form-check input[type="radio"].form-check-input {
    border-radius: 50% !important;
}

/* Checked State */
.form-check-input:checked,
.form-check input[type="radio"].form-check-input:checked,
.form-check input[type="checkbox"].form-check-input:checked {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

.form-check-input:checked[type="checkbox"],
.form-check input[type="checkbox"].form-check-input: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") !important;
}

.form-check-input:checked[type="radio"],
.form-check input[type="radio"].form-check-input: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") !important;
}

/* Focus State */
.form-check-input:focus,
.form-check input[type="radio"].form-check-input:focus,
.form-check input[type="checkbox"].form-check-input:focus {
    border-color: #86b7fe !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25) !important;
}

/* Disabled State */
.form-check-input:disabled,
.form-check input[type="radio"].form-check-input:disabled,
.form-check input[type="checkbox"].form-check-input:disabled {
    pointer-events: none !important;
    filter: none !important;
    opacity: 0.5 !important;
}

.form-check-input:disabled ~ .form-check-label,
.form-check input.form-check-input:disabled ~ .form-check-label {
    opacity: 0.5 !important;
}

/* Label */
.form-check-label,
.form-check .form-check-label,
.form-check-inline .form-check-label {
    cursor: pointer !important;
    margin-bottom: 0 !important;
    padding-left: 0.25rem !important;
    display: inline-block !important;
    position: relative !important;
}

.form-check-input:disabled ~ .form-check-label,
.form-check input.form-check-input:disabled ~ .form-check-label {
    cursor: default !important;
}

/* Indeterminate State (for checkboxes) */
.form-check-input:indeterminate,
.form-check input[type="checkbox"].form-check-input:indeterminate {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    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 10h8'/%3e%3c/svg%3e") !important;
}

/* Validation States */
.form-check-input.is-valid,
.form-check input[type="radio"].form-check-input.is-valid,
.form-check input[type="checkbox"].form-check-input.is-valid {
    border-color: #198754 !important;
}

.form-check-input.is-valid:checked,
.form-check input.form-check-input.is-valid:checked {
    background-color: #198754 !important;
}

.form-check-input.is-valid:focus,
.form-check input.form-check-input.is-valid:focus {
    box-shadow: 0 0 0 0.25rem rgba(25, 135, 84, 0.25) !important;
}

.form-check-input.is-invalid,
.form-check input[type="radio"].form-check-input.is-invalid,
.form-check input[type="checkbox"].form-check-input.is-invalid {
    border-color: #dc3545 !important;
}

.form-check-input.is-invalid:focus,
.form-check input.form-check-input.is-invalid:focus {
    box-shadow: 0 0 0 0.25rem rgba(220, 53, 69, 0.25) !important;
}
