/* ===================================
   Enhanced Filter System - Advanced Features
   =================================== */

/* Filter Pills Container with Advanced Features */
.filter-pills-section {
  max-width: 1200px;
  margin: 0 auto var(--youth-spacing-xl);
  padding: 0 var(--youth-spacing-md);
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--resources-bg-warm);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--resources-coral-light);
  padding-top: var(--youth-spacing-md);
  padding-bottom: var(--youth-spacing-md);
}

/* Filter Header with Search Integration */
.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--youth-spacing-md);
  gap: var(--youth-spacing-md);
}

.filter-title {
  font-family: var(--resources-font-heading);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--resources-text-warm);
  margin: 0;
}

.filter-stats {
  font-family: var(--resources-font-base);
  font-size: 0.875rem;
  color: var(--resources-text-warm-secondary);
  background: var(--resources-coral-light);
  padding: var(--youth-spacing-xs) var(--youth-spacing-sm);
  border-radius: 12px;
  font-weight: 600;
}

/* Search Integration - Bloom-style pill */
.filter-search {
  position: relative;
  flex: 1;
  max-width: 320px;
  display: flex;
  align-items: center;
  background: white;
  border: 2px solid #E8DDD5;
  border-radius: 100px;
  padding: 12px 20px 12px 20px;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-search:focus-within {
  border-color: var(--resources-coral);
  box-shadow: 0 4px 24px rgba(255, 107, 91, 0.15);
}

.filter-search-input {
  flex: 1;
  min-width: 0;
  padding: 0;
  border: none;
  padding-left: 0;
  font-family: var(--resources-font-base);
  font-size: 1rem;
  background: transparent;
  color: var(--resources-text-warm);
  outline: none;
}

.filter-search-input::placeholder {
  color: #B5A9A0;
}

.filter-search-icon {
  color: #B5A9A0;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.filter-pills-section .filter-search {
  margin-bottom: var(--youth-spacing-md);
}

@media (max-width: 768px) {
  .filter-search {
    max-width: 100%;
  }
}

/* Enhanced Filter Pills */
.filter-pills-container {
  position: relative;
}

.filter-pills-wrapper {
  display: flex;
  gap: var(--youth-spacing-sm);
  padding: var(--youth-spacing-md) 0;
  overflow-x: auto;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.filter-pills-wrapper::-webkit-scrollbar {
  display: none;
}

/* Enhanced Filter Pill Styles */
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--youth-spacing-xs);
  padding: var(--youth-spacing-sm) var(--youth-spacing-md);
  background: var(--resources-bg-warm-secondary);
  border: 2px solid var(--resources-coral-light);
  border-radius: 24px;
  font-family: var(--resources-font-base);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--resources-text-warm);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

/* Ripple Effect */
.filter-pill::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.filter-pill:active::before {
  width: 300px;
  height: 300px;
}

/* Filter Badge for Count */
.filter-pill__badge {
  background: var(--resources-coral);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  margin-left: var(--youth-spacing-xs);
}

.filter-pill.active .filter-pill__badge {
  background: white;
  color: var(--resources-coral);
}

/* Enhanced Hover States */
.filter-pill:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px rgba(255, 123, 107, 0.25);
  border-color: var(--resources-coral);
}

.filter-pill.active {
  background: var(--resources-coral);
  border-color: var(--resources-coral);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 123, 107, 0.3);
}

.filter-pill.active:hover {
  background: var(--resources-amber);
  border-color: var(--resources-amber);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 6px 16px rgba(244, 162, 97, 0.3);
}

/* Focus States */
.filter-pill:focus-visible {
  outline: 3px solid var(--resources-coral);
  outline-offset: 2px;
}

/* Filter Actions */
.filter-actions {
  display: flex;
  gap: var(--youth-spacing-sm);
  margin-top: var(--youth-spacing-md);
  padding-top: var(--youth-spacing-md);
  border-top: 1px solid var(--resources-coral-light);
}

.filter-btn {
  padding: var(--youth-spacing-sm) var(--youth-spacing-md);
  border-radius: 16px;
  font-family: var(--resources-font-base);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-btn--clear {
  background: var(--resources-bg-warm-secondary);
  color: var(--resources-text-warm);
  border: 1px solid var(--resources-coral-light);
}

.filter-btn--clear:hover {
  background: var(--resources-coral-light);
}

.filter-btn--apply {
  background: var(--resources-coral);
  color: white;
}

.filter-btn--apply:hover {
  background: var(--resources-amber);
  transform: translateY(-1px);
}

/* Active Filters Display */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--youth-spacing-xs);
  margin-top: var(--youth-spacing-sm);
}

.active-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: var(--youth-spacing-xs);
  padding: var(--youth-spacing-xs) var(--youth-spacing-sm);
  background: var(--resources-coral);
  color: white;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
}

.active-filter-tag__remove {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.active-filter-tag__remove:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
  .filter-pills-section {
    padding: var(--youth-spacing-sm);
    margin-bottom: var(--youth-spacing-lg);
  }
  
  .filter-header {
    flex-direction: column;
    align-items: stretch;
    gap: var(--youth-spacing-sm);
  }
  
  .filter-search {
    max-width: none;
  }
  
  .filter-pills-wrapper {
    padding: var(--youth-spacing-sm) 0;
    gap: var(--youth-spacing-xs);
  }
  
  .filter-pill {
    padding: var(--youth-spacing-xs) var(--youth-spacing-sm);
    font-size: 0.8125rem;
  }
  
  .filter-actions {
    flex-direction: column;
  }
  
  .filter-btn {
    width: 100%;
    padding: var(--youth-spacing-md);
  }
}

/* Dark mode adjustments */
html.dark-mode .filter-pills-section {
  background: var(--resources-bg-warm);
  border-bottom-color: var(--resources-coral);
}

html.dark-mode .filter-search-input {
  background: var(--resources-bg-warm-secondary);
  border-color: var(--resources-coral);
  color: var(--resources-text-warm);
}

html.dark-mode .filter-pill {
  background: var(--resources-bg-warm-secondary);
  border-color: var(--resources-coral);
  color: var(--resources-text-warm);
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .filter-pill::before {
    display: none;
  }
  
  .filter-pill {
    transition: none;
  }
  
  .filter-pill:hover {
    transform: none;
  }
}

/* Loading State */
.filter-pills-wrapper.loading {
  opacity: 0.6;
  pointer-events: none;
}

.filter-pills-wrapper.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 2px solid var(--resources-coral);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
  transform: translate(-50%, -50%);
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}
