/**
 * Accessibility enhancements for filter controls
 * Following Context7 accessibility best practices
 */

/* Enhanced focus indicators for all filter controls */
.filter-group input[type="checkbox"]:focus,
.filter-group button:focus,
#search-input:focus,
#distance-slider:focus,
.quick-filter-btn:focus {
    outline: 3px solid #003DA5;
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(6, 95, 70, 0.1);
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .filter-group input[type="checkbox"]:focus,
    .filter-group button:focus {
        outline: 4px solid currentColor;
        outline-offset: 2px;
    }
}

/* Visual indication for active filters */
.filter-group.has-active-filters {
    position: relative;
}

.filter-group.has-active-filters::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 0;
    bottom: 0;
    width: 4px;
    background-color: #003DA5;
    border-radius: 2px;
}

/* Skip link for keyboard navigation */
.filter-skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 999;
    padding: 0.5rem 1rem;
    background: #003DA5;
    color: white;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}

.filter-skip-link:focus {
    left: 0;
}

/* Improved checkbox styling for better visibility */
.filter-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
    cursor: pointer;
}

.filter-group label {
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 6px 0;
    transition: background-color 0.2s ease;
}

.filter-group label:hover {
    background-color: rgba(6, 95, 70, 0.05);
    margin-left: -8px;
    margin-right: -8px;
    padding-left: 8px;
    padding-right: 8px;
    border-radius: 4px;
}

/* Clear visual state for toggle buttons */
.quick-filter-btn[aria-pressed="true"] {
    background-color: #003DA5;
    color: white;
    font-weight: 600;
}

.quick-filter-btn[aria-pressed="false"] {
    background-color: #f3f4f6;
    color: #374151;
}

/* Loading states for filters */
.filter-group.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.filter-group.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #003DA5;
    border-top-color: transparent;
    border-radius: 50%;
    animation: filter-spin 0.8s linear infinite;
}

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

/* Error states */
.filter-error {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-error::before {
    content: '⚠️';
}

/* Success feedback */
.filter-success {
    color: #8B5CF6;
    font-size: 0.875rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-success::before {
    content: '✓';
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .filter-group label,
    .quick-filter-btn {
        transition: none;
    }
    
    @keyframes filter-spin {
        to { transform: none; }
    }
}

/* Touch target improvements for mobile */
@media (max-width: 768px) {
    .filter-group label {
        min-height: 44px; /* iOS recommended touch target */
        padding: 10px 0;
    }
    
    .quick-filter-btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .filter-group input[type="checkbox"] {
        width: 24px;
        height: 24px;
    }
}

/* Screen reader only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focus visible polyfill for better browser support */
.js-focus-visible :focus:not(.focus-visible) {
    outline: none;
}

.js-focus-visible .focus-visible {
    outline: 3px solid #003DA5;
    outline-offset: 2px;
}