.filter-panel {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Error styling for filter loading errors */
.filter-error {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
  color: #dc2626;
  font-size: 0.75rem;
}

.filter-error svg {
  flex-shrink: 0;
}

.filter-panel-mobile {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-fixed);
  border-radius: 0;
  height: 100vh;
  animation: slideInFromRight 0.3s ease-out;
}

.filter-panel-closing {
  animation: slideOutToRight 0.15s ease-in;
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideOutToRight {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(100%);
  }
}

.filter-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: -1;
}

.filter-content {
  background: white;
  height: 100%;
  display: flex;
  flex-direction: column;
  margin-left: auto;
  width: 100%;
  max-width: 400px;
  box-sizing: border-box;
  min-width: 0;
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f7fafc;
}

.filter-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1a1a1a;
}

.filter-title svg {
  font-size: 1.25rem;
  color: #2c5282;
}

.filter-title h3 {
  margin: 0;
  font-size: 1.125rem;
}

.filter-count {
  background: #2c5282;
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
  font-weight: 500;
}

.filter-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.filter-reset-btn {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  background: none;
  border: 1px solid #e2e8f0;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #4a5568;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-reset-btn svg {
  font-size: 0.875rem;
}

.filter-reset-btn:hover:not(:disabled) {
  background: #f7fafc;
  border-color: #cbd5e0;
  color: #2c5282;
}

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

.filter-close-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: #718096;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  transition: color 0.2s ease;
}

.filter-close-btn:hover {
  color: #1a1a1a;
}

.filter-sections {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0;
}

.filter-section {
  border-bottom: 1px solid #f7fafc;
}

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

.filter-section-header {
  width: 100%;
  background: none;
  border: none;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.9375rem;
  font-weight: 500;
  color: #1a1a1a;
  text-align: left;
  position: relative;
}

.filter-section-header.expanded {
  background-color: #f7fafc;
  font-weight: 600;
}

.filter-section-header.expanded::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 4px;
  height: 100%;
  background-color: #2c5282;
}

.filter-section-header:hover {
  background-color: #f7fafc;
}

.filter-section-header svg {
  color: #718096;
  font-size: 1.125rem;
}

.filter-section-content {
  padding: 0 1.25rem 1rem;
}

.filter-group {
  margin-bottom: 1rem;
}

.filter-group:last-child {
  margin-bottom: 0;
}

.filter-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4a5568;
  margin-bottom: 0.5rem;
}

.filter-group input,
.filter-group select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #1a1a1a;
  background: white;
  transition: border-color 0.2s ease;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #2c5282;
  box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1);
}

.range-inputs {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.range-inputs input,
.range-inputs select {
  flex: 1;
}

.input-wrapper {
  flex: 1;
  position: relative;
}

.range-separator {
  padding: 0.5rem 0;
  color: #718096;
  font-size: 0.875rem;
  flex-shrink: 0;
}

/* Validation Styles */
.filter-group input.error,
.filter-group select.error {
  border-color: var(--error-color, #dc3545);
}

.error-message {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  color: var(--error-color, #dc3545);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  line-height: 1.5;
}

.error-message svg {
  flex-shrink: 0;
  font-size: 0.875rem;
}

.input-wrapper .error-message {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  font-size: 0.875rem;
  flex-shrink: 0;
  z-index: 10;
}

.filter-active-section {
  border-bottom: 1px solid #e2e8f0;
  background: #fafbfc;
}

.filter-panel-active {
  margin: 0;
  border: none;
  background: transparent;
  padding: 0.75rem 1.25rem;
}

.filter-panel-active .active-filters-header {
  margin-bottom: 0.5rem;
}

.filter-panel-active .active-filters-title {
  font-size: 0.8125rem;
}

.filter-panel-active .clear-all-filters-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

.filter-panel-active .active-filter-tag {
  font-size: 0.8125rem;
  padding: 0.25rem 0.5rem;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .filter-panel:not(.filter-panel-mobile) {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-fixed);
    border-radius: 0;
  }

  .filter-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 1rem 1.25rem;
  }
  
  .filter-sections {
    padding: 0;
  }
  
  .filter-section-header {
    padding: 1.25rem 1.5rem;
    font-size: 1rem;
  }
  
  .filter-section-content {
    padding: 0 1.5rem 1.25rem;
  }
  
  .filter-btn-text {
    display: none;
  }
  
  .filter-reset-btn {
    padding: 0.5rem;
    border-radius: 0.5rem;
  }
  
  .filter-close-btn {
    padding: 0.75rem;
    font-size: 1.5rem;
  }
}

/* Ultra-small devices (<=400px) to avoid overflow */
@media (max-width: 400px) {
  .filter-content {
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
  }

  .filter-header,
  .filter-section-header,
  .filter-section-content {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .range-inputs {
    flex-direction: column;
    gap: 0.75rem;
  }
}

/* Touch-friendly tap targets for mobile */
@media (max-width: 768px) and (pointer: coarse) {
  .filter-section-header {
    min-height: 48px;
    padding: 1rem 1.5rem;
  }
  
  .filter-reset-btn,
  .filter-close-btn {
    min-width: 44px;
    min-height: 44px;
  }
  
  .filter-group input,
  .filter-group select {
    min-height: 44px;
    padding: 0.75rem;
    font-size: 1rem;
  }
}

/* Enhanced mobile drawer behavior */
@media (max-width: 480px) {
  .filter-panel-mobile .filter-content {
    width: 100vw;
    max-width: none;
  }
  
  .filter-header {
    padding: 1rem;
  }
  
  .filter-title {
    font-size: 1rem;
  }
  
  .filter-section-header {
    padding: 1rem;
    font-size: 0.9375rem;
  }
  
  .filter-section-content {
    padding: 0 1rem 1rem;
  }
  
  .range-inputs {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .range-separator {
    display: none;
  }
  
  .filter-group input,
  .filter-group select {
    padding: 1rem 0.75rem;
    font-size: 1rem;
  }
}

/* Scrollable content area for mobile */
@media (max-width: 768px) {
  .filter-sections {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  
  .filter-sections::-webkit-scrollbar {
    display: none;
  }
}

/* Range Slider Integration Styles */
.filter-range-slider {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start; /* Left-align on desktop */
}

.filter-range-slider .range-slider-label {
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
}

.filter-range-slider .range-slider-container {
  margin: 1.5rem 0 2rem 0;
  align-self: stretch; /* Take full width of parent container */
}

.filter-range-slider .range-slider-track {
  background-color: #e5e7eb;
}

.filter-range-slider .range-slider-track-active {
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.filter-range-slider .range-slider-thumb {
  background: #3b82f6;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.filter-range-slider .range-slider-thumb:hover {
  background: #2563eb;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.filter-range-slider .range-slider-thumb:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.filter-range-slider .range-slider-tooltip {
  background: #1f2937;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 500;
}

.filter-range-slider .range-slider-tooltip::after {
  border-top-color: #1f2937;
}

.filter-range-slider .range-slider-value-display {
  background: #f9fafb;
  color: #374151;
  border: 1px solid #d1d5db;
  font-size: 0.875rem;
}

/* Mobile adjustments for range slider in filters */
@media (max-width: 768px) {
  .filter-range-slider {
    align-items: stretch; /* Full width on mobile */
  }
  
  .filter-range-slider .range-slider-container {
    margin: 2rem 0 2.5rem 0;
    align-self: stretch; /* Ensure full width on mobile */
  }
  
  .filter-range-slider .range-slider-thumb {
    width: 24px;
    height: 24px;
    margin-top: -12px;
    margin-left: -12px;
  }
  
  .filter-range-slider .range-slider-track {
    height: 6px;
  }
  
  .filter-range-slider .range-slider-tooltip {
    font-size: 0.8rem;
    padding: 0.3rem 0.6rem;
  }
}