/* Select Control Enhancement - Global Styles */

/* Base select control styles */
.form-control.rv-auto,
select.form-control {
    /* Ensure consistent sizing */
    box-sizing: border-box;
    min-height: 38px;
    padding: 6px 12px;
    font-size: 14px;
    line-height: 1.42857143;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    /* Prevent size changes */
    width: 100%;
    max-width: 100%;
}

/* Hover state - subtle border color change */
.form-control.rv-auto:hover,
select.form-control:hover {
    border-color: #66afe9;
    cursor: pointer;
}

/* Focus state - highlight without size change */
.form-control.rv-auto:focus,
select.form-control:focus {
    border-color: #66afe9;
    outline: 0;
    box-shadow: 0 0 0 2px rgba(102, 175, 233, 0.3);
    /* DO NOT change size - keep same dimensions */
    transform: none;
    width: 100%;
    max-width: 100%;
}

/* Prevent size jumping during focus transitions */
.form-control.rv-auto:focus-visible,
select.form-control:focus-visible {
    outline: 0;
    border-color: #66afe9;
    box-shadow: 0 0 0 2px rgba(102, 175, 233, 0.3);
}

/* Enhanced focus for better visibility */
.select-enhanced {
    position: relative;
}

.select-enhanced:focus-within::after {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid #007bff;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0.8;
    z-index: 1;
}

/* Multi-select enhancement */
.multiple-select-field {
    min-height: 80px;
    resize: vertical;
}

.multiple-select-field:focus {
    min-height: 80px;
    /* Maintain minimum height on focus */
}

/* Dropdown arrow styling for consistency */
select.form-control {
    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 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px 12px;
    padding-right: 40px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* Text input consistency - Enhanced version */
.text-dropdown,
.wide-text,
.form-control.wide-text {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    transition: none !important;
}

/* Additional stability for focus/blur transitions */
.wide-text:focus,
.wide-text:blur,
.form-control.wide-text:focus,
.form-control.wide-text:blur {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    transform: none !important;
    transition: none !important;
}

/* Button enhancements to prevent focus issues */
.btn-dnict,
.btn.btn-primary,
.btn.btn-default {
    /* Prevent immediate focus loss issues */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    pointer-events: auto !important;
    cursor: pointer !important;
    /* Ensure buttons respond immediately */
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-control.rv-auto,
    select.form-control {
        font-size: 16px; /* Prevent zoom on mobile */
        min-height: 44px; /* Touch-friendly size */
    }
}

/* Fix for select2 if used */
.select2-container--default .select2-selection--single {
    height: 38px !important;
    border: 1px solid #ddd !important;
}

.select2-container--default .select2-selection--single:focus,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #66afe9 !important;
    box-shadow: 0 0 0 2px rgba(102, 175, 233, 0.3) !important;
}
