/* Universal Select Box Fixes - Works across all themes */

/* Increase max-width for all pages content */
.max-w-7xl {
    max-width: 90rem !important;
}

/* Base select styling for all themes - STANDARDIZED DESIGN */
select,
.form-select,
.custom-select,
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-color: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    font-weight: 500;
    color: #374151;
    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 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    transition: all 0.15s ease-in-out;
    cursor: pointer;
    width: 100%;
    /* Remove any default shadows for consistency */
    box-shadow: none !important;
}

/* Hover states - Remove background change, only border color */
select:hover,
.form-select:hover,
.custom-select:hover,
select.form-control:hover {
    border-color: #d1d5db;
    /* background-color: #f9fafb; REMOVED */
}

/* Focus states */
select:focus,
.form-select:focus,
.custom-select:focus,
select.form-control:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background-color: white;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    select,
    .form-select,
    .custom-select,
    select.form-control {
        background-color: #1f2937;
        border-color: #374151;
        color: #f9fafb;
        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='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    }
    
    select:hover,
    .form-select:hover,
    .custom-select:hover,
    select.form-control:hover {
        border-color: #4b5563;
        /* background-color: #374151; REMOVED */
    }
    
    select:focus,
    .form-select:focus,
    .custom-select:focus,
    select.form-control:focus {
        border-color: #6366f1;
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
        background-color: #1f2937;
    }
}

/* Dark mode class support */
.dark select,
.dark .form-select,
.dark .custom-select,
.dark select.form-control {
    background-color: #1f2937;
    border-color: #374151;
    color: #f9fafb;
    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='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
}

.dark select:hover,
.dark .form-select:hover,
.dark .custom-select:hover,
.dark select.form-control:hover {
    border-color: #4b5563;
    /* background-color: #374151; REMOVED */
}

.dark select:focus,
.dark .form-select:focus,
.dark .custom-select:focus,
.dark select.form-control:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background-color: #1f2937;
}

/* Multiple select styling */
select[multiple],
.form-select[multiple],
.custom-select[multiple],
select.form-control[multiple] {
    min-height: 100px;
    padding: 0.75rem;
    background-image: none;
}

select[multiple] option,
.form-select[multiple] option,
.custom-select[multiple] option,
select.form-control[multiple] option {
    padding: 0.5rem;
    margin: 0.25rem 0;
}

/* Disabled state */
select:disabled,
.form-select:disabled,
.custom-select:disabled,
select.form-control:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
    opacity: 0.7;
}

.dark select:disabled,
.dark .form-select:disabled,
.dark .custom-select:disabled,
.dark select.form-control:disabled {
    background-color: #374151;
    color: #6b7280;
}

/* Error state */
select.error,
select.is-invalid,
.form-select.error,
.form-select.is-invalid,
.custom-select.error,
.custom-select.is-invalid,
select.form-control.error,
select.form-control.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Success state */
select.success,
select.is-valid,
.form-select.success,
.form-select.is-valid,
.custom-select.success,
.custom-select.is-valid,
select.form-control.success,
select.form-control.is-valid {
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

/* Size variations */
select.form-select-sm,
.form-select.form-select-sm,
.custom-select.form-select-sm,
select.form-control.form-select-sm {
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    font-size: 0.75rem;
    border-radius: 0.375rem;
}

select.form-select-lg,
.form-select.form-select-lg,
.custom-select.form-select-lg,
select.form-control.form-select-lg {
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    font-size: 1rem;
    border-radius: 0.75rem;
}

/* Inline forms */
.form-inline select,
.input-group select {
    display: inline-block;
    width: auto;
}

/* Input group styling */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    width: 100%;
}

.input-group select {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
}

.input-group-append select,
.input-group-prepend select {
    border-radius: 0;
}

.input-group-append:last-child select,
.input-group-prepend:first-child select {
    border-radius: 0.5rem;
}

/* Responsive design */
@media (max-width: 640px) {
    select,
    .form-select,
    .custom-select,
    select.form-control {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.75rem 2.5rem 0.75rem 0.75rem;
    }
    
    select[multiple],
    .form-select[multiple],
    .custom-select[multiple],
    select.form-control[multiple] {
        min-height: 100px;
    }
}

/* Table inline selects */
.table select,
table select {
    padding: 0.25rem 1.5rem 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 0.25rem;
}

/* Card and modal selects */
.card select,
.modal select {
    border-color: #e5e7eb;
    background-color: white;
}

.dark .card select,
.dark .modal select {
    border-color: #374151;
    background-color: #1f2937;
}

/* Django admin specific overrides */
.admin select,
.admin .form-select,
.admin .select2-container--default .select2-selection--single {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-color: white !important;
    border: 1px solid #e5e7eb !important;
    border-radius: 0.5rem !important;
    padding: 0.5rem 2.5rem 0.5rem 0.75rem !important;
    font-size: 0.875rem !important;
    color: #374151 !important;
    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") !important;
    background-position: right 0.5rem center !important;
    background-repeat: no-repeat !important;
    background-size: 1.5em 1.5em !important;
}

/* Select2 integration */
.select2-container--default .select2-selection--single {
    border: 1px solid #e5e7eb !important;
    border-radius: 0.5rem !important;
    height: 40px !important;
    background-color: white !important;
    display: flex !important;
    align-items: center !important;
}

.select2-selection__rendered {
    padding: 0 !important;
    line-height: 40px !important;
    color: #374151 !important;
}

.select2-selection__arrow {
    height: 38px !important;
    right: 8px !important;
}

.select2-container--default.select2-container--open .select2-selection--single {
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1) !important;
}
