/* Overlay */
#filter-popup-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1200;
  background: rgba(0,0,0,0.48);
}

/* Popup main container */
.filter-popup {
  background: var(--element-bg, #232325);
  border-radius: 16px;
  padding: 2rem 1.8rem;
  box-shadow: 0 10px 60px 0 rgba(0,0,0,0.40);
  min-width: 410px;
  max-width: 95vw;
  min-height: 400px;
  /*max-height: 80vh;*/
  
 
  position: absolute; 
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-height: 90vh;
  overflow-y: auto;
  scrollbar-gutter: stable;  
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--primary, #E16F39) var(--element-bg, #232325);  
  padding-right: 1em; /* prevents content from hiding under scrollbar */
}

.filter-popup::-webkit-scrollbar {
  width: 8px;
}
.filter-popup::-webkit-scrollbar-thumb {
  background: var(--primary, #E16F39);
  border-radius: 8px;
}
.filter-popup::-webkit-scrollbar-track {
  background: var(--element-bg, #232325);
}
.filter-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
  cursor: move;
}

.filter-popup-header h3 {
  margin: 0;
  font-size: 1.7em;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--button-text, #fff);
}

.filter-popup-header-buttons {
  display: flex;
  gap: 0.5em;
}

.filter-popup-header .btn,
#filter-close, #filter-clear {
  font-size: 1em;
  border: none;
  background: var(--button-bg, #444);
  color: var(--button-text, #fff);
  border-radius: 6px;
  padding: 0.3em 0.9em;
  margin-left: 0.2em;
  cursor: pointer;
  transition: background 0.18s;
}

.filter-popup-header .btn:hover,
#filter-close:hover, #filter-clear:hover {
  background: var(--button-outline, #ffd966);
  color: #222;
}

.filter-popup-body {
  overflow-y: auto;
  padding-right: 8px;
  max-height: 58vh;
}

.filter-group {
  margin-bottom: 1.3em;
  border-bottom: 1px solid #313137;
  transition: all 0.18s;
}



.filter-group .expand-arrow {
  font-size: 1.1em;
  margin-left: 5px;
  transition: transform 0.23s;
  align-items: end;
}

.filter-group:not(.expanded) .expand-arrow {
  transform: rotate(-90deg);
}

.filter-options {
  margin-top: 0.13em;
  margin-bottom: 0.21em;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.21em 2.7em;
  padding-left: 0.6em;
  padding-right: 0.3em;
  transition: max-height 0.23s, opacity 0.18s;
  max-height: 320px;
  opacity: 1;
  overflow: hidden;
}

.filter-group:not(.expanded) .filter-options {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

.filter-options label {
  font-size: 1em;
  color: var(--button-text, #bbb);
  display: flex;
  align-items: center;
  gap: 0.35em;
  cursor: pointer;
  margin-bottom: 0.14em;
}

input[type="checkbox"] {
  width: 1.1em;
  height: 1.1em;
  accent-color: var(--primary, #E16F39);
  margin-right: 0.34em;
}

.filter-group-content.two-column {
  display: flex;
  flex-direction: row;
  gap: 8rem; /* spacing between columns */
  margin: 0.5em 0;
}

.filter-group-content.two-column > div {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}

.divider {
  border: none;
  border-top: 1px solid #ccc;
  margin: 1em 0;
}


.filter-group-title {
  font-size: 1.07em;
  font-weight: 600;
  color: var(--button-text, #fff);
  cursor: pointer;
  padding: 0.2em 0.5em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.arrow {
  margin-left: 0.5em;
  font-size: 0.9em;
  transform: translateY(1px);
}
.filter-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid #e2e2e2;
  padding-bottom: 0.3em;
}
.filter-action {
  background: none;
  border: none;
  color: var(--button-bg, #504A4A);
  font-size: 1em;
  cursor: pointer;
  margin-left: 0.7em;
}

.filter-group-content {
  /* Smooth transition for expand/collapse */
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.5s cubic-bezier(0.33, 1, 0.68, 1),
    padding-top 0.3s,
    padding-bottom 0.3s;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
}

.filter-group.expanded .filter-group-content {
  max-height: 350px;    /* Make sure this is enough for your largest group! */
  padding-top: 0.5em;
  padding-bottom: 0.5em;
  padding-right: 1em;
  opacity: 1;
 justify-content: space-between;
}

.filter-group-title {
  font-size: 1.07em;
  font-weight: 600;
  color: var(--button-text, #fff);
  cursor: pointer;
  padding: 0.2em 0.5em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.arrow {
  margin-left: 0.5em;
  font-size: 0.9em;
  transform: translateY(1px);
  transition: transform 0.23s;
}

.filter-group:not(.expanded) .arrow {
  transform: rotate(-90deg);
}

/* Two column layout for filter content */
.filter-group-content.two-column {
  display: flex;
  flex-direction: row;
  gap: 3rem;
  margin: 0.5em 0;
}
.filter-group-content.two-column > div {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
}



@media (max-width: 650px) {
  .filter-popup { min-width: 95vw; padding: 1rem 0.6rem;}
  .filter-popup-body { max-height: 65vw; }
}