/**
 * Form Alignment Fixes
 * Fixes select dropdown and form control alignment issues
 */

/* Fix select dropdown alignment */
select.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    
    /* Fix text alignment */
    text-align: left;
    text-indent: 0;
    
    /* Ensure proper height */
    height: auto !important;
    min-height: calc(1.5em + 0.75rem + 2px);
    
    /* Fix appearance on different browsers */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    
    /* Add dropdown arrow */
    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.25rem;
}

/* Focus state */
select.form-control:focus {
    color: #495057;
    background-color: #fff;
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Disabled state */
select.form-control:disabled {
    background-color: #e9ecef;
    opacity: 1;
}

/* Fix option alignment */
select.form-control option {
    padding: 0.375rem 0.75rem;
    text-align: left;
}

/* Fix textarea alignment */
textarea.form-control {
    display: block;
    width: 100%;
    padding: 0.375rem 0.75rem;
    font-size: 1rem;
    font-weight: 400;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.25rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    
    /* Fix text alignment */
    text-align: left;
    
    /* Ensure resize handle doesn't overlap text */
    resize: vertical;
    min-height: calc(1.5em + 0.75rem + 2px);
}

/* Form group spacing */
.form-group {
    margin-bottom: 1rem;
}

/* Label styling */
.form-group label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #212529;
}

/* Required asterisk */
.form-group .required {
    color: #dc3545;
    margin-left: 0.25rem;
}

/* Placeholder text color */
.form-control::placeholder {
    color: #6c757d;
    opacity: 1;
}

/* Fix for Chrome autofill */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:hover,
.form-control:-webkit-autofill:focus {
    -webkit-text-fill-color: #495057;
    -webkit-box-shadow: 0 0 0px 1000px #fff inset;
    transition: background-color 5000s ease-in-out 0s;
}

/* Ensure consistent styling across all form controls */
input.form-control,
select.form-control,
textarea.form-control {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

/* Fix for iOS devices */
@supports (-webkit-touch-callout: none) {
    select.form-control {
        font-size: 16px;
    }
}

/* Responsive adjustments */
@media (max-width: 576px) {
    select.form-control,
    textarea.form-control {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Modern select styling for better UX */
.form-control:not(:disabled):not([readonly]) {
    cursor: pointer;
}

/* Hover effect for select */
select.form-control:not(:disabled):hover {
    border-color: #b3d7ff;
}

/* Fix alignment in card layouts */
.card .form-group:last-child {
    margin-bottom: 0;
}

/* Ensure proper vertical alignment */
.form-group > label {
    vertical-align: middle;
}

/* Fix for inline forms */
.form-inline .form-control {
    display: inline-block;
    width: auto;
    vertical-align: middle;
}

/* Custom select wrapper for additional styling if needed */
.select-wrapper {
    position: relative;
}

.select-wrapper select.form-control {
    position: relative;
    z-index: 1;
}

/* Fix for validation states */
.form-control.is-invalid {
    border-color: #dc3545;
    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-valid {
    border-color: #28a745;
    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='%2328a745' d='M2.3 6.73L.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);
}