/**
 * @file
 * Filter bar above the offers listing.
 *
 * Colours follow the theme's tokens (--color-primary, --color-accent) with
 * fallbacks, so the bar still looks right if the tokens go away.
 */

.offer-filters {
  --of-primary: var(--color-primary, #004e7d);
  --of-accent: var(--color-accent, #dcaf8a);
  --of-border: #d6e2eb;
  --of-field-bg: #f8fbfd;
  --of-text: #1f2d3d;
  --of-muted: #6b7c8c;

  margin: 0 0 28px;
  padding: 20px;
  background: #fff;
  border: 1px solid #e8eff5;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 78, 125, 0.07);
  /* Anchor target: clear the fixed header. */
  scroll-margin-top: 110px;
}

/* ── Search · price · sort ── */
.offer-filters__bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px 220px auto;
  gap: 12px;
  align-items: end;
}
.offer-filters.is-enhanced .offer-filters__bar {
  grid-template-columns: minmax(0, 1fr) 200px 220px;
}
.offer-filters.is-enhanced .offer-filters__apply {
  display: none;
}

.offer-filters__search {
  position: relative;
}
.offer-filters__search input {
  width: 100%;
  height: 48px;
  padding-block: 0;
  padding-inline: 18px 54px;
  font-size: 15px;
  color: var(--of-text);
  background: var(--of-field-bg);
  border: 1.5px solid var(--of-border);
  border-radius: 14px;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.offer-filters__search input::-webkit-search-cancel-button {
  cursor: pointer;
}
.offer-filters__search-btn {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: #fff;
  background: var(--of-primary);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.offer-filters__search-btn:hover {
  background: #006699;
}

.offer-filters__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}
.offer-filters__field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--of-muted);
}
.offer-filters__field select {
  width: 100%;
  height: 48px;
  padding-block: 0;
  padding-inline: 14px 38px;
  font-size: 14px;
  font-weight: 600;
  color: var(--of-text);
  background-color: var(--of-field-bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23004e7d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  border: 1.5px solid var(--of-border);
  border-radius: 14px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}
[dir="rtl"] .offer-filters__field select {
  background-position: left 14px center;
}

.offer-filters__search input:focus,
.offer-filters__field select:focus {
  outline: none;
  background-color: #fff;
  border-color: var(--of-primary);
  box-shadow: 0 0 0 4px rgba(0, 78, 125, 0.12);
}

.offer-filters__apply {
  height: 48px;
  padding: 0 24px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--of-primary);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
}

/* ── Category chips ── */
.offer-filters__categories {
  min-width: 0;
  margin: 18px 0 0;
  padding: 18px 0 0;
  border: 0;
  border-top: 1px dashed #e3ecf3;
}
.offer-filters__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.offer-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #33475b;
  white-space: nowrap;
  background: #fff;
  border: 1.5px solid var(--of-border);
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
/* The radio stays in place (invisible) so it keeps focus and keyboard use. */
.offer-chip input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}
.offer-chip:hover {
  color: var(--of-primary);
  border-color: var(--of-primary);
}
.offer-chip:focus-within {
  box-shadow: 0 0 0 3px rgba(0, 78, 125, 0.2);
}
.offer-chip.is-active {
  color: #fff;
  background: var(--of-primary);
  border-color: var(--of-primary);
}
.offer-chip__count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  color: var(--of-primary);
  background: #eef5fa;
  border-radius: 999px;
}
.offer-chip.is-active .offer-chip__count {
  color: #fff;
  background: rgba(255, 255, 255, 0.22);
}

/* Dermatology types: a second chip row, gold when chosen. */
.offer-filters__legend {
  float: none;
  width: auto;
  margin: 0 0 10px;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--of-muted);
}
.offer-filters__types .offer-chip.is-active {
  color: #fff;
  background: var(--of-accent);
  border-color: var(--of-accent);
}
.offer-filters__types .offer-chip:hover {
  color: #9a6a43;
  border-color: var(--of-accent);
}
.offer-filters__types .offer-chip.is-active:hover {
  color: #fff;
}

/* ── Result count · active filters ── */
.offer-filters__summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  font-size: 14px;
}
.offer-filters__summary:empty {
  display: none;
}
.offer-filters__total {
  margin-inline-end: 6px;
  font-weight: 700;
  color: var(--of-text);
}
.offer-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  color: #8a5a33 !important;
  background: #fdf5ee;
  border: 1px solid #f1dcc8;
  border-radius: 999px;
  text-transform: none !important;
  transition: background 0.2s ease, color 0.2s ease;
}
.offer-tag i {
  font-size: 11px;
}
.offer-tag:hover {
  color: #fff !important;
  background: var(--of-accent);
  border-color: var(--of-accent);
}
.offer-filters__reset {
  font-weight: 700;
  text-transform: none !important;
  color: var(--of-primary) !important;
  text-decoration: underline !important;
  text-underline-offset: 3px;
}

/* ── No results ── */
.offer-filters__empty {
  margin-top: 20px;
  padding: 36px 20px;
  text-align: center;
  background: var(--of-field-bg);
  border: 1.5px dashed var(--of-border);
  border-radius: 16px;
}
.offer-filters__empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin-bottom: 12px;
  font-size: 20px;
  color: var(--of-primary);
  background: #eef5fa;
  border-radius: 50%;
}
.offer-filters__empty-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: var(--of-text);
}
.offer-filters__empty-text {
  margin: 0 0 16px;
  color: var(--of-muted);
}
.offer-filters__empty-btn {
  display: inline-block;
  padding: 10px 24px;
  font-weight: 700;
  color: #fff !important;
  background: var(--of-primary);
  border-radius: 999px;
}

/* ── Loading state while a new listing is fetched ── */
.view-id-offers.is-loading .view-content,
.view-id-offers.is-loading nav {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

/* ── Tablet ── */
@media (max-width: 991.98px) {
  .offer-filters__bar,
  .offer-filters.is-enhanced .offer-filters__bar {
    grid-template-columns: 1fr 1fr;
  }
  .offer-filters__search,
  .offer-filters__apply {
    grid-column: 1 / -1;
  }
}

/* ── Phone: chips scroll sideways instead of wrapping ── */
@media (max-width: 575.98px) {
  .offer-filters {
    margin-bottom: 20px;
    padding: 14px;
    border-radius: 16px;
  }
  .offer-filters__bar,
  .offer-filters.is-enhanced .offer-filters__bar {
    gap: 10px;
  }
  .offer-filters__categories {
    margin-top: 14px;
    padding-top: 14px;
  }
  .offer-filters__chips {
    flex-wrap: nowrap;
    margin-inline: -14px;
    padding-inline: 14px;
    padding-bottom: 4px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }
  .offer-filters__chips::-webkit-scrollbar {
    display: none;
  }
  .offer-chip {
    flex: 0 0 auto;
    scroll-snap-align: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .offer-filters *,
  .view-id-offers.is-loading .view-content {
    transition: none !important;
  }
}
