/*
 * Patch focused on dark-mode form control contrast.
 * Scope: text color, caret, focus, placeholders and autofill only.
 */

html[data-bs-theme="dark"],
[data-bs-theme="dark"] {
  --ag-form-fg: var(--bs-body-color);
  --ag-form-bg: var(--bs-body-bg);
  --ag-form-border: var(--bs-border-color);
  --ag-form-placeholder: rgba(var(--bs-body-color-rgb), 0.65);
}

html[data-theme="dark"],
[data-theme="dark"] {
  --ag-form-fg: var(--text, #f8f9fa);
  --ag-form-bg: var(--surface, #15181b);
  --ag-form-border: var(--border, #2c3238);
  --ag-form-placeholder: color-mix(in srgb, var(--ag-form-fg) 65%, transparent);
}

html[data-bs-theme="dark"] .form-control,
html[data-bs-theme="dark"] .form-select,
html[data-bs-theme="dark"] textarea,
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] textarea,
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] textarea,
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select,
[data-theme="dark"] textarea {
  color: var(--ag-form-fg) !important;
  caret-color: var(--ag-form-fg);
  background-color: var(--ag-form-bg);
  border-color: var(--ag-form-border);
}

html[data-bs-theme="dark"] .form-control:focus,
html[data-bs-theme="dark"] .form-select:focus,
html[data-bs-theme="dark"] textarea:focus,
[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus,
[data-bs-theme="dark"] textarea:focus,
html[data-theme="dark"] .form-control:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] textarea:focus,
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] textarea:focus {
  color: var(--ag-form-fg) !important;
  caret-color: var(--ag-form-fg);
  background-color: var(--ag-form-bg);
}

html[data-bs-theme="dark"] .form-control::placeholder,
html[data-bs-theme="dark"] textarea::placeholder,
[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] textarea::placeholder,
html[data-theme="dark"] .form-control::placeholder,
html[data-theme="dark"] textarea::placeholder,
[data-theme="dark"] .form-control::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--ag-form-placeholder);
  opacity: 1;
}

html[data-bs-theme="dark"] .form-select option,
[data-bs-theme="dark"] .form-select option,
html[data-theme="dark"] .form-select option,
[data-theme="dark"] .form-select option {
  color: var(--ag-form-fg);
  background-color: var(--ag-form-bg);
}

html[data-bs-theme="dark"] .form-control:-webkit-autofill,
html[data-bs-theme="dark"] .form-control:-webkit-autofill:hover,
html[data-bs-theme="dark"] .form-control:-webkit-autofill:focus,
html[data-bs-theme="dark"] textarea:-webkit-autofill,
html[data-bs-theme="dark"] textarea:-webkit-autofill:hover,
html[data-bs-theme="dark"] textarea:-webkit-autofill:focus,
html[data-bs-theme="dark"] .form-select:-webkit-autofill,
html[data-bs-theme="dark"] .form-select:-webkit-autofill:hover,
html[data-bs-theme="dark"] .form-select:-webkit-autofill:focus,
[data-bs-theme="dark"] .form-control:-webkit-autofill,
[data-bs-theme="dark"] .form-control:-webkit-autofill:hover,
[data-bs-theme="dark"] .form-control:-webkit-autofill:focus,
[data-bs-theme="dark"] textarea:-webkit-autofill,
[data-bs-theme="dark"] textarea:-webkit-autofill:hover,
[data-bs-theme="dark"] textarea:-webkit-autofill:focus,
[data-bs-theme="dark"] .form-select:-webkit-autofill,
[data-bs-theme="dark"] .form-select:-webkit-autofill:hover,
[data-bs-theme="dark"] .form-select:-webkit-autofill:focus,
html[data-theme="dark"] .form-control:-webkit-autofill,
html[data-theme="dark"] .form-control:-webkit-autofill:hover,
html[data-theme="dark"] .form-control:-webkit-autofill:focus,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] textarea:-webkit-autofill:hover,
html[data-theme="dark"] textarea:-webkit-autofill:focus,
html[data-theme="dark"] .form-select:-webkit-autofill,
html[data-theme="dark"] .form-select:-webkit-autofill:hover,
html[data-theme="dark"] .form-select:-webkit-autofill:focus,
[data-theme="dark"] .form-control:-webkit-autofill,
[data-theme="dark"] .form-control:-webkit-autofill:hover,
[data-theme="dark"] .form-control:-webkit-autofill:focus,
[data-theme="dark"] textarea:-webkit-autofill,
[data-theme="dark"] textarea:-webkit-autofill:hover,
[data-theme="dark"] textarea:-webkit-autofill:focus,
[data-theme="dark"] .form-select:-webkit-autofill,
[data-theme="dark"] .form-select:-webkit-autofill:hover,
[data-theme="dark"] .form-select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ag-form-fg) !important;
  caret-color: var(--ag-form-fg);
  box-shadow: 0 0 0 1000px var(--ag-form-bg) inset;
  transition: background-color 9999s ease-out 0s;
}
