/* Form Control Size Consistency Fixes */
/* This file ensures all inputs, selects, and dropdowns have consistent sizing across the site */

/* Base form control sizing - standardize to modern form height */
.form-control,
input[type="text"],
input[type="password"], 
input[type="email"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="search"],
input[type="date"],
input[type="datetime"],
input[type="datetime-local"],
input[type="time"],
input[type="month"],
input[type="week"],
select,
textarea {
    min-height: 4.50rem !important; /* 72px - matches modern forms */
    padding: 0.9375rem !important; /* 15px - matches modern forms */
    font-size: 1.5625rem !important; /* 25px - matches modern forms */
    line-height: 1.5 !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    box-sizing: border-box !important;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out !important;
}

/* Focus states */
.form-control:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
input[type="date"]:focus,
input[type="datetime"]:focus,
input[type="datetime-local"]:focus,
input[type="time"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
select:focus,
textarea:focus {
    border-color: #667eea !important;
    outline: 0 !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25) !important;
}

/* Select dropdown specific fixes */
select.form-control,
select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
    background-position: right 0.75rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.5em 1.5em !important;
    padding-right: 2.5rem !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
}

/* Chosen plugin dropdown fixes */
.chzn-container-single .chzn-single {
    min-height: 4.50rem !important;
    height: 4.50rem !important;
    padding: 0.9375rem !important;
    font-size: 1.5625rem !important;
    line-height: 1.5 !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    background: #fff !important;
    box-shadow: none !important;
}

.chzn-container-single .chzn-single div {
    width: 2.5rem !important;
    height: 4.50rem !important;
    background: transparent !important;
    border-left: none !important;
}

.chzn-container-single .chzn-single div b {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e") !important;
    background-size: 1.5em 1.5em !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    width: 100% !important;
    height: 100% !important;
}

.chzn-container-single .chzn-single:hover {
    border-color: #667eea !important;
}

.chzn-container-active .chzn-single {
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25) !important;
}

/* Multi-select chosen fixes */
.chzn-container-multi .chzn-choices {
    min-height: 4.50rem !important;
    padding: 0.5rem !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
    background: #fff !important;
    box-shadow: none !important;
}

.chzn-container-active .chzn-choices {
    border-color: #667eea !important;
    box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.25) !important;
}

/* Input group fixes */
.input-group .form-control,
.input-group input,
.input-group select {
    min-height: 4.50rem !important;
}

.input-group-text {
    min-height: 4.50rem !important;
    padding: 0.9375rem !important;
    font-size: 1.5625rem !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
}

/* Button sizing to match form controls */
.btn {
    line-height: 1.5 !important;
    border-radius: 8px !important;
}

/* Textarea specific fixes */
textarea.form-control,
textarea {
    min-height: 6rem !important; /* Slightly taller for textareas */
    resize: vertical !important;
}

/* File input fixes */
input[type="file"] {
    min-height: 4.50rem !important;
    padding: 0.9375rem !important;
}

/* Custom file upload fixes */
.customfile-input {
    min-height: 4.50rem !important;
    padding: 0.9375rem !important;
    font-size: 1.5625rem !important;
    border: 2px solid #e9ecef !important;
    border-radius: 8px !important;
}

.customfile-button {
    min-height: 4.50rem !important;
    padding: 0.9375rem 1rem !important;
    font-size: 1.5625rem !important;
    border: 2px solid #e9ecef !important;
    border-radius: 0 8px 8px 0 !important;
}

/* Disabled state consistency */
.form-control:disabled,
.form-control[readonly],
input:disabled,
input[readonly],
select:disabled,
select[readonly],
textarea:disabled,
textarea[readonly] {
    background-color: #f8f9fa !important;
    opacity: 1 !important;
    border-color: #e9ecef !important;
}

/* Error state consistency */
.form-control.is-invalid,
.form-control.error,
input.error,
select.error,
textarea.error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Success state consistency */
.form-control.is-valid,
.form-control.valid,
input.valid,
select.valid,
textarea.valid {
    border-color: #28a745 !important;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25) !important;
}

/* Specific overrides for legacy form elements */
input[type='text'] {
    width: 100%; /* Override the fixed width from forms.css */
}

/* Grid column form controls */
._25 input, ._50 input, ._75 input, ._100 input,
._25 select, ._50 select, ._75 select, ._100 select,
._25 textarea, ._50 textarea, ._75 textarea, ._100 textarea {
    width: 100% !important;
    min-height: 4.50rem !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-control,
    input[type="text"],
    input[type="password"], 
    input[type="email"],
    input[type="number"],
    input[type="tel"],
    input[type="url"],
    input[type="search"],
    input[type="date"],
    input[type="datetime"],
    input[type="datetime-local"],
    input[type="time"],
    input[type="month"],
    input[type="week"],
    select,
    textarea {
        font-size: 1.25rem !important; /* Slightly smaller on mobile */
        padding: 0.75rem !important;
        min-height: 3.75rem !important;
    }
    
    .btn {
        min-height: 3.75rem !important;
        padding: 0.75rem 1.5rem !important;
        font-size: 1.25rem !important;
    }
    
    .chzn-container-single .chzn-single {
        min-height: 3.75rem !important;
        height: 3.75rem !important;
        padding: 0.75rem !important;
        font-size: 1.25rem !important;
    }
    
    .chzn-container-single .chzn-single div {
        height: 3.75rem !important;
    }
    
    .chzn-container-multi .chzn-choices {
        min-height: 3.75rem !important;
    }
}

/* Print styles - ensure form controls are visible when printing */
@media print {
    .form-control,
    input,
    select,
    textarea {
        border: 1px solid #000 !important;
        background: transparent !important;
        box-shadow: none !important;
    }
}
