/* Filter Panel Styles */

/* Base panel - no fixed sizing here. The desktop sidebar (.filter-sidebar)
   and the mobile fullscreen modal (.filter-modal-content) each define
   their own outer positioning/scrolling; the panel just fills them. */
.filter-panel {
  background: var(--color-bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-bg-primary);
  z-index: 10;
}

.filter-header h4 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--color-text-primary);
}

.filter-panel-toggle {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.filter-toggle-icon {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  transition: transform var(--transition-base);
  display: inline-block;
}

.filter-panel.collapsed .filter-toggle-icon {
  transform: rotate(-90deg);
}

.filter-panel.collapsed .filter-content {
  display: none;
}

.reset-filters {
  padding: var(--spacing-xs) var(--spacing-sm);
  font-size: 0.75rem;
  color: var(--color-accent);
  background: transparent;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.reset-filters:hover {
  background: var(--color-accent-light);
  border-color: var(--color-accent-dark);
}

.filter-content {
  padding: var(--spacing-md);
}

/* Filter Groups */
.filter-group {
  margin-bottom: var(--spacing-lg);
  border-bottom: 1px solid var(--color-border-light);
  padding-bottom: var(--spacing-md);
}

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

/* Filter Labels */
.filter-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
}

.filter-label:hover {
  background: var(--color-bg-secondary);
}

.filter-collapse-btn {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
  transition: transform var(--transition-base), background var(--transition-base);
}

.filter-collapse-btn:hover {
  background: var(--color-border-light);
}

.filter-group.collapsed .filter-collapse-btn {
  transform: rotate(-90deg);
}

.filter-group.collapsed .filter-subcategories {
  display: none;
}

.filter-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--color-accent);
}

.filter-icon {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.filter-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.filter-subicon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.filter-subicon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.filter-name {
  flex: 1;
  font-weight: 500;
  color: var(--color-text-primary);
}

.filter-count {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-left: var(--spacing-sm);
}

/* Subcategories */
.filter-subcategories {
  margin-top: var(--spacing-sm);
  margin-left: var(--spacing-lg);
  padding-left: var(--spacing-md);
  border-left: 2px solid var(--color-border-light);
}

.filter-sublabel {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-sm);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  user-select: none;
  font-size: 0.9rem;
}

.filter-sublabel:hover {
  background: var(--color-bg-secondary);
}

.filter-sublabel input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.filter-sublabel .count {
  font-size: 0.7rem;
  color: var(--color-text-secondary);
}

/* Toggle Switch (Alternative) */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) var(--spacing-md);
  cursor: pointer;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--transition-base);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch.active {
  background: var(--color-accent);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: left var(--transition-base);
}

.toggle-switch.active::after {
  left: 22px;
}

/* Filter Sidebar (Desktop Layout) - the only place this fixed box/scroll
   is used. The mobile modal below manages its own fullscreen layout. */
.filter-sidebar {
  position: fixed;
  left: 20px;
  top: 20px;
  width: 280px;
  height: auto;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  z-index: 20;
}

/* Filter Button (Mobile Layout) */
.filter-btn-mobile {
  position: fixed;
  bottom: 20px;
  left: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--color-accent);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 25;
  font-size: 1.5rem;
  transition: all var(--transition-base);
}

.filter-btn-mobile:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-lg);
}

.filter-btn-mobile:active {
  transform: scale(0.95);
}

/* Mobile Filter Modal - a genuine fullscreen overlay. A bottom sheet
   capped at 80vh left too little room for the icon grid and made the
   "is this actually open?" experience unclear on small phones. */
.filter-modal {
  display: none;
  position: fixed;
  inset: 0;
  /* height/width as belt-and-suspenders alongside inset:0 - some mobile
     browsers only recompute vh-based sizing (not inset) when the address
     bar/toolbar show or hide, which is what caused content to look cut
     off at the bottom. dvh tracks the *actual* visible viewport. */
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  /* Most robust: a real pixel value computed from window.innerHeight
     (set in index.html/Karte.fluid.html), applied last so it wins over
     the vh/dvh guesses above where supported. */
  height: calc(var(--app-vh, 1vh) * 100);
  background: var(--color-bg-primary);
  z-index: 30;
  animation: fadeIn 0.2s ease-out;
}

.filter-modal.active {
  display: block;
}

.filter-modal-content {
  width: 100%;
  height: 100%;
  background: var(--color-bg-primary);
  overflow-y: auto;
  padding-top: 64px;
  box-sizing: border-box;
  animation: slideUp 0.25s ease-out;
}

.filter-modal-content .filter-panel {
  border-radius: 0;
  box-shadow: none;
}

.filter-modal-close {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-bg-primary);
  box-shadow: var(--shadow-md);
  font-size: 1.5rem;
  line-height: 1;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 31;
}

.filter-modal-close:hover {
  color: var(--color-text-primary);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Responsive Breakpoints */
@media (max-width: 992px) {
  .filter-sidebar {
    display: none;
  }

  .filter-btn-mobile {
    display: flex;
  }
}

@media (min-width: 993px) {
  .filter-btn-mobile {
    display: none;
  }

  .filter-modal {
    display: none !important;
  }

  .filter-sidebar {
    display: block;
  }
}

/* Filter Count Badge */
.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--color-error);
  color: white;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  margin-left: var(--spacing-sm);
}

.filter-btn-mobile .filter-badge {
  position: absolute;
  top: -8px;
  right: -8px;
}

/* Empty State */
.filter-empty {
  padding: var(--spacing-lg);
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
}

/* Loading State */
.filter-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-lg);
}

.filter-loading .spinner {
  width: 24px;
  height: 24px;
}
