/*
 * Authoritative form-control contrast contract.
 *
 * This file must load after every legacy theme/contrast stylesheet. Text-entry
 * controls are intentionally light surfaces everywhere in the dark application
 * shell. Foreground, background, browser text-fill, native color scheme and
 * state styling are always set together so later inheritance cannot produce
 * white-on-white or dark-on-dark values.
 */

:root {
    --form-field-bg: #ffffff;
    --form-field-fg: #111827;
    --form-field-placeholder: #5b6472;
    --form-field-border: #6b7280;
    --form-field-focus: #0d6efd;
    --form-field-disabled-bg: #e9ecef;
    --form-field-disabled-fg: #343a40;
    --form-field-invalid: #dc3545;
}

html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]),
html[data-bs-theme="dark"] body textarea,
html[data-bs-theme="dark"] body select {
    background-color: var(--form-field-bg) !important;
    color: var(--form-field-fg) !important;
    -webkit-text-fill-color: var(--form-field-fg) !important;
    border-color: var(--form-field-border) !important;
    caret-color: var(--form-field-fg) !important;
    color-scheme: light !important;
    opacity: 1 !important;
}

html[data-bs-theme="dark"] body 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='%23111827' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 0.75rem center !important;
    background-size: 16px 12px !important;
}

html[data-bs-theme="dark"] body select[multiple],
html[data-bs-theme="dark"] body select[size]:not([size="1"]) {
    background-image: none !important;
}

html[data-bs-theme="dark"] body select option,
html[data-bs-theme="dark"] body select optgroup,
html[data-bs-theme="dark"] body select.form-select option,
html[data-bs-theme="dark"] body select.form-select optgroup {
    background-color: var(--form-field-bg) !important;
    color: var(--form-field-fg) !important;
    -webkit-text-fill-color: var(--form-field-fg) !important;
}

html[data-bs-theme="dark"] body input::placeholder,
html[data-bs-theme="dark"] body textarea::placeholder {
    color: var(--form-field-placeholder) !important;
    -webkit-text-fill-color: var(--form-field-placeholder) !important;
    opacity: 1 !important;
}

html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]):focus,
html[data-bs-theme="dark"] body textarea:focus,
html[data-bs-theme="dark"] body select:focus {
    background-color: var(--form-field-bg) !important;
    color: var(--form-field-fg) !important;
    -webkit-text-fill-color: var(--form-field-fg) !important;
    border-color: var(--form-field-focus) !important;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25) !important;
    outline: 0 !important;
}

html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"])[readonly],
html[data-bs-theme="dark"] body textarea[readonly],
html[data-bs-theme="dark"] body select[readonly],
html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]):disabled,
html[data-bs-theme="dark"] body textarea:disabled,
html[data-bs-theme="dark"] body select:disabled {
    background-color: var(--form-field-disabled-bg) !important;
    color: var(--form-field-disabled-fg) !important;
    -webkit-text-fill-color: var(--form-field-disabled-fg) !important;
    border-color: var(--form-field-border) !important;
    opacity: 1 !important;
}

html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]).is-invalid,
html[data-bs-theme="dark"] body textarea.is-invalid,
html[data-bs-theme="dark"] body select.is-invalid {
    border-color: var(--form-field-invalid) !important;
}

html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]):-webkit-autofill,
html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]):-webkit-autofill:hover,
html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]):-webkit-autofill:focus,
html[data-bs-theme="dark"] body textarea:-webkit-autofill,
html[data-bs-theme="dark"] body select:-webkit-autofill {
    -webkit-text-fill-color: var(--form-field-fg) !important;
    caret-color: var(--form-field-fg) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--form-field-bg) inset !important;
    box-shadow: 0 0 0 1000px var(--form-field-bg) inset !important;
    border-color: var(--form-field-border) !important;
}

html[data-bs-theme="dark"] body input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="image"]):not([type="hidden"]):autofill,
html[data-bs-theme="dark"] body textarea:autofill,
html[data-bs-theme="dark"] body select:autofill {
    background-color: var(--form-field-bg) !important;
    color: var(--form-field-fg) !important;
}

html[data-bs-theme="dark"] body input::-webkit-date-and-time-value,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-fields-wrapper,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-text,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-month-field,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-day-field,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-year-field,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-hour-field,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-minute-field,
html[data-bs-theme="dark"] body input::-webkit-datetime-edit-ampm-field {
    color: var(--form-field-fg) !important;
    -webkit-text-fill-color: var(--form-field-fg) !important;
    opacity: 1 !important;
}

html[data-bs-theme="dark"] body input::-webkit-calendar-picker-indicator {
    opacity: 1 !important;
}

html[data-bs-theme="dark"] body input[type="file"].form-control::file-selector-button {
    background-color: var(--form-field-disabled-bg) !important;
    color: var(--form-field-fg) !important;
    border-color: var(--form-field-border) !important;
}

/* Plaintext fields are labels/value displays, not entry blanks. */
html[data-bs-theme="dark"] body .form-control-plaintext {
    background-color: transparent !important;
    color: inherit !important;
    -webkit-text-fill-color: currentColor !important;
}