/*
 * YHN 4.0 — Catalogue, Multi-Facet Filter Bar & Merch Landing Polish
 * Fixes:
 *   1. Eliminates double dropdown arrows (chevron + black ▼) on ALL archive <select> controls.
 *   2. Fixes desktop card overlap ("429 sản phẩm" vs "KHÁM PHÁ") on /cham-soc-da/ landing page.
 *   3. Hides unsightly default browser scrollbar under horizontal sub-category pill strip.
 *   4. Harmonizes archive product cards (brand label, typography, touch-safe hover, Ruby price).
 *   5. Prevents mobile right-edge overflow in .yhn-facets-bar.
 */

/* 1. Multi-Facet Filter Bar */
.yhn-facets-bar {
  margin: 0 0 20px;
  padding: 12px 14px;
  background: var(--yhn-surface);
  border: 1px solid var(--yhn-line);
  border-radius: var(--yhn-radius-lg);
  box-sizing: border-box;
  max-width: 100%;
  overflow: hidden;
}

.yhn-facets-bar__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.yhn-facet-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 !important;
  font-size: 12.5px;
  color: var(--yhn-muted);
  min-width: 0;
}

.yhn-facet-field__label {
  font-weight: 600;
  white-space: nowrap;
  color: var(--yhn-ink);
}

.yhn-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-width: 158px;
}

.yhn-select-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--yhn-muted);
  pointer-events: none;
}

/* Strip ALL native & Flatsome background arrows cleanly (100% immune to WP Rocket CSS minify!) */
html body.yhn-redesign-40 .yhn-facet-field select,
html body.yhn-redesign-40 div.shop-page-title.category-page-title .woocommerce-ordering select,
html body.yhn-redesign-40 .woocommerce-ordering select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  display: block !important;
  margin: 0 !important;
  min-height: 36px !important;
  height: 36px !important;
  line-height: 34px !important;
  padding: 0 30px 0 11px !important;
  border-radius: var(--yhn-radius-md) !important;
  border: 1px solid var(--yhn-line) !important;
  background-color: var(--yhn-bg) !important;
  background-image: none !important;
  color: var(--yhn-ink) !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  cursor: pointer;
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
  box-sizing: border-box !important;
}

/* Single crisp CSS border chevron for WooCommerce native sort wrapper */
html body.yhn-redesign-40 .woocommerce-ordering {
  position: relative !important;
}

html body.yhn-redesign-40 .woocommerce-ordering::after {
  content: "" !important;
  position: absolute !important;
  right: 13px !important;
  top: 50% !important;
  width: 6px !important;
  height: 6px !important;
  margin-top: -4px !important;
  border-right: 1.8px solid var(--yhn-muted) !important;
  border-bottom: 1.8px solid var(--yhn-muted) !important;
  transform: rotate(45deg) !important;
  pointer-events: none !important;
  display: block !important;
}

html body.yhn-redesign-40 .yhn-facet-field select {
  max-width: 172px;
}

html body.yhn-redesign-40 .yhn-facet-field::after {
  content: none !important;
  display: none !important;
}

html body.yhn-redesign-40 .yhn-facet-field select:focus,
html body.yhn-redesign-40 .woocommerce-ordering select:focus {
  border-color: var(--yhn-brand) !important;
  box-shadow: 0 0 0 3px var(--yhn-brand-soft) !important;
}

/* Harmonize ALL archive sale badges (-14%, -16%, -20%) to Quiet Ruby */
html body.yhn-redesign-40 .products .product-small .badge-container .badge-inner,
html body.yhn-redesign-40 .products .product-small .callout.badge .badge-inner,
html body.yhn-redesign-40 .products .product-small .onsale {
  background-color: var(--yhn-sale) !important;
  background-image: none !important;
  color: #ffffff !important;
  border-radius: var(--yhn-radius-sm) !important;
}

.yhn-facet-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 12px;
  margin: 0 !important;
  border-radius: var(--yhn-radius-md);
  border: 1px solid var(--yhn-line);
  background: var(--yhn-bg);
  color: var(--yhn-ink);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.yhn-facet-toggle input[type="checkbox"] {
  margin: 0 !important;
  accent-color: var(--yhn-brand);
}

.yhn-facet-reset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  padding: 6px 12px;
  border-radius: var(--yhn-radius-pill);
  background: var(--yhn-brand-soft);
  color: var(--yhn-brand) !important;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none !important;
  transition: background-color var(--yhn-transition), color var(--yhn-transition);
}

.yhn-facet-reset:hover {
  background: var(--yhn-brand);
  color: #ffffff !important;
}

/* 2. Hide ugly default browser scrollbar under sub-category pill scroller */
body.yhn-redesign-40 .yhn-archive-links {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

body.yhn-redesign-40 .yhn-archive-links::-webkit-scrollbar {
  display: none !important;
}

body.yhn-redesign-40.yhn-archive-phase1c .yhn-archive-chip {
  border-color: var(--yhn-line) !important;
  border-radius: var(--yhn-radius-pill) !important;
  background: var(--yhn-bg) !important;
  color: var(--yhn-ink) !important;
  transition: border-color var(--yhn-transition), background-color var(--yhn-transition), color var(--yhn-transition);
}

body.yhn-redesign-40.yhn-archive-phase1c .yhn-archive-chip:hover {
  border-color: var(--yhn-brand) !important;
  background: var(--yhn-brand-soft) !important;
  color: var(--yhn-brand) !important;
}

/* 3. Archive Product Cards (brand tag + Ruby price + touch-safe hover) */
.yhn-archive-card-brand {
  display: block;
  margin: 0 0 3px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--yhn-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.yhn-redesign-40.yhn-archive-phase1c .products .product-small .box {
  border: 1px solid var(--yhn-line) !important;
  border-radius: var(--yhn-radius-lg) !important;
  background: var(--yhn-bg) !important;
  overflow: hidden;
  transition: transform var(--yhn-transition), box-shadow var(--yhn-transition), border-color var(--yhn-transition);
}

@media (hover: hover) and (pointer: fine) {
  body.yhn-redesign-40.yhn-archive-phase1c .products .product-small .box:hover {
    transform: translateY(-3px) !important;
    border-color: var(--yhn-brand-border) !important;
    box-shadow: var(--yhn-shadow-md) !important;
  }
}

body.yhn-redesign-40.yhn-archive-phase1c .products .product-small .price,
body.yhn-redesign-40.yhn-archive-phase1c .products .product-small .price ins .amount {
  color: var(--yhn-brand) !important;
  font-weight: 700 !important;
}

/* Filter icon & count pill harmonization (removes hot-pink leak on mobile filter button) */
body.yhn-redesign-40 .category-filtering .filter-button,
body.yhn-redesign-40 .category-filtering .yhn-filter-count {
  color: var(--yhn-brand) !important;
}

body.yhn-redesign-40 .category-filtering .yhn-filter-count {
  background: var(--yhn-brand-soft) !important;
}

/* 4. Fix /cham-soc-da/ Merch Landing Desktop Card Overlap ("429 sản phẩm" vs "KHÁM PHÁ") */
body.yhn-redesign-40 .yhn-pl {
  --yhn-rose: var(--yhn-brand);
  --yhn-rose2: var(--yhn-brand-hover);
}

body.yhn-redesign-40 .yhn-pl-category-cards a {
  justify-content: flex-start !important;
  gap: 2px;
  padding: 14px 12px !important;
  border-color: var(--yhn-line) !important;
}

body.yhn-redesign-40 .yhn-pl-category-cards a::after {
  position: static !important;
  display: block !important;
  right: auto !important;
  bottom: auto !important;
  margin-top: 8px !important;
  color: var(--yhn-brand) !important;
  font-size: 9.5px !important;
  opacity: 0.9 !important;
}

body.yhn-redesign-40 .yhn-pl-section-head > a {
  white-space: nowrap !important;
  flex-shrink: 0 !important;
}

/* 5. Mobile Facet Grid (zero right-edge clipping on 390px) */
@media (max-width: 767px) {
  .yhn-facets-bar {
    padding: 10px;
  }

  .yhn-facets-bar__controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .yhn-facet-field {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    min-width: 0;
  }

  .yhn-select-wrap {
    width: 100%;
  }

  html body.yhn-redesign-40 .yhn-facet-field select {
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .yhn-facet-toggle {
    grid-column: 1 / -1;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
  }

  .yhn-facet-reset {
    grid-column: 1 / -1;
    width: 100%;
    justify-content: center;
    margin-left: 0;
  }
}
