/* Dynamic Filter Styles */
.dynamic-filter-wrapper {
    position: relative;
    width: 100%;
}

.dynamic-filter-search {
    position: relative;
}

.dynamic-filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
    transition: border-color 0.2s ease;
}

.dynamic-filter-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.dynamic-filter-input:disabled {
    background-color: #f8f9fa;
    cursor: not-allowed;
}

.dynamic-filter-input.searching {
    background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="none" stroke="%23007bff" stroke-width="2" opacity="0.3"><animate attributeName="stroke-dasharray" values="0 37.7;18.85 18.85;0 37.7" dur="1s" repeatCount="indefinite"/></circle></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px 16px;
    padding-right: 36px;
}

.dynamic-filter-loading {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6c757d;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.dynamic-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
}

.dynamic-filter-dropdown.show {
    display: block !important;
}

.dynamic-filter-options {
    padding: 0;
}

.dynamic-filter-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.2s ease;
}

.dynamic-filter-option:hover,
.dynamic-filter-option.active {
    background-color: #f8f9fa;
}

.dynamic-filter-option:last-child {
    border-bottom: none;
}

.option-content {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.option-label {
    font-size: 14px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.option-value {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.option-count {
    display: none;
    font-size: 12px;
    color: #6c757d;
    margin-left: 8px;
    flex-shrink: 0;
}

.dynamic-filter-empty {
    padding: 20px 12px;
    text-align: center;
    color: #6c757d;
    font-size: 14px;
    font-style: italic;
}

.empty-search-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.empty-message {
    margin-bottom: 12px;
    font-style: normal;
}

.clear-search-btn {
    background-color: #6c757d;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.clear-search-btn:hover {
    background-color: #5a6268;
}

.dynamic-filter-error {
    padding: 16px 12px;
    text-align: center;
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 4px;
}

.error-icon {
    display: block;
    font-size: 20px;
    margin-bottom: 8px;
}

.error-message {
    display: block;
    font-size: 14px;
    margin-bottom: 12px;
}

.error-retry {
    background-color: #dc3545;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.error-retry:hover {
    background-color: #c82333;
}

.error-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.error-fallback {
    background-color: #6c757d;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

.error-fallback:hover {
    background-color: #5a6268;
}

.dynamic-filter-loading-state {
    padding: 24px 12px;
    text-align: center;
    color: #6c757d;
}

.loading-spinner-large {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 12px;
}

.loading-text {
    font-size: 14px;
}

.fallback-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    margin-top: 4px;
    font-size: 12px;
    color: #856404;
}

.fallback-icon {
    font-size: 14px;
}

.fallback-text {
    flex: 1;
}

.dynamic-filter-input.fallback-mode {
    border-color: #ffc107;
    background-color: #fff3cd;
}

.dynamic-filter-input.fallback-mode:focus {
    border-color: #ffc107;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.25);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .dynamic-filter-dropdown {
        max-height: 200px;
    }

    .dynamic-filter-option {
        padding: 12px;
    }

    .option-label {
        font-size: 16px;
    }
}

/* Integration with existing filter modal styles */
.modal .dynamic-filter-wrapper {
    margin-bottom: 16px;
}

.modal .dynamic-filter-input {
    border-color: #ced4da;
}

.modal .dynamic-filter-dropdown {
    z-index: 1050;
    /* Higher than modal backdrop */
}

/* Dark mode support (if needed) */
@media (prefers-color-scheme: dark) {
    .dynamic-filter-input {
        background-color: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .dynamic-filter-dropdown {
        background-color: #2d3748;
        border-color: #4a5568;
    }

    .dynamic-filter-option {
        color: #e2e8f0;
        border-bottom-color: #4a5568;
    }

    .dynamic-filter-option:hover,
    .dynamic-filter-option.active {
        background-color: #4a5568;
    }

    .option-count {
        color: #a0aec0;
    }

    .dynamic-filter-empty {
        color: #a0aec0;
    }
}
