/* ===== Design tokens ===== */
:root {
  --bg: #f7f7f8;
  --card: #ffffff;
  --text: #111;
  --muted: #6b7280;
  --primary: #2e7d71;
  --primary-hover: #266a61;
  --primary-contrast: #fff;
  --border: #ececec;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 10px 24px rgba(0, 0, 0, 0.1);
  --pill: #2e7d71;
  --pill-contrast: #fff;
  --sale: #ef4444;
  --pill-muted: #0f172a;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  font-family: Inter, "Be Vietnam Pro", system-ui, -apple-system, Segoe UI,
    Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* ===== Breadcrumb / containers ===== */
.breadcrumb {
  border-radius: 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
}

/* ===== Shop Container ===== */
/* Không set align-items: flex-start vì cần các column có chiều cao bằng nhau để sticky hoạt động */

/* ===== Filter Box ===== */
.filter-box {
  background: var(--card);
  border-radius: 0.75rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 1.5rem;
}

.filter-box .card {
  border: 0;
  margin-bottom: 0.5rem;
}

.filter-box .card-header {
  background: transparent;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.filter-box .btn-link {
  color: var(--text);
  padding: 0.75rem 0;
  text-decoration: none;
  font-weight: 600;
  width: 100%;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-box .btn-link:hover {
  text-decoration: none;
  color: var(--primary);
}

.filter-box .btn-link:after {
  content: "\f107";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  transition: transform 0.2s;
}

.filter-box .btn-link.collapsed:after {
  transform: rotate(-90deg);
}

/* Đảm bảo aside có đủ không gian để sticky hoạt động */
/* Không set align-self: flex-start để aside có chiều cao bằng section bên phải */

aside .filter-box {
  position: sticky;
  top: 80px; /* Khoảng cách từ top để tránh header */
  max-height: calc(100vh - 100px); /* Giới hạn chiều cao */
  overflow-y: auto; /* Cho phép scroll bên trong nếu nội dung quá dài */
  z-index: 10; /* Đảm bảo filter box nằm trên các element khác */
}

.filter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.filter-header h6 {
  margin: 0;
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.875rem;
}

.filter-header .btn-clear-all {
  font-size: 0.8rem;
  color: var(--muted);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.filter-header .btn-clear-all:hover {
  color: var(--primary);
}

/* ===== Product Card ===== */
.card.product-card {
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background: var(--card);
}

.card.product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.product-img {
  position: relative;
  overflow: hidden;
  padding-top: 100%;
  border-radius: 1rem 1rem 0 0;
  background: #eff1f3;
}

.product-img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1);
  transition: transform 0.35s ease;
}

.product-card:hover .product-img img {
  transform: scale(1.04);
}

/* ===== Brand Logo ===== */
.product-brand-logo {
  position: absolute;
  top: 0.875rem;
  left: 0.875rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 160px;
  min-height: 36px;
  z-index: 2;
  line-height: 0;
}

.product-brand-logo .brand-text {
  font-size: 0.75rem;
  font-weight: 600;
  color: #111827;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.2;
}

.product-brand-logo img {
  height: 24px;
  width: 50px;
  max-width: 140px;
  object-fit: contain;
  object-position: center;
  display: block;
  margin-top: 5px;
  padding-left: 6px;
}

.product-action {
  position: absolute;
  inset: auto 0.75rem 0.75rem auto;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.18s ease-out, transform 0.18s ease-out, visibility 0.18s;
  z-index: 2;
}

.product-card:hover .product-action {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Luôn hiện trên mobile */
@media (max-width: 768px) {
  .product-card .product-action {
    opacity: 1;
    visibility: visible;
    transform: none;
  }
}

.btn-square {
  width: 42px;
  height: 42px;
  border-radius: 0.65rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  background: white;
  transition: all 0.2s ease;
}

.btn-square:hover:not(.fav-btn) {
  background: var(--primary);
  color: var(--primary-contrast);
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(46, 125, 113, 0.2);
}

.fav-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(239, 68, 68, 0.2);
}

.product-badge {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: var(--pill);
  color: var(--pill-contrast);
  border-radius: 999px;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 1;
}

.product-badge.right {
  left: auto;
  right: 0.75rem;
  background: var(--sale);
}

.product-card .card-body {
  padding: 0;
}

.product-meta {
  padding: 0.85rem 0.9rem 1rem 0.9rem;
  text-align: center;
}

/* ===== Product Subline (Brand + Category) ===== */
.product-subline {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.product-brand {
  font-weight: 600;
  color: var(--muted);
}

.product-group {
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 0.7rem;
  color: var(--muted);
}

.dot-separator {
  font-size: 0.8rem;
  opacity: 0.6;
  color: var(--muted);
}

.product-title {
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 0.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.product-title:hover {
  color: var(--primary);
  text-decoration: none;
}

.price {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.price-main .now {
  font-weight: 700;
  color: #0f172a;
  font-size: 1.05rem;
  line-height: 1.2;
}

.price-sub {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #6b7280;
  line-height: 1.5;
  margin-top: 2px;
}

.price-strike {
  text-decoration: line-through;
  opacity: 0.7;
  color: #6b7280;
  display: inline-block;
  vertical-align: baseline;
}

.save-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.75rem;
}

.fav-btn {
  border: 1px solid var(--border) !important;
  background: white !important;
}

.fav-btn i {
  color: #ef4444 !important;
}

.fav-btn:hover {
  background: #fef2f2 !important;
  border-color: #ef4444 !important;
}

.fav-btn.active {
  background: #ef4444 !important;
  border-color: #ef4444 !important;
}

.fav-btn.active i {
  color: white !important;
}

/* ===== Toolbar / chips ===== */
.toolbar {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

#activeChips {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

#activeChips .chip {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: #eef2f7;
  color: #0f172a;
  margin: 0;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}

#activeChips .chip button {
  border: 0;
  background: transparent;
  margin-left: 0.35rem;
  line-height: 1;
  cursor: pointer;
  font-size: 1rem;
  color: #0f172a;
}

#activeChips .chip button:hover {
  color: var(--sale);
}

/* ===== View Toggle Buttons ===== */
.view-toggle-group {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.view-toggle-group .btn {
  border: none;
  border-radius: 0;
  border-right: 1px solid var(--border);
  background: white;
  color: var(--muted);
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

.view-toggle-group .btn:last-child {
  border-right: none;
}

.view-toggle-group .btn:hover {
  background: #f9fafb;
}

.view-toggle-group .btn.active {
  background: var(--primary);
  color: var(--primary-contrast);
}

/* ===== Offcanvas (BS4 modal trick) ===== */
.modal.right .modal-dialog {
  position: fixed;
  right: 0;
  margin: 0;
  top: 0;
}

.modal-dialog-slideout {
  width: 86vw;
  max-width: 420px;
  height: 100%;
  transform: translateX(100%);
  transition: transform 0.3s ease-out;
  margin: 0;
}

.modal.right .modal-content {
  height: 100%;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: var(--card);
  color: var(--text);
}

.modal.right.show .modal-dialog-slideout {
  transform: translateX(0);
}

.modal.right .modal-backdrop {
  background-color: rgba(0, 0, 0, 0.5);
}

/* ===== Custom Checkboxes ===== */
.custom-control-label {
  cursor: pointer;
  user-select: none;
}

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::before {
  background-color: var(--primary);
  border-color: var(--primary);
}

/* ===== Dropdown Menu ===== */
.dropdown-menu {
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.dropdown-item {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--text);
}

.dropdown-item:hover {
  background-color: #f9fafb;
}

.dropdown-item.active {
  background-color: var(--primary);
  color: var(--primary-contrast);
}

/* ===== Responsive ===== */
@media (max-width: 767.98px) {
  .filter-box {
    padding: 1rem;
  }

  .toolbar {
    padding: 0.5rem 0.75rem;
  }

  #activeChips {
    max-width: 100%;
    overflow-x: auto;
  }
}

/* ===== Size Filter (Button Style) ===== */
.filter-size {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.size-filter-btn {
  display: none;
}

.size-filter-label {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  background-color: white;
  transition: all 0.2s ease;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.size-count-badge {
  font-size: 0.75rem;
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--muted);
  font-weight: 500;
  min-width: 1.5rem;
  text-align: center;
}

.size-filter-btn:checked + .size-filter-label {
  background-color: var(--primary);
  color: var(--primary-contrast);
  border-color: var(--primary);
}

.size-filter-btn:checked + .size-filter-label .size-count-badge {
  background-color: rgba(255, 255, 255, 0.2);
  color: var(--primary-contrast);
}

.size-filter-label:hover {
  border-color: var(--primary);
}

/* ===== Modal Quantity Controls ===== */
.btn-black {
  background: var(--primary) !important;
  color: var(--primary-contrast) !important;
  border: none;
  width: 36px;
  height: 36px;
  font-size: 18px;
  border-radius: 0.5rem;
}

.btn-black:hover {
  opacity: 0.85;
}

.small-input {
  width: 64px;
  text-align: center;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

/* ===== Quick Add Modal Styling ===== */
.size-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.size-radio {
  display: none;
}

.size-label {
  padding: 10px 15px;
  border: 2px solid #ccc;
  border-radius: 5px;
  cursor: pointer;
  font-size: 16px;
  background-color: #fff;
  transition: all 0.3s ease;
  user-select: none;
}

.size-radio:checked + .size-label {
  background-color: var(--primary);
  color: var(--primary-contrast);
  border-color: var(--primary);
}

.size-label:hover {
  border-color: var(--primary);
}

.quantity-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

/* ===== Custom Scrollbar cho Filter Box ===== */
aside .filter-box::-webkit-scrollbar {
  width: 6px;
}

aside .filter-box::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

aside .filter-box::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 10px;
}

aside .filter-box::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Firefox scrollbar */
aside .filter-box {
  scrollbar-width: thin;
  scrollbar-color: #888 #f1f1f1;
}

/* ===== Price Range Slider ===== */
.price-range-container {
  padding: 0.5rem 0;
}

.price-range-display {
  background: #f9fafb;
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid var(--border);
}

.price-input-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  flex: 1;
}

.price-label {
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.price-display-input {
  border: none;
  background: transparent;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  width: 100%;
  padding: 0.25rem 0;
  text-align: left;
}

.price-currency {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.125rem;
}

.price-separator {
  margin: 0 1rem;
  font-size: 1.25rem;
  color: var(--muted);
  font-weight: 300;
  align-self: flex-end;
  padding-bottom: 0.5rem;
}

.price-range-wrapper {
  position: relative;
  height: 40px;
  margin: 1.5rem 0;
}

.price-range-track {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 4px;
  background: #e5e7eb;
  border-radius: 2px;
  transform: translateY(-50%);
}

.price-range-progress {
  position: absolute;
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  left: 0%;
  right: 0%;
  transition: all 0.2s ease;
}

.price-range-input {
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: none;
  pointer-events: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  transform: translateY(-50%);
  margin: 0;
  padding: 0;
}

/* Min input z-index thấp hơn */
#priceRangeMin {
  z-index: 1;
}

/* Max input z-index cao hơn để có thể tương tác khi gần nhau */
#priceRangeMax {
  z-index: 2;
}

.price-range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border: 3px solid white;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  position: relative;
}

.price-range-input::-webkit-slider-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.price-range-input::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border: 3px solid white;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: all;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: all 0.2s ease;
  position: relative;
}

.price-range-input::-moz-range-thumb:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
}

.price-range-input::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.price-range-input::-moz-range-track {
  height: 4px;
  background: transparent;
}

.price-range-info {
  text-align: center;
}

.price-above-option {
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

.price-above-option .custom-control-label {
  font-size: 0.875rem;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}

.price-above-option .custom-control-input:checked ~ .custom-control-label {
  color: var(--primary);
  font-weight: 600;
}

#applyPriceFilter {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.625rem 1rem;
  border-radius: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
}

#applyPriceFilter:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(46, 125, 113, 0.3);
}

#applyPriceFilter:active {
  transform: translateY(0);
}

#applyPriceFilter:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(46, 125, 113, 0.25);
}
