/**
 * Form Input Border Consistency Fixes
 * Ensures all form inputs have consistent border styling across the application
 * 
 * IMPORTANT: This file must be loaded AFTER material-dashboard.css to properly override
 * Material Dashboard's default form styling
 */

:root {
    --form-border-default: #d2d6da;
    --form-border-hover: #c1c5ca;
    --form-border-focus: #A6EF67; /* Your green theme color */
    --form-border-valid: #4CAF50;
    --form-border-invalid: #F44335;
    --form-text-color: #344767;
    --form-label-color: #7b809a;
    --form-placeholder-color: #adb5bd;
}

/* Base form control styling */
.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
input[type="datetime-local"],
input[type="month"],
input[type="time"],
input[type="week"],
input[type="search"],
textarea,
select {
    border: 1px solid var(--form-border-default) !important;
    color: var(--form-text-color) !important;
    background-color: white !important;
    border-radius: 0.375rem !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

/* Input group styling */
.input-group-outline .form-control,
.input-group-static .form-control,
.input-group .form-control {
    border: 1px solid var(--form-border-default) !important;
}

/* Hover state */
.form-control:hover:not(:focus):not(:disabled),
input:hover:not(:focus):not(:disabled),
textarea:hover:not(:focus):not(:disabled),
select:hover:not(:focus):not(:disabled) {
    border-color: var(--form-border-hover) !important;
}

/* Focus state */
.form-control:focus,
input:focus,
textarea:focus,
select:focus,
.input-group.input-group-outline.is-focused .form-control,
.input-group.input-group-static.is-focused .form-control {
    border-color: var(--form-border-focus) !important;
    box-shadow: 0 0 0 0.2rem rgba(166, 239, 103, 0.25) !important;
    outline: 0 !important;
}

/* Remove Material Dashboard's pink/red focus color */
.input-group.input-group-outline.is-focused .form-label,
.input-group.input-group-outline.is-filled .form-label {
    color: var(--form-border-focus) !important;
}

/* Valid state */
.form-control.is-valid,
.was-validated .form-control:valid,
input.is-valid,
textarea.is-valid,
select.is-valid {
    border-color: var(--form-border-valid) !important;
}

/* Invalid state */
.form-control.is-invalid,
.was-validated .form-control:invalid,
input.is-invalid,
textarea.is-invalid,
select.is-invalid {
    border-color: var(--form-border-invalid) !important;
}

/* Disabled state */
.form-control:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    background-color: #f5f5f5 !important;
    border-color: #e0e0e0 !important;
    opacity: 0.6 !important;
}

/* Labels */
.form-label,
.input-group-outline label,
.input-group-static label,
label {
    color: var(--form-label-color) !important;
    font-weight: 400 !important;
}

/* Placeholders */
.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--form-placeholder-color) !important;
    opacity: 1 !important;
}

/* Select dropdowns */
select.form-control,
.form-select {
    border: 1px solid var(--form-border-default) !important;
    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") !important;
    background-repeat: no-repeat !important;
    background-position: right .75rem center !important;
    background-size: 16px 12px !important;
    padding-right: 2.25rem !important;
}

/* File inputs */
input[type="file"] {
    border: 1px solid var(--form-border-default) !important;
    padding: 0.375rem 0.75rem !important;
}

/* Checkbox and radio buttons */
.form-check-input {
    border: 1px solid var(--form-border-default) !important;
}

.form-check-input:checked {
    background-color: var(--form-border-focus) !important;
    border-color: var(--form-border-focus) !important;
}

.form-check-input:focus {
    border-color: var(--form-border-focus) !important;
    box-shadow: 0 0 0 0.2rem rgba(166, 239, 103, 0.25) !important;
}

/* Input groups with addons */
.input-group-text {
    border: 1px solid var(--form-border-default) !important;
    background-color: #f8f9fa !important;
    color: var(--form-label-color) !important;
}

/* Search inputs */
input[type="search"] {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Number input spinners */
input[type="number"] {
    -moz-appearance: textfield !important;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* Material Dashboard specific overrides */
.input-group.input-group-outline .form-control {
    background-color: white !important;
    border: 1px solid var(--form-border-default) !important;
}

.input-group.input-group-outline:not(.is-focused):not(.is-filled) .form-control {
    background-color: white !important;
    border: 1px solid var(--form-border-default) !important;
}

/* Fix for specific Material Dashboard classes */
.bmd-form-group .form-control,
.bmd-form-group input,
.bmd-form-group textarea {
    border: 1px solid var(--form-border-default) !important;
}

/* Ensure text in inputs is always visible */
.form-control,
input,
textarea,
select {
    color: var(--form-text-color) !important;
}

/* Fix for white text in inputs */
.form-control.text-white,
input.text-white,
textarea.text-white,
select.text-white {
    color: var(--form-text-color) !important;
}

/* Override any Material Dashboard animation that might hide borders */
.input-group-outline .form-control,
.input-group-outline input,
.input-group-outline textarea {
    border: 1px solid var(--form-border-default) !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

/* Ensure consistent padding */
.form-control,
input:not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    padding: 0.5rem 0.75rem !important;
}

/* Small form controls */
.form-control-sm,
input.form-control-sm {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.875rem !important;
}

/* Large form controls */
.form-control-lg,
input.form-control-lg {
    padding: 0.75rem 1rem !important;
    font-size: 1.25rem !important;
}

/* Readonly inputs */
.form-control[readonly],
input[readonly],
textarea[readonly] {
    background-color: #f8f9fa !important;
    border-color: var(--form-border-default) !important;
}

/* Fix Alpine.js x-model inputs */
[x-model] {
    border: 1px solid var(--form-border-default) !important;
}

/* Ensure all form controls in modals have borders */
.modal .form-control,
.modal input,
.modal textarea,
.modal select {
    border: 1px solid var(--form-border-default) !important;
}

/* Fix for dynamically added inputs */
.form-control:not([class*="border-0"]) {
    border: 1px solid var(--form-border-default) !important;
}