/**
 * Modern Select2 Styling
 * A beautiful, consistent Select2 theme for the entire application
 * 
 * Features:
 * - Clean, modern design with rounded corners
 * - Customizable accent colors via CSS variables
 * - Smooth transitions and hover effects
 * - Consistent typography using Inter font family
 * - Custom scrollbars
 * - Support for single and multiple select
 * - DataTable footer integration
 * - Responsive design
 * - Light theme with commented dark mode support
 */

/* ==========================================================================
   CSS Custom Properties (Variables) for Theme Customization
   ========================================================================== */

:root {
    /* Default theme colors - can be overridden per page */
    --select2-primary-color: #3b82f6;        /* Blue - default primary */
    --select2-primary-hover: #2563eb;        /* Darker blue for hover */
    --select2-primary-light: #eff6ff;        /* Light blue for backgrounds */
    --select2-primary-ring: rgba(59, 130, 246, 0.1); /* Focus ring */
    
    /* Neutral colors */
    --select2-border-color: #d1d5db;         /* Default border */
    --select2-border-hover: #9ca3af;         /* Hover border */
    --select2-text-color: #374151;           /* Main text */
    --select2-placeholder-color: #9ca3af;    /* Placeholder text */
    --select2-background: #ffffff;           /* Background */
    --select2-disabled-bg: #f9fafb;          /* Disabled background */
    --select2-disabled-border: #e5e7eb;      /* Disabled border */
    --select2-disabled-text: #6b7280;        /* Disabled text */
}

/* ==========================================================================
   Base Select2 Container
   ========================================================================== */

.select2-container {
    width: 100% !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
}

/* ==========================================================================
   Single Select Styling
   ========================================================================== */

.select2-container--default .select2-selection--single {
    background-color: var(--select2-background) !important;
    border: 1px solid var(--select2-border-color) !important;
    border-radius: 6px !important;
    height: 40px !important;
    padding: 0 !important;
    transition: all 0.2s ease !important;
    font-size: 0.875rem !important;
}

.select2-container--default .select2-selection--single:hover {
    border-color: var(--select2-border-hover) !important;
}

.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--select2-primary-color) !important;
    box-shadow: 0 0 0 3px var(--select2-primary-ring) !important;
    outline: none !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--select2-text-color) !important;
    line-height: 38px !important;
    padding-left: 12px !important;
    padding-right: 40px !important;
    font-size: 0.875rem !important;
}

.select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: var(--select2-placeholder-color) !important;
    font-style: normal !important;
}

/* Arrow styling */
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px !important;
    right: 12px !important;
    width: 20px !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--select2-text-color) transparent transparent transparent !important;
    border-style: solid !important;
    border-width: 5px 4px 0 4px !important;
    height: 0 !important;
    left: 50% !important;
    margin-left: -4px !important;
    margin-top: -2px !important;
    position: absolute !important;
    top: 50% !important;
    width: 0 !important;
}

.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
    border-color: transparent transparent var(--select2-text-color) transparent !important;
    border-width: 0 4px 5px 4px !important;
}

/* ==========================================================================
   Dropdown Styling
   ========================================================================== */

.select2-dropdown {
    background-color: var(--select2-background) !important;
    border: 1px solid var(--select2-border-color) !important;
    border-radius: 6px !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    margin-top: 4px !important;
    z-index: 9999 !important;
    color: var(--select2-text-color) !important;
}

.select2-container--default .select2-search--dropdown {
    padding: 8px !important;
    background: #f8fafc !important;
    border-bottom: 1px solid #e2e8f0 !important;
    border-radius: 6px 6px 0 0 !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
    background: var(--select2-background) !important;
    border: 1px solid var(--select2-border-color) !important;
    border-radius: 4px !important;
    padding: 6px 10px !important;
    font-size: 0.875rem !important;
    color: var(--select2-text-color) !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--select2-primary-color) !important;
    box-shadow: 0 0 0 2px var(--select2-primary-ring) !important;
    outline: none !important;
}

/* ==========================================================================
   Results/Options Styling
   ========================================================================== */

.select2-container--default .select2-results > .select2-results__options {
    max-height: 200px !important;
    overflow-y: auto !important;
    padding: 4px 0 !important;
}

.select2-container--default .select2-results__option {
    padding: 8px 12px !important;
    font-size: 0.875rem !important;
    color: var(--select2-text-color) !important;
    cursor: pointer !important;
    transition: all 0.15s ease !important;
}

.select2-container--default .select2-results__option:hover,
.select2-container--default .select2-results__option--highlighted {
    background-color: var(--select2-primary-light) !important;
    color: var(--select2-primary-color) !important;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--select2-primary-color) !important;
    color: white !important;
}

.select2-container--default .select2-results__option[aria-selected=true]:hover {
    background-color: var(--select2-primary-hover) !important;
}

.select2-container--default .select2-results__option--disabled {
    color: var(--select2-disabled-text) !important;
    cursor: not-allowed !important;
}

.select2-container--default .select2-results__message {
    padding: 8px 12px !important;
    color: var(--select2-placeholder-color) !important;
    font-size: 0.875rem !important;
}

/* ==========================================================================
   Multiple Select Styling
   ========================================================================== */

.select2-container--default .select2-selection--multiple {
    background-color: var(--select2-background) !important;
    border: 1px solid var(--select2-border-color) !important;
    border-radius: 6px !important;
    padding: 4px 8px !important;
    min-height: 40px !important;
    transition: all 0.2s ease !important;
}

.select2-container--default .select2-selection--multiple:hover {
    border-color: var(--select2-border-hover) !important;
}

.select2-container--default.select2-container--focus .select2-selection--multiple {
    border-color: var(--select2-primary-color) !important;
    box-shadow: 0 0 0 3px var(--select2-primary-ring) !important;
    outline: none !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--select2-primary-light) !important;
    border: 1px solid var(--select2-primary-color) !important;
    border-radius: 4px !important;
    color: var(--select2-primary-color) !important;
    font-size: 0.75rem !important;
    font-weight: 500 !important;
    padding: 2px 8px 2px 24px !important;
    margin: 2px !important;
    position: relative !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice:hover {
    background-color: var(--select2-primary-color) !important;
    color: white !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--select2-primary-color) !important;
    font-weight: bold !important;
    font-size: 1rem !important;
    margin: 0 !important;
    cursor: pointer !important;
    transition: color 0.15s ease !important;
    position: absolute !important;
    left: 6px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    width: 12px !important;
    height: 12px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
}

.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: white !important;
}

/* ==========================================================================
   Custom Scrollbar
   ========================================================================== */

.select2-results__options::-webkit-scrollbar {
    width: 6px !important;
}

.select2-results__options::-webkit-scrollbar-track {
    background: #f1f5f9 !important;
    border-radius: 3px !important;
}

.select2-results__options::-webkit-scrollbar-thumb {
    background: var(--select2-border-color) !important;
    border-radius: 3px !important;
}

.select2-results__options::-webkit-scrollbar-thumb:hover {
    background: var(--select2-border-hover) !important;
}

/* ==========================================================================
   DataTable Footer Integration
   ========================================================================== */

table.dataTable tfoot th .select2-container {
    width: 100% !important;
}

table.dataTable tfoot th .select2-container .select2-selection--single {
    height: 36px !important;
    border: 1px solid var(--select2-border-color) !important;
    border-radius: 6px !important;
}

table.dataTable tfoot th .select2-container .select2-selection--single .select2-selection__rendered {
    line-height: 34px !important;
    padding-left: 10px !important;
    font-size: 0.875rem !important;
}

/* ==========================================================================
   Additional States
   ========================================================================== */

.select2-container--default .select2-results__option--loading {
    color: var(--select2-placeholder-color) !important;
    padding: 8px 12px !important;
}

.select2-container--default .select2-selection--single .select2-selection__clear {
    color: var(--select2-placeholder-color) !important;
    cursor: pointer !important;
    float: right !important;
    font-weight: bold !important;
    margin-right: 10px !important;
    margin-top: 12px !important;
}

.select2-container--default .select2-selection--single .select2-selection__clear:hover {
    color: var(--select2-text-color) !important;
}

/* ==========================================================================
   Size Variants
   ========================================================================== */

/* Small Select2 */
.select2-container--default .select2-selection--single {
    height: 40px !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 38px !important;
    padding-left: 12px !important;
    font-size: 0.875rem !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px !important;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .select2-container--default .select2-selection--single {
        height: 40px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        line-height: 38px !important;
        padding-left: 10px !important;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__arrow {
        height: 38px !important;
    }
    
    .select2-dropdown {
        font-size: 16px !important; /* Prevents zoom on iOS */
    }
    
    .select2-container--default .select2-results__option {
        padding: 12px !important;
        font-size: 16px !important;
    }
}

/* ==========================================================================
   Dark Mode Support (Optional - Add .dark class to enable)
   ========================================================================== */

/*
@media (prefers-color-scheme: dark) {
    .select2-container--default .select2-selection--single {
        background-color: #1f2937 !important;
        border-color: #374151 !important;
        color: #f9fafb !important;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__rendered {
        color: #f9fafb !important;
    }
    
    .select2-container--default .select2-selection--single .select2-selection__placeholder {
        color: #9ca3af !important;
    }
    
    .select2-dropdown {
        background-color: #1f2937 !important;
        border-color: #374151 !important;
    }
    
    .select2-container--default .select2-results__option {
        color: #f9fafb !important;
    }
    
    .select2-container--default .select2-results__option:hover,
    .select2-container--default .select2-results__option--highlighted {
        background-color: #374151 !important;
    }
}
*/

/* Dark mode - Manual activation with .dark class */
.dark .select2-container--default .select2-selection--single {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
    color: #f9fafb !important;
}

.dark .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #f9fafb !important;
}

.dark .select2-container--default .select2-selection--single .select2-selection__placeholder {
    color: #9ca3af !important;
}

.dark .select2-dropdown {
    background-color: #1f2937 !important;
    border-color: #374151 !important;
}

.dark .select2-container--default .select2-results__option {
    color: #f9fafb !important;
    background-color: #1f2937 !important;
}

.dark .select2-container--default .select2-results__option:hover,
.dark .select2-container--default .select2-results__option--highlighted {
    background-color: #374151 !important;
}

.dark .select2-container--default .select2-results > .select2-results__options {
    background-color: #1f2937 !important;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

/* Small variant */
.select2-container.select2-sm .select2-selection--single {
    height: 32px !important;
    font-size: 0.8125rem !important;
}

.select2-container.select2-sm .select2-selection--single .select2-selection__rendered {
    line-height: 30px !important;
    padding-left: 8px !important;
}

.select2-container.select2-sm .select2-selection--single .select2-selection__arrow {
    height: 30px !important;
}

/* Large variant */
.select2-container.select2-lg .select2-selection--single {
    height: 44px !important;
    font-size: 1rem !important;
}

.select2-container.select2-lg .select2-selection--single .select2-selection__rendered {
    line-height: 42px !important;
    padding-left: 16px !important;
}

.select2-container.select2-lg .select2-selection--single .select2-selection__arrow {
    height: 42px !important;
}

/* Error state */
.select2-container.has-error .select2-selection--single {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1) !important;
}

/* Success state */
.select2-container.has-success .select2-selection--single {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1) !important;
} 