/* CWO Esoteric Form Dropdown Fixes */

/* Fix for all dropdown select elements */
select, 
.form-control select,
.form-select {
    /* Ensure proper height and visibility */
    height: auto !important;
    min-height: 2.25rem !important;
    line-height: 1.4 !important;
    
    /* Reset any problematic styling */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    
    /* Ensure proper padding and spacing */
    padding: 8px 12px !important;
    
    /* Background and borders */
    background-color: white !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 5 6 6 6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 16px 12px !important;
    
    border: 2px solid #e0e0e0 !important;
    border-radius: 6px !important;
    
    /* Text styling */
    color: var(--dark, #2C1810) !important;
    font-size: 16px !important;
    font-weight: normal !important;
    
    /* Cursor */
    cursor: pointer !important;
}

/* Focus state for dropdowns */
select:focus, 
.form-control select:focus,
.form-select:focus {
    border-color: var(--primary, #B22222) !important;
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(178, 34, 34, 0.1) !important;
}

/* Option styling to ensure visibility */
select option {
    background-color: white !important;
    color: var(--dark, #2C1810) !important;
    padding: 8px 12px !important;
    font-size: 16px !important;
    line-height: 1.4 !important;
    min-height: auto !important;
    display: block !important;
    white-space: nowrap !important;
}

/* Hover state for options */
select option:hover {
    background-color: rgba(178, 34, 34, 0.1) !important;
}

/* Selected option styling */
select option:checked,
select option[selected] {
    background-color: var(--primary, #B22222) !important;
    color: white !important;
    font-weight: bold !important;
}

/* Multiple select styling */
select[multiple] {
    height: auto !important;
    min-height: 120px !important;
    background-image: none !important;
    padding: 4px !important;
}

select[multiple] option {
    padding: 4px 8px !important;
    margin: 1px 0 !important;
    border-radius: 3px !important;
}

/* Specific fixes for form rows */
.form-row select,
.form-group select {
    width: 100% !important;
    max-width: 100% !important;
}

/* Fix for Bootstrap and other framework conflicts */
.bootstrap-select .dropdown-toggle,
.bootstrap-select .dropdown-menu {
    font-size: 16px !important;
    line-height: 1.4 !important;
}

/* Fix for Django admin style conflicts */
.aligned .form-row select {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
}

/* Mobile responsive fixes */
@media (max-width: 768px) {
    select, 
    .form-control select,
    .form-select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        min-height: 44px !important; /* Better touch target */
        padding: 12px 16px !important;
    }
    
    select option {
        font-size: 16px !important;
        padding: 12px 16px !important;
    }
}

/* Fix for specific select elements that might be problematic */
#id_post_type,
#id_favorite_cwo,
#comment-sort,
#comment-filter,
select[name*="vote"],
select[name*="type"],
select[name*="category"] {
    /* Force proper display */
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    
    /* Ensure proper dimensions */
    height: auto !important;
    min-height: 2.25rem !important;
    
    /* Reset any transforms or positioning */
    transform: none !important;
    position: relative !important;
    z-index: 1 !important;
}

/* Fix dropdown arrow positioning */
select:not([multiple]):not([size]) {
    background-position: right 12px center !important;
    padding-right: 40px !important;
}

/* Ensure dropdown list appears above other elements */
select:focus {
    z-index: 1000 !important;
}

/* Fix for any overflow issues */
.form-group,
.form-row {
    overflow: visible !important;
}

/* Additional fix for option text visibility */
select option {
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Fix for WebKit browsers (Chrome, Safari) */
select::-webkit-scrollbar {
    width: 12px;
}

select::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 6px;
}

select::-webkit-scrollbar-thumb {
    background: var(--primary, #B22222);
    border-radius: 6px;
    border: 2px solid #f1f1f1;
}

select::-webkit-scrollbar-thumb:hover {
    background: var(--secondary, #DC143C);
}

/* Ensure select elements are not hidden by transforms or other CSS */
select {
    transform: translateZ(0) !important; /* Force hardware acceleration */
}