/* Modular Section Sort & Filter Component Styling */

.sort-filter-bar {
  background: #ffffff;
  border: 1px solid var(--border-line, rgba(29, 31, 32, 0.16));
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 24px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  font-family: 'Barlow', system-ui, sans-serif;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sort-filter-bar:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.sf-main-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Search Box */
.sf-search-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 200px;
  max-width: 360px;
  display: flex;
  align-items: center;
}

.sf-search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-muted, rgba(29, 31, 32, 0.5));
  pointer-events: none;
}

.sf-search-input {
  width: 100%;
  padding: 9px 36px 9px 36px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-main, #1d1f20);
  background: var(--bg-main, #f2f2f3);
  border: 1px solid var(--border-line, rgba(29, 31, 32, 0.16));
  border-radius: 6px;
  outline: none;
  transition: all 0.18s ease;
}

.sf-search-input:focus {
  background: #ffffff;
  border-color: var(--steel-accent, #5980a6);
  box-shadow: 0 0 0 3px rgba(89, 128, 166, 0.15);
}

.sf-search-clear {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-muted, rgba(29, 31, 32, 0.5));
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  border-radius: 50%;
  transition: color 0.15s ease, background 0.15s ease;
}

.sf-search-clear:hover {
  color: var(--text-main, #1d1f20);
  background: rgba(0, 0, 0, 0.06);
}

/* Category Pills Group */
.sf-category-pills {
  display: inline-flex;
  align-items: center;
  background: var(--bg-main, #f2f2f3);
  padding: 3px;
  border-radius: 6px;
  border: 1px solid var(--border-light, rgba(29, 31, 32, 0.08));
  gap: 2px;
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.sf-pill-btn {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-main, #1d1f20);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sf-pill-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-main, #1d1f20);
}

.sf-pill-btn.active {
  background-color: var(--primary-button-color, #79A659);
  color: var(--on-primary-text, #ffffff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  font-weight: 600;
}

/* Right Controls (Filter Dropdown, Sort Dropdown & Reset) */
.sf-right-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-left: auto;
  flex-wrap: wrap;
}

.sf-control-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sf-control-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted, rgba(29, 31, 32, 0.7));
  font-weight: 500;
  white-space: nowrap;
}

.sf-select-custom {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.sf-select-input,
.sf-sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 8px 32px 8px 12px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-main, #1d1f20);
  background: var(--bg-main, #f2f2f3);
  border: 1px solid var(--border-line, rgba(29, 31, 32, 0.16));
  border-radius: 6px;
  cursor: pointer;
  outline: none;
  transition: all 0.18s ease;
}

.sf-select-input:hover,
.sf-sort-select:hover {
  border-color: var(--steel-accent, #5980a6);
}

.sf-select-input:focus,
.sf-sort-select:focus {
  background: #ffffff;
  border-color: var(--steel-accent, #5980a6);
  box-shadow: 0 0 0 3px rgba(89, 128, 166, 0.15);
}

.sf-select-arrow {
  position: absolute;
  right: 10px;
  color: var(--text-muted, rgba(29, 31, 32, 0.6));
  pointer-events: none;
}

/* Reset Button */
.sf-reset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  color: #c53030;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sf-reset-btn:hover {
  background: #fed7d7;
  color: #9b2c2c;
  border-color: #fc8181;
}

/* Meta Sub-row (Counter & Active Tags) */
.sf-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light, rgba(29, 31, 32, 0.1));
  font-size: 12px;
  color: var(--text-muted, rgba(29, 31, 32, 0.7));
}

.sf-counter {
  font-weight: 500;
}

.sf-counter-highlight {
  font-weight: 700;
  color: var(--text-main, #1d1f20);
}

.sf-active-tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sf-active-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(89, 128, 166, 0.12);
  color: var(--steel-accent, #5980a6);
  border-radius: 12px;
}

/* Empty State Card insertion */
.sf-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
  background: #ffffff;
  border: 1px dashed var(--border-line, rgba(29, 31, 32, 0.2));
  border-radius: 8px;
  margin: 16px 0;
}

.sf-empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-muted, rgba(29, 31, 32, 0.4));
}

.sf-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main, #1d1f20);
  margin: 0 0 6px;
}

.sf-empty-text {
  font-size: 13px;
  color: var(--text-muted, rgba(29, 31, 32, 0.7));
  margin: 0 0 16px;
}

/* Responsive / Mobile Optimization */
@media (max-width: 768px) {
  .sort-filter-bar {
    padding: 12px 14px;
    margin-bottom: 20px;
  }

  .sf-main-row {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
  }
  
  .sf-search-wrap {
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
  }

  .sf-search-input {
    font-size: 14px; /* Prevents mobile browser auto-zoom on focus */
    padding: 10px 36px 10px 36px;
  }

  .sf-right-controls {
    margin-left: 0;
    width: 100%;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
  }

  .sf-control-wrap {
    flex: 1 1 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .sf-control-label {
    font-size: 13px;
    flex-shrink: 0;
  }

  .sf-select-custom {
    flex: 1;
    width: 100%;
  }

  .sf-select-input,
  .sf-sort-select {
    width: 100%;
    font-size: 13.5px;
    padding: 9px 32px 9px 12px;
  }

  .sf-category-pills {
    width: 100%;
    justify-content: flex-start;
  }

  .sf-reset-btn {
    width: auto;
    padding: 8px 12px;
  }

  .sf-meta-row {
    margin-top: 8px;
    padding-top: 8px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .sf-control-wrap {
    flex-direction: row;
    align-items: center;
  }
}
