/**
 * Halo Product Filter — Frontend CSS
 * Tokens from mockup: --brand:#b8651e; --brand-dark:#9a541a; --red:#c0392b; --zalo:#0068ff
 */

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
.hpf,
.hpf-sheet {
  --brand:       #b8651e;
  --brand-dark:  #9a541a;
  --brand-light: #fff4ea;
  --brand-border:#e6c39c;
  --red:         #c0392b;
  --zalo:        #0068ff;
  --bg:          #f4f5f7;
  --line:        #e3e3e3;
  --ink:         #222;
  --grey:        #666;
  --chip-bg:     #f1f1f1;
  --white:       #fff;
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   24px;
  --shadow:      0 2px 12px rgba(0,0,0,.1);
}

/* ============================================================
   HIDE DEFAULT WOO SIDEBAR & ORDERING ON HPF PAGES
   ============================================================ */
.hpf-active-page .widget_layered_nav,
.hpf-active-page .widget_price_filter,
.hpf-active-page .widget_product_categories,
.hpf-active-page .woocommerce-ordering,
.hpf-active-page .woocommerce-result-count,
.hpf-active-page ul.products.columns-4 > li.product > a:not(.hpf-card-name),
.hpf-active-page ul.products.columns-4 > li.product .price,
.hpf-active-page ul.products.columns-4 > li.product .button,
.hpf-active-page ul.products.columns-4 > li.product .woocommerce-loop-product__title,
.hpf-active-page ul.products.columns-4 > li.product .attachment-woocommerce_thumbnail {
  display: none !important;
}

/* ============================================================
   CARD WRAPPER (when WC loop runs, li.product wraps our article)
   ============================================================ */
.hpf-active-page ul.products.columns-4 > li.product {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
}

/* ============================================================
   ROOT WRAPPER
   ============================================================ */
.hpf {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  padding: 0;
  box-sizing: border-box;
  width: 100%;
}

.hpf *,
.hpf *::before,
.hpf *::after {
  box-sizing: border-box;
}

/* ============================================================
   SHARED CARD PANEL
   ============================================================ */
.hpf .card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  padding: 12px 14px;
}

/* ============================================================
   SECTION LABEL
   ============================================================ */
.hpf-section-label {
  display: block;
  font-size: 12px;
  letter-spacing: .5px;
  color: var(--grey);
  text-transform: uppercase;
  margin-bottom: 8px;
  font-weight: 600;
}

/* ============================================================
   BRAND ROW
   ============================================================ */
.hpf-brands {
}

.hpf-brands-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hpf-brand {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  color: #444;
  background: #fafafa;
  min-width: 84px;
  text-align: center;
  text-decoration: none;
  transition: border-color .15s, background .15s, color .15s;
  cursor: pointer;
}

.hpf-brand:hover {
  border-color: var(--brand);
  color: var(--brand-dark);
  background: var(--brand-light);
}

.hpf-brand.is-active {
  border-color: var(--brand);
  background: var(--brand);
  color: var(--white);
  font-weight: 700;
}

/* ============================================================
   CRITERIA + CHIPS
   ============================================================ */
.hpf-criteria {
}

.hpf-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

/* Each facet chip container — position relative for popover */
.hpf-chip {
  position: relative;
  display: inline-flex;
  flex-direction: column;
}

/* Chip trigger button */
.hpf-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 8px 16px;
  font-size: 13.5px;
  background: var(--chip-bg);
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}

.hpf-chip-btn:hover,
.hpf-chip.is-open > .hpf-chip-btn {
  border-color: var(--brand);
  background: var(--white);
  color: var(--brand-dark);
}

.hpf-chip.is-active-filter > .hpf-chip-btn {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
}

.hpf-chip-count {
  font-weight: 700;
  color: var(--brand);
}

.hpf-caret {
  font-size: 11px;
  opacity: .7;
  margin-left: 2px;
  transition: transform .15s;
}

.hpf-chip.is-open > .hpf-chip-btn .hpf-caret {
  transform: rotate(180deg);
}

/* ---- Popover ---- */
.hpf-pop {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 900;
  padding: 10px 0 0;
}

.hpf-chip.is-open > .hpf-pop {
  display: block;
}

/* Options list */
.hpf-pop-options {
  max-height: 260px;
  overflow-y: auto;
  padding: 0 12px;
}

.hpf-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 2px;
  cursor: pointer;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  transition: background .1s;
}

.hpf-opt:hover {
  background: var(--brand-light);
}

.hpf-opt input[type="checkbox"] {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--brand);
  cursor: pointer;
}

.hpf-opt-label {
  flex: 1;
}

.hpf-cnt {
  font-size: 11.5px;
  color: var(--grey);
}

/* Price dropdown */
.hpf-pop-price {
  padding: 10px 12px;
}

.hpf-price-inputs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.hpf-price-inputs input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 0;
}

.hpf-price-inputs input:focus {
  border-color: var(--brand);
}

.hpf-price-sep {
  color: var(--grey);
  flex-shrink: 0;
}

.hpf-price-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.hpf-price-preset {
  border: 1px solid var(--line);
  background: var(--chip-bg);
  border-radius: var(--radius-lg);
  padding: 5px 11px;
  font-size: 12.5px;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s, border-color .1s;
}

.hpf-price-preset:hover,
.hpf-price-preset.is-active {
  border-color: var(--brand);
  background: var(--brand-light);
  color: var(--brand-dark);
}

/* Pop footer */
.hpf-pop-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  margin-top: 6px;
  gap: 8px;
}

.hpf-pop-clear {
  background: none;
  border: none;
  color: var(--grey);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: color .1s, background .1s;
}

.hpf-pop-clear:hover {
  color: var(--red);
  background: #fde;
}

.hpf-pop-apply {
  background: var(--brand);
  border: none;
  color: var(--white);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 16px;
  border-radius: var(--radius-lg);
  font-family: inherit;
  transition: background .1s;
}

.hpf-pop-apply:hover {
  background: var(--brand-dark);
}

/* ============================================================
   QUICK CHIPS
   ============================================================ */
.hpf-quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.hpf-quick-label {
  font-size: 13px;
  color: var(--grey);
  white-space: nowrap;
}

.hpf-quick-chip {
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  color: var(--brand-dark);
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .1s, border-color .1s;
}

.hpf-quick-chip:hover,
.hpf-quick-chip.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--white);
}

/* ============================================================
   SORT BAR
   ============================================================ */
.hpf-sortbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.hpf-sort-label {
  font-size: 13px;
  color: var(--grey);
  white-space: nowrap;
}

.hpf-sort {
  font-size: 13.5px;
  color: #444;
  text-decoration: none;
  padding: 5px 12px;
  border-radius: var(--radius-lg);
  transition: background .1s, color .1s;
  white-space: nowrap;
}

.hpf-sort:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.hpf-sort.is-active {
  background: var(--brand);
  color: var(--white);
  font-weight: 700;
}

.hpf-count {
  margin-left: auto;
  color: var(--grey);
  font-size: 13px;
  white-space: nowrap;
}

/* ============================================================
   ACTIVE FILTER CHIPS
   ============================================================ */
.hpf-active {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.hpf-active:empty {
  display: none;
}

.hpf-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eef4ff;
  border: 1px solid #cdddf7;
  border-radius: 18px;
  padding: 4px 10px;
  font-size: 12.5px;
  color: #2b5dab;
}

.hpf-active-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  color: #2b5dab;
  padding: 0 2px;
  line-height: 1;
  font-family: inherit;
}

.hpf-active-remove:hover {
  color: var(--red);
}

.hpf-clear {
  background: var(--brand-light);
  border: 1px solid var(--brand-border);
  border-radius: 18px;
  padding: 4px 12px;
  font-size: 12.5px;
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 600;
  transition: background .1s;
}

.hpf-clear:hover {
  background: var(--brand);
  color: var(--white);
  border-color: var(--brand);
}

/* ============================================================
   RESULTS WRAPPER + PRODUCT GRID
   ============================================================ */
.hpf-results {
  position: relative;
}

.hpf-products {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  min-height: 200px;
}

/* Loading overlay */
.hpf-results.is-loading .hpf-products {
  opacity: .5;
  pointer-events: none;
}

.hpf-results.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,.45);
  z-index: 10;
}

.hpf-no-products {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--grey);
  font-size: 15px;
}

/* ============================================================
   PRODUCT CARD (article.hpf-card)
   ============================================================ */
article.hpf-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s;
}

article.hpf-card:hover {
  box-shadow: 0 4px 18px rgba(0,0,0,.12);
}

/* Image area */
.hpf-card-img {
  height: 160px;
  position: relative;
  background: #f3f3f3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.hpf-card-img a {
  display: block;
  width: 100%;
  height: 100%;
}

.hpf-card-img img,
.hpf-card-thumb {
  width: 100%;
  height: 160px;
  object-fit: contain;
  display: block;
}

.hpf-no-img {
  color: #b3b3b3;
  font-size: 13px;
}

/* Sale badge */
.hpf-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--red);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  z-index: 1;
  pointer-events: none;
}

/* Card body */
.hpf-card-body {
  padding: 11px 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}

/* Product name */
.hpf-card-name {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.3;
  min-height: 36px;
  color: var(--ink);
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hpf-card-name:hover {
  color: var(--brand);
}

/* Spec chips */
.hpf-card-spec {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.hpf-card-spec span {
  background: #f3f3f3;
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  padding: 2px 7px;
  color: #555;
}

.hpf-card-spec span.cap {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
}

/* Price */
.hpf-card-price {
  color: var(--red);
  font-weight: 800;
  font-size: 15px;
  margin-top: 2px;
}

.hpf-card-price small {
  color: #aaa;
  font-weight: 400;
  text-decoration: line-through;
  font-size: 12px;
  margin-left: 6px;
}

/* Contact quote */
.hpf-card-quote {
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 14px;
  margin-top: 2px;
}

/* CTA buttons */
.hpf-card-btns {
  display: flex;
  gap: 7px;
  margin-top: auto;
}

.hpf-card-btns a {
  flex: 1;
  text-align: center;
  border-radius: var(--radius-sm);
  padding: 8px 0;
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  transition: opacity .15s, filter .15s;
}

.hpf-card-btns a:hover {
  filter: brightness(1.1);
}

.hpf-b-quote {
  background: var(--brand);
  color: var(--white) !important;
}

.hpf-b-zalo {
  background: var(--zalo);
  color: var(--white) !important;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.hpf-pagination {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.hpf-pagination ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 4px;
}

.hpf-pagination ul li a,
.hpf-pagination ul li span {
  display: block;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  text-decoration: none;
  color: var(--ink);
  background: var(--white);
  transition: background .1s, color .1s;
}

.hpf-pagination ul li span.current {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--white);
  font-weight: 700;
}

.hpf-pagination ul li a:hover {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-dark);
}

/* ============================================================
   LOAD MORE BUTTON
   ============================================================ */
.hpf-loadmore {
  display: block;
  margin: 20px auto 0;
  background: var(--brand);
  color: var(--white);
  border: none;
  border-radius: var(--radius-lg);
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}

.hpf-loadmore:hover {
  background: var(--brand-dark);
}

.hpf-loadmore:disabled {
  opacity: .6;
  cursor: not-allowed;
}

/* ============================================================
   MOBILE BAR (fixed at bottom on small screens)
   ============================================================ */
.hpf-mobilebar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 800;
  background: var(--white);
  border-top: 1px solid var(--line);
  padding: 10px 16px;
  gap: 12px;
  box-shadow: 0 -2px 12px rgba(0,0,0,.1);
}

.hpf-mobilebar button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--brand);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 0;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  position: relative;
}

.hpf-mobilebar button:active {
  filter: brightness(.9);
}

.hpf-m-icon {
  font-size: 16px;
}

.hpf-m-badge {
  position: absolute;
  top: 6px;
  right: 10px;
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
}

/* ============================================================
   BOTTOM SHEET (mobile filter/sort overlay)
   ============================================================ */
.hpf-sheet {
  --brand:       #b8651e;
  --brand-dark:  #9a541a;
  --brand-light: #fff4ea;
  --brand-border:#e6c39c;
  --red:         #c0392b;
  --zalo:        #0068ff;
  --bg:          #f4f5f7;
  --line:        #e3e3e3;
  --ink:         #222;
  --grey:        #666;

  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.45);
}

.hpf-sheet.is-open {
  display: block;
}

.hpf-sheet-inner {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 80vh;
  overflow-y: auto;
  background: var(--white, #fff);
  border-radius: 16px 16px 0 0;
  padding: 16px 16px 24px;
  transform: translateY(100%);
  transition: transform .3s ease;
}

.hpf-sheet.is-open .hpf-sheet-inner {
  transform: translateY(0);
}

.hpf-sheet-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--grey, #666);
  z-index: 1;
  line-height: 1;
  padding: 4px;
}

/* Scrollable sheet content */
.hpf-sheet-inner .hpf-sheet-section {
  margin-bottom: 20px;
}

.hpf-sheet-inner .hpf-sheet-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink, #222);
}

/* Sort options in sheet */
.hpf-sheet-sorts {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hpf-sheet-sort {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line, #e3e3e3);
  border-radius: 8px;
  background: var(--white, #fff);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  color: var(--ink, #222);
  transition: background .1s, border-color .1s;
}

.hpf-sheet-sort.is-active,
.hpf-sheet-sort:hover {
  background: var(--brand-light, #fff4ea);
  border-color: var(--brand, #b8651e);
  color: var(--brand-dark, #9a541a);
  font-weight: 700;
}

/* Filter checkboxes in sheet */
.hpf-sheet-filter-group {
  margin-bottom: 16px;
}

.hpf-sheet-filter-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--grey, #666);
  text-transform: uppercase;
  letter-spacing: .4px;
  margin-bottom: 8px;
  display: block;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
@keyframes hpf-spin {
  to { transform: rotate(360deg); }
}

.hpf-results.is-loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid var(--line);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: hpf-spin .7s linear infinite;
  z-index: 11;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1000px) {
  .hpf-products {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 760px) {
  .hpf-products {
    grid-template-columns: repeat(2, 1fr);
  }
  /* Hide desktop criteria/sortbar; show mobile bar */
  .hpf-criteria,
  .hpf-sortbar,
  .hpf-active {
    display: none;
  }
  .hpf-mobilebar {
    display: flex;
  }
  /* Add bottom padding so content isn't hidden behind fixed bar */
  .hpf-results {
    padding-bottom: 64px;
  }
  .hpf-brands-inner {
    gap: 6px;
  }
  .hpf-brand {
    min-width: 70px;
    padding: 7px 10px;
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .hpf-products {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .hpf-card-img {
    height: 120px;
  }
  .hpf-card-img img,
  .hpf-card-thumb {
    height: 120px;
  }
}

/* ==========================================================================
   Full-width archive: ẩn sidebar mặc định + mở rộng cột nội dung
   Scoped theo .hpf (chỉ trang có bộ lọc Halo). Dùng :has() (trình duyệt hiện đại).
   ========================================================================== */
.row:has(.hpf) > .col.large-3 {
  display: none !important;
}
.row:has(.hpf) > .col.large-9 {
  width: 100% !important;
  max-width: 100% !important;
  flex-basis: 100% !important;
}
/* Fallback: body class do plugin thêm trên product archive */
body.hpf-fullwidth .category-page-row > .col.large-3,
body.hpf-fullwidth .row > .col.large-3.hide-for-medium {
  display: none !important;
}
body.hpf-fullwidth .category-page-row > .col.large-9 {
  width: 100% !important;
  max-width: 100% !important;
  flex-basis: 100% !important;
}
