/* ============================================================================
   PERFORMANCE & SEARCH/FILTER UI STYLES
   Optimized for handling large datasets (1000+ members)
   ============================================================================ */

/* ============================================================================
   1. MEMBERS TOOLBAR - Search and Filter Controls
   ============================================================================ */

.members-toolbar {
    padding: 16px 20px;
    border-bottom: var(--border-light);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Search Box */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-tertiary);
    pointer-events: none;
    z-index: 1;
}

.search-input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    background: var(--bg-secondary);
    border: var(--border-light);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-light);
    background: var(--bg-primary);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-clear {
    position: absolute;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: var(--text-tertiary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-clear:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.search-clear svg {
    width: 16px;
    height: 16px;
}

/* Filter Controls */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-select {
    padding: 8px 12px;
    background: var(--bg-secondary);
    border: var(--border-light);
    border-radius: 6px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:hover {
    border-color: var(--brand-primary);
}

.filter-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-light);
}

.sort-order-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sort-order-btn svg {
    transition: transform 0.3s ease;
}

.sort-order-btn:hover svg {
    transform: scale(1.2);
}

/* Results count */
.results-count {
    font-size: 13px;
    color: var(--text-secondary);
    padding: 8px 20px;
    border-bottom: var(--border-light);
    background: var(--bg-hover);
}

.results-highlight {
    color: var(--brand-primary);
    font-weight: 600;
}

/* ============================================================================
   2. PAGINATION CONTROLS
   ============================================================================ */

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-top: var(--border-light);
    background: var(--bg-primary);
}

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: var(--border-light);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-hover);
    border-color: var(--brand-primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: var(--brand-primary);
    color: white;
    border-color: var(--brand-primary);
}

.page-numbers {
    display: flex;
    gap: 4px;
}

.page-number {
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================================================
   3. VIRTUAL SCROLL OPTIMIZATIONS
   ============================================================================ */

.virtual-scroll-viewport {
    overflow: hidden auto;
    height: 100%;
    position: relative;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.virtual-scroll-content {
    position: relative;
    width: 100%;
}

.virtual-scroll-item {
    contain: layout style paint; /* CSS containment for performance */
}

/* Scrollbar styling */
.virtual-scroll-viewport::-webkit-scrollbar {
    width: 8px;
}

.virtual-scroll-viewport::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.virtual-scroll-viewport::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

.virtual-scroll-viewport::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ============================================================================
   4. LOADING INDICATORS
   ============================================================================ */

.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--bg-primary-rgb), 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--bg-hover);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   5. RESPONSIVE LAYOUT
   ============================================================================ */

@media (width >= 768px) {
    .members-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .search-box {
        max-width: 400px;
    }
}

/* Mobile optimization */
@media (width <= 767px) {
    .members-toolbar {
        padding: 12px 16px;
    }

    .filter-controls {
        flex-wrap: wrap;
    }

    .filter-select {
        flex: 1;
        min-width: 120px;
    }

    .pagination {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }

    .pagination-controls {
        justify-content: center;
    }
}

/* ============================================================================
   6. PERFORMANCE HINTS
   ============================================================================ */

/* Use GPU acceleration for frequently updated elements */
.search-input,
.filter-select,
.pagination-btn {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Optimize member list rendering */
.members-list {
    contain: layout style paint;
    will-change: scroll-position;
}

.member-row {
    contain: layout style;
}

/* Remove will-change when not needed */
.members-list:not(:hover) {
    will-change: auto;
}

/* ============================================================================
   7. EMPTY STATES WITH FILTERS
   ============================================================================ */

.empty-state.filtered {
    padding: 40px 20px;
}

.empty-state.filtered .empty-state-icon {
    width: 48px;
    height: 48px;
}

.empty-state.filtered .empty-state-title {
    font-size: 16px;
}

.empty-state.filtered .empty-state-description {
    font-size: 13px;
}

/* ============================================================================
   8. ACCESSIBILITY ENHANCEMENTS
   ============================================================================ */

/* Focus indicators for keyboard navigation */
.search-input:focus-visible,
.filter-select:focus-visible,
.pagination-btn:focus-visible {
    outline: 2px solid var(--brand-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .search-input,
    .filter-select,
    .pagination-btn {
        border-width: 2px;
    }
}

/* ============================================================================
   9. DARK MODE OPTIMIZATIONS
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .search-input:focus {
        box-shadow: 0 0 0 3px rgba(var(--brand-rgb), 0.2);
    }

    .loading-overlay {
        backdrop-filter: blur(4px);
    }

    .virtual-scroll-viewport::-webkit-scrollbar-track {
        background: rgb(0 0 0 / 20%);
    }
}

/* ============================================================================
   10. PRINT STYLES
   ============================================================================ */

@media print {
    .members-toolbar,
    .pagination {
        display: none;
    }

    .members-list {
        overflow: visible !important;
        height: auto !important;
    }
}
