/*
 * select2-dark-mode.css
 * GLOBAL — loaded via base.html for ALL pages.
 * Products app pages that use Select2 dropdowns:
 *   - add_product.html      → Category, Brand, Unit, Supplier selects
 *   - add_subcategory.html  → Main Category select
 *   - add_producttype.html  → Subcategory select
 *
 * Select2 light/dark mode styles: selection box sizing, icon support,
 * dropdown colors, focus states, disabled/multiple states
 * Loaded globally — applies wherever Select2 is used
 *
 * Used in:
 *   templates/base.html (global — all pages)
 */

/* =====================================================
   SELECT2 DARK MODE SUPPORT
   Custom styles to make Select2 work with Bootstrap 5 dark mode
   ===================================================== */

/* Light Mode Styles - Match form controls exactly */
.select2-container--bootstrap-5 {
    width: 100% !important;
}

.select2-container--bootstrap-5 .select2-selection {
    min-height: 48px !important;
    height: 48px !important;
    padding-top: 12px !important;
    padding-bottom: 12px !important;
    padding-left: 12px !important;
    padding-right: 40px !important;
    border-radius: var(--radius-md) !important;
    background-color: var(--background-white) !important;
    border: 2px solid var(--border-color) !important;
    color: var(--text-dark) !important;
}

.select2-container--bootstrap-5 .select2-selection--single {
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    line-height: 24px !important;
    padding-left: 0 !important;
    padding-top: 0 !important;
    padding-right: 4px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    max-width: 100% !important;
    font-size: var(--font-sm) !important;
    color: var(--text-dark) !important;
}

.select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow {
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
}

/* Fix Select2 inside input-with-icon wrapper */
.input-with-icon .select2-container--bootstrap-5 .select2-selection {
    padding-left: 45px !important; /* Matches regular inputs with icons */
}

.input-with-icon .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    padding-left: 0 !important;
    padding-right: 4px !important;
    max-width: 100% !important;
}

/* Ensure icon stays visible with Select2 */
.input-with-icon .input-icon {
    position: absolute;
    left: 12px; /* Matches regular form control padding */
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    z-index: 10;
    pointer-events: none;
}

.input-with-icon {
    position: relative;
}

.input-with-icon .select2-container {
    width: 100% !important;
}

/* Fix for columns with px-0 (no padding) */
.col-3.px-0 .form-outline,
.col-6.px-0 .form-outline {
    padding: 0 10px;
}

/* First column - no left padding */
.col-3.px-0:first-child .form-outline {
    padding-left: 0;
}

/* Last column - no right padding */
.col-3.px-0:last-child .form-outline {
    padding-right: 0;
}

/* Ensure Select2 floating label works like other inputs */
.form-outline:has(.select2-container) .form-label,
.form-outline:has(select.form-control) .form-label {
    /* Keep the floating label design from auth-forms.css */
    z-index: 10 !important; /* Ensure label appears above Select2 */
}

/* Ensure Select2 container doesn't interfere with floating label */
.form-outline .select2-container {
    display: block;
    margin-top: 0;
    position: relative;
    z-index: 1;
}

/* Make sure Select2 selection box doesn't cover the label */
.form-outline .select2-container--bootstrap-5 .select2-selection {
    position: relative;
    z-index: 1;
}

/* Placeholder styles */
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
    color: var(--placeholder-color, #9ca3af) !important;
    font-size: var(--font-sm) !important;
}

/* Dark Mode Styles - Match regular form controls */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
    background-color: var(--background-white) !important;
    border-color: var(--border-color) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
    color: #6b7280 !important;
    font-size: var(--font-sm) !important;
}

/* Dark mode - Selection arrow */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__arrow b {
    border-color: #9ca3af transparent transparent transparent !important;
}

/* Dropdown menu colors - Match form controls */
.select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--background-white) !important;
    border: 2px solid var(--border-color) !important;
    color: var(--text-dark) !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    background-color: var(--background-white) !important;
    border: 2px solid var(--border-color) !important;
    color: var(--text-dark) !important;
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus {
    border-color: var(--primary-green) !important;
    box-shadow: 0 0 0 3px var(--primary-green-light) !important;
}

.select2-container--bootstrap-5 .select2-results__option {
    color: var(--text-dark) !important;
    background-color: var(--background-white) !important;
}

.select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--primary-green) !important;
    color: white !important;
}

.select2-container--bootstrap-5 .select2-results__option[aria-selected=true] {
    background-color: rgba(16, 185, 129, 0.1) !important;
    color: var(--text-dark) !important;
}

/* Dark mode dropdown */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--background-white) !important;
    border-color: var(--border-color) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
    background-color: var(--background-white) !important;
    border-color: var(--border-color) !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option {
    color: #ffffff !important;
    background-color: var(--background-white) !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: var(--primary-green) !important;
    color: white !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option[aria-selected=true] {
    background-color: rgba(16, 185, 129, 0.2) !important;
    color: #ffffff !important;
}

/* Dark mode - Icon color in input-with-icon wrapper */
[data-bs-theme="dark"] .input-with-icon .input-icon {
    color: #9ca3af !important;
}

/* Focus state - Match regular form controls */
.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary-green) !important;
    box-shadow: 0 0 0 3px var(--primary-green-light) !important;
    outline: none !important;
}

/* Dark mode focus - same as regular */
[data-bs-theme="dark"] .select2-container--bootstrap-5.select2-container--focus .select2-selection,
[data-bs-theme="dark"] .select2-container--bootstrap-5.select2-container--open .select2-selection {
    border-color: var(--primary-green) !important;
    box-shadow: 0 0 0 3px var(--primary-green-light) !important;
}

/* Dark mode - Disabled state */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single[aria-disabled=true] {
    background-color: #1a202c;
    border-color: #4a5568;
    color: #718096;
    cursor: not-allowed;
}

/* Dark mode - Multiple select */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple {
    background-color: #2d3748;
    border-color: #4a5568;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
    background-color: #10B981;
    border-color: #059669;
    color: white;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove {
    color: white;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice__remove:hover {
    color: #fca5a5;
}

/* Hide clear button on main selection field */
.select2-container--bootstrap-5 .select2-selection__clear {
    display: none !important;
}

/* Dark mode - No results message */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__message {
    color: #a0aec0;
}

/* Dark mode - Loading indicator */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--loading {
    color: #a0aec0;
}

/* Smooth transitions */
.select2-container--bootstrap-5 .select2-selection,
.select2-container--bootstrap-5 .select2-dropdown,
.select2-container--bootstrap-5 .select2-results__option {
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
