/*
 * Hide native multi-select to prevent FOUC
 * JavaScript will initialize custom component
 */
select[multiple] {
    display: none !important;
}

/*
 * Multi-Select Dropdown Component Styles
 * Responsive multi-select dropdown with search functionality
 * Extracted from inline styles and improved for mobile-first approach
 */

/* Container */
.multi-select-dropdown {
    position: relative;
    display: inline-block;
    width: 100%;
}

/* Button trigger */
.multi-select-button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.15s ease;
}

.multi-select-button:hover {
    border-color: #9ca3af;
}

.multi-select-button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
    border-color: #3b82f6;
}

.selected-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    color: #374151;
}

.selected-text.placeholder {
    color: #9ca3af;
}

.dropdown-arrow {
    transition: transform 0.2s ease;
    color: #6b7280;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.dropdown-arrow.rotated {
    transform: rotate(180deg);
}

/* Dropdown menu */
.multi-select-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    z-index: 1000;
    margin-top: 2px;
    max-height: 300px;
    overflow-y: auto;
    animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search input */
.multi-select-search {
    padding: 0.5rem;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    background: white;
    z-index: 1;
}

.multi-select-search input {
    width: 100%;
    padding: 0.375rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    transition: border-color 0.15s ease;
}

.multi-select-search input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Options list */
.multi-select-option {
    padding: 0;
    list-style: none;
}

.multi-select-label {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    margin: 0;
    width: 100%;
    transition: background-color 0.15s ease;
    user-select: none;
}

.multi-select-label:hover {
    background-color: #f3f4f6;
}

.multi-select-label input[type="checkbox"] {
    margin-right: 0.5rem;
    width: 1rem;
    height: 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

.multi-select-label span {
    font-size: 0.875rem;
    color: #374151;
}

/* Select all option */
.select-all-option .multi-select-label {
    font-weight: 600;
    background-color: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.select-all-option .multi-select-label:hover {
    background-color: #f3f4f6;
}

/* Divider */
.multi-select-divider {
    margin: 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

/* Actions footer */
.multi-select-actions {
    padding: 0.5rem;
    border-top: 1px solid #e5e7eb;
    position: sticky;
    bottom: 0;
    background: white;
}

.multi-select-clear {
    width: 100%;
    justify-content: center;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    background: white;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    transition: background-color 0.15s ease;
}

.multi-select-clear:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

/* Scrollbar styling */
.multi-select-dropdown-menu {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

.multi-select-dropdown-menu::-webkit-scrollbar {
    width: 8px;
}

.multi-select-dropdown-menu::-webkit-scrollbar-track {
    background: transparent;
}

.multi-select-dropdown-menu::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.multi-select-dropdown-menu::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

/* Responsive adjustments */
@media (max-width: 767px) {
    .multi-select-dropdown-menu {
        max-height: 250px;
    }

    .multi-select-button {
        padding: 0.625rem 0.75rem;
    }

    .multi-select-label {
        padding: 0.625rem 0.75rem;
    }
}

@media (max-width: 639px) {
    .multi-select-dropdown-menu {
        max-height: 200px;
    }

    .multi-select-button {
        font-size: 0.875rem;
    }

    .selected-text {
        font-size: 0.8125rem;
    }

    .multi-select-label span {
        font-size: 0.8125rem;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    .multi-select-label {
        padding: 0.75rem;
        min-height: 44px; /* Minimum touch target size */
    }

    .multi-select-button {
        min-height: 44px;
    }

    .multi-select-label input[type="checkbox"] {
        width: 1.25rem;
        height: 1.25rem;
        margin-right: 0.75rem;
    }
}

/* Loading state */
.multi-select-loading {
    padding: 1rem;
    text-align: center;
    color: #6b7280;
    font-size: 0.875rem;
}

.multi-select-loading::after {
    content: '...';
    animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

/* Empty state */
.multi-select-empty {
    padding: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Disabled state */
.multi-select-button:disabled {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    cursor: not-allowed;
    opacity: 0.6;
}

.multi-select-button:disabled .selected-text {
    color: #9ca3af;
}

/* Focus visible for keyboard navigation */
.multi-select-label:focus-within {
    background-color: #dbeafe;
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

/* Selected count badge */
.selected-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    background-color: #3b82f6;
    color: white;
    font-size: 0.6875rem;
    font-weight: 600;
    border-radius: 9999px;
    margin-left: 0.25rem;
}
