﻿/* 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: 10px 14px;
  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: 8px;
  flex-wrap: nowrap;
}

/* Search Box — Standardized across all sections */
.sf-search-wrap {
  position: relative;
  flex: 1 1 240px;
  min-width: 140px;
  max-width: 360px;
  display: flex;
  align-items: center;
}

.sf-search-icon {
  position: absolute;
  left: 9px;
  width: 14px;
  height: 14px;
  color: var(--text-muted, rgba(29, 31, 32, 0.5));
  pointer-events: none;
}

.sf-search-input {
  width: 100%;
  padding: 8px 30px 8px 30px;
  font-size: 13px;
  height: 36px;
  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;
  box-sizing: border-box;
}

.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;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  flex-wrap: nowrap;
}

/* Secondary Filter Rows (e.g. Open Play, Pasalo, Tournaments, Coaches, Services) — Clean Left Alignment */
.sf-secondary-row,
.sf-row-filters {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light, rgba(29, 31, 32, 0.08));
}

/* Filter Toggle Button — hidden unless the App-Style Mobile Homepage is active (see mobile media query below) */
.sf-filter-toggle-btn {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 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;
  white-space: nowrap;
  flex-shrink: 0;
}

.sf-toggle-chevron {
  transition: transform 0.2s ease;
}

.sort-filter-bar.sf-expanded .sf-toggle-chevron {
  transform: rotate(180deg);
}

.sf-control-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.sf-control-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted, rgba(29, 31, 32, 0.7));
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.sf-control-label svg {
  width: 13px;
  height: 13px;
}

.sf-select-custom {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.sf-select-input,
.sf-sort-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: auto;
  min-width: 100px;
  box-sizing: border-box;
  padding: 6px 24px 6px 8px;
  font-size: 12px;
  height: 36px;
  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;
  text-overflow: ellipsis;
  white-space: nowrap;
}

input[type="date"].sf-select-input {
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  width: auto;
  min-width: 130px;
  box-sizing: border-box;
  padding: 5px 8px;
  height: 36px;
}

.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: 6px;
  width: 11px;
  height: 11px;
  color: var(--text-muted, rgba(29, 31, 32, 0.6));
  pointer-events: none;
}

/* Reset Button & Dedicated Reset Row (Last item occupying its own row) */
.sf-reset-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-light, rgba(29, 31, 32, 0.1));
}

.sf-reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 12.5px;
  font-weight: 500;
  font-family: inherit;
  color: #c53030;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sf-reset-btn:hover {
  background: #fed7d7;
  color: #9b2c2c;
  border-color: #fc8181;
}

.sf-reset-btn svg {
  flex-shrink: 0;
}

/* 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;
}

/* Table sections (Open Play, Pasalo, Tournaments): the empty state is a <tr><td colspan>
   instead of a <div>, since appending a div directly into a <tbody> is invalid HTML and
   won't stretch to the table's width. Same visuals, moved onto the cell. */
.sf-empty-state-cell {
  text-align: center;
  padding: 48px 24px;
  background: #ffffff;
  border: none;
}

.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: 14px;
    margin-bottom: 20px;
  }

  .sf-main-row {
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
  }

  .sf-search-wrap {
    width: 100%;
    min-width: 100%;
    max-width: none;
    flex: 1 1 100%;
  }

  .sf-search-input {
    width: 100%;
    font-size: 13.5px; /* Prevents mobile browser auto-zoom on focus */
    padding: 9px 36px 9px 36px;
    height: 38px;
    box-sizing: border-box;
  }

  .sf-right-controls {
    margin-left: 0;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: nowrap;
  }

  .sf-control-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .sf-control-label {
    width: 75px;
    min-width: 75px;
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main, #1d1f20);
    gap: 6px;
  }

  .sf-control-label svg {
    width: 14px;
    height: 14px;
  }

  .sf-select-custom {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: center;
  }

  .sf-select-input,
  .sf-sort-select {
    width: 100%;
    flex: 1;
    min-width: 0;
    font-size: 13px;
    height: 38px;
    padding: 8px 30px 8px 12px;
    box-sizing: border-box;
  }

  input[type="date"].sf-select-input {
    padding: 7px 10px;
  }

  .sf-category-pills {
    width: 100%;
    justify-content: flex-start;
  }

  .sf-reset-row {
    width: 100%;
    margin-top: 8px;
    padding-top: 8px;
    justify-content: stretch;
  }

  .sf-reset-row .sf-reset-btn,
  .sf-reset-btn {
    width: 100%;
    justify-content: center;
    padding: 8px 12px;
    font-size: 13px;
  }

  .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;
  }
}

/* App-Style Mobile Homepage: collapse filters by default, showing only Search + Sort by.
   Tapping "Filters" reveals the rest (.sf-secondary-row). Desktop and the regular
   (non-app-style) mobile view are unaffected. */
@media (max-width: 768px) {
  body.has-mobile-app-home .sf-filter-toggle-btn {
    display: inline-flex;
    width: 100%;
    justify-content: center;
  }

  body.has-mobile-app-home .sf-secondary-row {
    display: none;
  }

  body.has-mobile-app-home .sort-filter-bar.sf-expanded .sf-secondary-row {
    display: flex;
  }
}

