/* =====================================================
   MEI BEDDING — shop.css
   Shop layout, filter sidebar, shop main, grid, product card, pagination, filter popup (mobile), sort popup (mobile).
   Extracted from hifi-v2.css sections 10-15, 17, 20b.
   ===================================================== */

/* ---------- 10. Shop layout (sidebar + grid) ---------- */
.shop-wrap {
  display: flex;
  flex-direction: column;
  gap: var(--sp-5);
  padding-bottom: var(--sp-8);
}
@media (min-width: 1024px) {
  .shop-wrap {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--sp-6);
  }
}

/* ---------- 11. Filter sidebar (desktop — Hybrid C: minimal + thin border) ---------- */
.filter-sidebar {
  display: none;
  flex-shrink: 0;
  width: 260px;
  position: sticky;
  top: calc(var(--header-h) + var(--sp-4));
  max-height: calc(100vh - var(--header-h) - var(--sp-4));
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: var(--sp-5) var(--sp-5) 0;
  scrollbar-width: thin;
}
.filter-sidebar::-webkit-scrollbar { width: 4px; }
.filter-sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 2px; }
@media (min-width: 1024px) {
  .filter-sidebar { display: block; }
}

/* Active filter chips bar (Style B) */
.filter-chips-active {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-4);
  border-bottom: 1px dashed var(--line);
}
.filter-chips-active:empty {
  display: none;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px 4px 10px;
  background: var(--bone-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 0.2px;
  animation: chipIn 0.18s var(--ease-out);
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(0.85); }
  to   { opacity: 1; transform: scale(1); }
}
.filter-chip-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--line);
}
.filter-chip-remove {
  cursor: pointer;
  color: var(--muted);
  margin-left: 4px;
  padding: 0 4px;
  font-size: 13px;
  line-height: 1;
  border: none;
  background: none;
  display: inline-flex;
  align-items: center;
  height: 16px;
  border-radius: 50%;
  transition: all var(--t-fast) var(--ease);
}
.filter-chip-remove:hover { color: var(--white); background: var(--sale); }

/* Sidebar header with active count + clear */
.filter-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--ink);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--ink);
}
.filter-title-left {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-2);
}
.filter-active-count {
  display: none;
  font-size: 10px;
  background: var(--ink);
  color: var(--white);
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 700;
  letter-spacing: 0;
  min-width: 18px;
  text-align: center;
}
.filter-active-count.show { display: inline-block; }
.filter-clear-all {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: none;
  color: var(--muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  transition: color var(--t-fast) var(--ease);
}
.filter-clear-all:hover { color: var(--sale); }
.filter-clear-all.hidden { visibility: hidden; }

/* Group: collapsible accordion */
.filter-group {
  border-bottom: 1px solid var(--bone-soft);
  padding-bottom: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.filter-group:last-of-type { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.filter-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--sp-1) 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink);
  transition: color var(--t-fast) var(--ease);
}
.filter-group-title:hover { color: var(--ink-soft); }
.filter-group-arrow {
  font-size: 10px;
  color: var(--muted);
  transition: transform var(--t-base) var(--ease);
}
.filter-group[data-expanded="false"] .filter-group-arrow { transform: rotate(-90deg); }
.filter-group[data-expanded="false"] .filter-options,
.filter-group[data-expanded="false"] .filter-color-row {
  max-height: 0;
  opacity: 0;
  margin-top: 0 !important;
  padding-top: 0;
  overflow: hidden;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--sp-3);
  max-height: 600px;
  opacity: 1;
  overflow: hidden;
  transition: max-height var(--t-base) var(--ease), opacity var(--t-fast) var(--ease);
}

/* Custom-styled checkbox (scoped to filter) */
.filter-group .checkbox,
.filter-group .radio {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 7px 6px;
  border-radius: var(--radius);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  user-select: none;
}
.filter-group .checkbox:hover,
.filter-group .radio:hover {
  background: var(--bone-soft);
  color: var(--ink);
}
.filter-group .checkbox input[type="checkbox"],
.filter-group .radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.filter-group .check-box,
.filter-group .radio-dot {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--line);
  flex-shrink: 0;
  position: relative;
  transition: all var(--t-fast) var(--ease);
  background: var(--white);
}
.filter-group .check-box { border-radius: 3px; }
.filter-group .radio-dot { border-radius: 50%; }

.filter-group .checkbox:hover .check-box,
.filter-group .radio:hover .radio-dot { border-color: var(--ink); }

.filter-group .checkbox input:checked ~ .check-box {
  background: var(--ink);
  border-color: var(--ink);
}
.filter-group .checkbox input:checked ~ .check-box::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid var(--white);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}
.filter-group .radio input:checked ~ .radio-dot {
  border-color: var(--ink);
  border-width: 2px;
}
.filter-group .radio input:checked ~ .radio-dot::after {
  content: "";
  position: absolute;
  inset: 2.5px;
  background: var(--ink);
  border-radius: 50%;
}

.filter-group .checkbox input:checked ~ .check-label,
.filter-group .radio input:checked ~ .check-label {
  color: var(--ink);
  font-weight: 600;
}

.check-label {
  flex: 1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-2);
}
.check-count {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
}
.filter-group .checkbox:hover .check-count,
.filter-group .radio:hover .check-count { color: var(--ink-soft); }

/* Color checkbox — dot + text in same row */
.filter-group .color-checkbox .color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.06) inset;
}

/* Color swatches — larger 32px with ring on active */
.filter-color-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: var(--sp-3);
  max-height: 200px;
  opacity: 1;
  transition: max-height var(--t-base) var(--ease), opacity var(--t-fast) var(--ease);
}
.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  cursor: pointer;
  position: relative;
  transition: transform var(--t-fast) var(--ease);
}
.color-swatch:hover { transform: scale(1.08); border-color: var(--ink-soft); }
.color-swatch.active {
  border-color: var(--ink);
}
.color-swatch.active::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--ink);
}
.color-swatch[data-color="trang"] { background: #ffffff; border-color: #ccc; }
.color-swatch[data-color="be"] { background: #e8e0d4; }
.color-swatch[data-color="ghi"] { background: #8a8a85; }
.color-swatch[data-color="hong"] { background: #d4a5a5; }
.color-swatch[data-color="xanh"] { background: #6b8e7a; }

/* Apply button — sticky bottom of card sidebar */
.filter-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--sp-2);
  margin: var(--sp-5) calc(var(--sp-5) * -1) 0;
  padding: var(--sp-4) var(--sp-5);
  background: var(--white);
  border-top: 1px solid var(--line);
  border-radius: 0 0 6px 6px;
}
.filter-actions .btn { flex: 1; font-size: 13px; padding: 11px; }

/* ---------- 12. Shop main (grid area) ---------- */
.shop-main { flex: 1; min-width: 0; }
.shop-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  padding-bottom: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.shop-title { font-family: var(--font-serif); font-size: 20px; font-weight: 700; letter-spacing: -0.01em; }
@media (min-width: 1024px) {
  .shop-title { font-size: 24px; }
}
.shop-meta { font-size: 13px; color: var(--muted); }

/* Mobile filter + sort toolbar (scroll naturally with content) */
.shop-toolbar-mobile {
  display: flex;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
  padding: var(--sp-3) 0;
  background: var(--white);
}
.shop-toolbar-mobile .btn { flex: 1; padding: 10px; font-size: 13px; }
@media (min-width: 1024px) {
  .shop-toolbar-mobile { display: none; }
}

/* Sort dropdown */
.sort-wrap {
  display: none;
  position: relative;
}
@media (min-width: 1024px) {
  .sort-wrap { display: block; }
}
.sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--white);
  color: var(--ink-soft);
  transition: border-color var(--t-fast) var(--ease);
}
.sort-toggle:hover { border-color: var(--ink); }
.sort-toggle strong {
  color: var(--ink);
  font-weight: 600;
}
.sort-toggle .sort-toggle-arrow {
  font-size: 9px;
  margin-left: 2px;
  transition: transform var(--t-fast) var(--ease);
}
.sort-wrap.open .sort-toggle-arrow { transform: rotate(180deg); }

.sort-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 220px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
  padding: 4px 0;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--t-fast) var(--ease);
  z-index: 20;
}
.sort-wrap.open .sort-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}
.sort-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  width: 100%;
  padding: 10px 16px;
  font-size: 13px;
  text-align: left;
  color: var(--ink-soft);
  transition: all var(--t-fast) var(--ease);
}
.sort-menu button:hover { background: var(--bone-soft); color: var(--ink); }
.sort-menu button.active {
  background: var(--bone-soft);
  color: var(--ink);
  font-weight: 600;
}
.sort-menu button.active::after {
  content: "✓";
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

/* ---------- 13. Product grid ---------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}
@media (min-width: 768px) {
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-5); }
}
@media (min-width: 1024px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 14. Product card ---------- */
.product-card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  position: relative;
  transition: transform var(--t-base) var(--ease);
}
.product-card-img {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--bone-soft);
}
.product-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--t-slow) var(--ease);
}
.product-card:hover .product-card-img img { transform: scale(1.04); }

.product-card-badge {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  background: var(--sale);
  color: var(--white);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 2px;
  letter-spacing: 0.5px;
  z-index: 2;
}
/* Multi-badge support — stack siblings vertically */
.product-card-badge + .product-card-badge {
  top: calc(var(--sp-2) + 26px);
}
.product-card-badge + .product-card-badge + .product-card-badge {
  top: calc(var(--sp-2) + 52px);
}
/* Badge variants */
.product-card-badge--new {
  background: var(--ink);
}
.product-card-badge--hot {
  background: #b8732a;
}
.product-card-badge--sale {
  background: var(--sale);
}

.product-card-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.4), transparent 50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: var(--sp-4);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
  z-index: 2;
}
@media (hover: hover) {
  .product-card:hover .product-card-overlay { opacity: 1; }
}
.product-card-overlay .btn {
  background: var(--white);
  color: var(--ink);
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
}
.product-card-overlay .btn:hover { background: var(--ink); color: var(--white); }

.product-card-info {
  padding: var(--sp-3) 0 var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.product-card-cat {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.product-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card-price-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.product-card-price {
  font-size: 17px;
  font-weight: 700;
  color: var(--cta-red);
}
.product-card-price--normal {
  color: var(--cta-red);
}
.price-unit {
  font-size: 0.7em;
  font-weight: 400 !important;
  margin-left: 2px;
  text-transform: lowercase;
  letter-spacing: 0;
}
.product-card-price-old {
  font-size: 13px;
  color: var(--muted);
  text-decoration: line-through;
  font-weight: 400;
}
.product-card-colors {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}
.product-card-colors .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

/* ---------- 15. Pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-7);
  flex-wrap: wrap;
}
.pagination a, .pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--ink-soft);
  background: var(--white);
  transition: all var(--t-fast) var(--ease);
}
.pagination a:hover { border-color: var(--ink); color: var(--ink); }
.pagination .current {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--white);
  font-weight: 600;
}
.pagination .dots { border: none; background: transparent; }


/* ---------- 17. Filter popup (mobile) ---------- */
.filter-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: var(--z-filter-popup);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base) var(--ease);
}
.filter-popup-backdrop.open { opacity: 1; visibility: visible; }
.filter-popup {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(90vw, 380px);
  background: var(--white);
  z-index: calc(var(--z-filter-popup) + 1);
  transform: translateX(-100%);
  transition: transform var(--t-base) var(--ease-out);
  display: flex;
  flex-direction: column;
}
.filter-popup.open { transform: translateX(0); }
.filter-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--line);
}
.filter-popup-title { font-size: 16px; font-weight: 600; }
.filter-popup-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
}
.filter-popup-footer {
  display: flex;
  gap: var(--sp-2);
  padding: var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--white);
}
.filter-popup-footer .btn { flex: 1; padding: 12px; font-size: 14px; }


/* ---------- 20b. Sort popup (mobile bottom sheet) ---------- */
.sort-popup-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: var(--z-filter-popup);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-base) var(--ease);
}
.sort-popup-backdrop.open { opacity: 1; visibility: visible; }
.sort-popup {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--white);
  z-index: calc(var(--z-filter-popup) + 1);
  transform: translateY(100%);
  transition: transform var(--t-base) var(--ease-out);
  border-radius: 16px 16px 0 0;
  padding-bottom: env(safe-area-inset-bottom);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.sort-popup.open { transform: translateY(0); }
.sort-popup-handle {
  width: 40px;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  margin: 10px auto 0;
}
.sort-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-5) var(--sp-3);
  border-bottom: 1px solid var(--line);
}
.sort-popup-title { font-size: 15px; font-weight: 600; }
.sort-popup-body {
  padding: var(--sp-3) 0;
  overflow-y: auto;
}
.sort-option {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 14px var(--sp-5);
  font-size: 14px;
  color: var(--ink-soft);
  cursor: pointer;
  border-bottom: 1px solid var(--bone-soft);
  transition: background var(--t-fast) var(--ease);
  position: relative;
}
.sort-option:last-child { border-bottom: none; }
.sort-option:hover { background: var(--bone-soft); }
.sort-option input[type="radio"] { accent-color: var(--ink); width: 18px; height: 18px; }
.sort-option.active {
  color: var(--ink);
  font-weight: 600;
  background: var(--bone-soft);
}
.sort-option.active::after {
  content: "✓";
  margin-left: auto;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
}


/* Tighten filter checkbox + radio vertical gap — match hifi exact */
.filter-sidebar .checkbox,
.filter-sidebar .radio,
.filter-options .checkbox,
.filter-options .radio,
.filter-popup .checkbox,
.filter-popup .radio {
  margin: 0;
  line-height: 1.5; /* match hifi default body line-height */
}

/* ---------- Empty state khi không có SP phù hợp filter ---------- */
.shop-empty {
  text-align: center;
  padding: var(--sp-7) var(--sp-5);
  background: var(--bone-soft);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  margin: var(--sp-4) 0 var(--sp-6);
}
.shop-empty::before {
  content: '';
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-3);
  background-color: var(--muted);
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/><line x1='8' y1='11' x2='14' y2='11'/></svg>");
          mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/><line x1='8' y1='11' x2='14' y2='11'/></svg>");
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-size: contain;
          mask-size: contain;
  opacity: 0.65;
}
.shop-empty p {
  font-size: 15px;
  color: var(--ink);
  margin-bottom: var(--sp-2);
  font-weight: 500;
}
.shop-empty::after {
  content: 'Bỏ tick bớt bộ lọc để mở rộng kết quả tìm kiếm.';
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: var(--sp-5);
  margin-bottom: 0;
  letter-spacing: 0.3px;
  line-height: 1.6;
}
.shop-empty .btn {
  min-width: 180px;
}
/* Fix hover: button outline → filled black bg KHÔNG che text trắng */
.shop-empty .btn--outline {
  background: var(--white);
  color: var(--ink);
  border-color: var(--ink);
}
.shop-empty .btn--outline:hover,
.shop-empty .btn--outline:focus,
.shop-empty a.btn--outline:hover,
.shop-empty a.btn--outline:focus {
  background: var(--ink);
  color: var(--white) !important;
  border-color: var(--ink);
}
