/*
 * shop-index-products.css
 * Components sản phẩm trang chủ: shop-section, tabs, product-grid, product-card,
 * btn-outline-sm, horizontal product rails, brand chips.
 */

/* ============================================================
   shop-section + shop-tabs
   ============================================================ */
.shop-section { margin-bottom: var(--space-8); }

.shop-section__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.shop-section__title {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: var(--font-display-weight);
  font-style: var(--font-display-style);
  letter-spacing: 0.03em;
  color: var(--primary);
}

.shop-section__more {
  font-size: var(--text-small);
  font-weight: 600;
  text-decoration: none;
  color: var(--color-blue);
}

.shop-tabs {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border);
  padding-bottom: var(--space-2);
}

.shop-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border: none;
  background: transparent;
  min-height: var(--btn-height);
  height: var(--btn-height);
  padding: 0 var(--btn-padding-sm-x);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--btn-font-size-sm);
  line-height: 1;
  color: var(--muted-foreground);
  cursor: pointer;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  white-space: nowrap;
}

.shop-tab.is-active {
  color: var(--primary);
  background: var(--background-muted);
  box-shadow: inset 0 -2px 0 var(--color-cyan);
}

/* ============================================================
   Product grid
   ============================================================ */
.shop-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-5);
}

.shop-product-grid--2col,
.shop-product-grid--bestseller {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

@media (min-width: 768px) {
  .shop-product-grid--bestseller {
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: var(--space-5);
  }
}

@media (min-width: 993px) {
  .shop-product-grid--2col {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
  }
}

/* ============================================================
   Product card
   ============================================================ */
.product-card {
  background: var(--color-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow var(--duration-normal);
}

.product-card:hover { box-shadow: var(--shadow-md); }

.product-card__media {
  position: relative;
  aspect-ratio: var(--shop-card-img-ratio);
  background: var(--background-muted);
  overflow: hidden;
}

.product-card__media img { width: 100%; height: 100%; object-fit: cover; }

.product-card__badges {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.product-card__badge {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  color: var(--color-white);
}

.product-card__badge--sale { background: var(--shop-sale-color); }
.product-card__badge--hot  { background: var(--color-orange); }
.product-card__badge--new  { background: var(--color-blue); }

.product-card__body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: var(--space-2);
}

.product-card__cat {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.product-card__name {
  font-family: var(--font-display);
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--primary);
  line-height: var(--leading-snug);
  text-decoration: none;
}

.product-card__name:hover { color: var(--accent); }

.product-card__specs { display: flex; flex-direction: column; gap: 2px; }

.product-card__specs-row {
  display: block;
  margin: 0;
  font-size: 0.6875rem;
  line-height: 1.35;
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card__specs-row--meta { font-size: 0.625rem; opacity: 0.75; }

.product-card__price {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: auto;
}

.product-card__price-current {
  font-weight: 700;
  color: var(--shop-price-color);
  font-size: var(--text-body);
}

.product-card__price-old {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  text-decoration: line-through;
}

.product-card__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.product-card__actions .btn-primary,
.product-card__actions .btn-outline-sm {
  flex: 1;
  min-height: var(--btn-height-xs);
  height: var(--btn-height-xs);
  padding: 0 var(--btn-padding-xs-x);
  font-size: var(--btn-font-size-xs);
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}

/* ============================================================
   btn-outline-sm
   ============================================================ */
.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: var(--btn-height);
  height: var(--btn-height);
  padding: 0 var(--btn-padding-sm-x);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--btn-font-size-sm);
  line-height: 1;
  color: var(--primary);
  background: transparent;
  border: 1px solid var(--color-blue);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
}

.btn-outline-sm:hover {
  border-color: var(--color-cyan);
  color: var(--color-cyan);
}

/* ============================================================
   Responsive — tabs, product grid (mobile)
   ============================================================ */
@media (max-width: 992px) {
  .shop-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: var(--space-2);
  }
  .shop-tab { flex: 0 0 auto; }
}

@media (max-width: 640px) {
  .shop-section__title { font-size: var(--text-h3); }
  .shop-product-grid {
    gap: var(--space-3);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 400px) {
  .shop-product-grid:not(.shop-product-grid--bestseller):not(.shop-product-grid--2col) {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Horizontal product rails
   ============================================================ */
.shop-product-rail-section { margin-bottom: var(--space-6); }

.shop-product-rail-section .shop-section__head { margin-bottom: var(--space-3); }

.shop-rail-tabs {
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  margin-bottom: var(--space-4);
}

.shop-rail-tabs::-webkit-scrollbar { display: none; }

.shop-rail-tabs .shop-tab {
  flex-shrink: 0;
  scroll-snap-align: start;
  transition: background var(--duration-fast), color var(--duration-fast), box-shadow var(--duration-fast), transform 0.22s var(--ease-out);
}

.shop-rail-tabs .shop-tab.is-activating {
  transform: scale(0.97);
  animation: shop-rail-tab-pulse 0.34s var(--ease-out);
}

@keyframes shop-rail-tab-pulse {
  0%   { filter: brightness(1); }
  40%  { filter: brightness(1.06); box-shadow: inset 0 -2px 0 var(--color-cyan), 0 0 0 3px rgba(0, 174, 239, 0.14); }
  100% { filter: brightness(1); }
}

.shop-rail-panel {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-3);
  align-items: stretch;
}

.shop-rail-panel__main { min-width: 0; }

.shop-rail-panel__aside {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: var(--space-2);
  flex-shrink: 0;
  min-width: auto;
}

.shop-rail-more {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-2);
  min-height: 105px;
  text-decoration: none;
  color: var(--color-white);
  background: linear-gradient(180deg, var(--color-blue) 0%, #0077b3 100%);
  border: 2px solid rgba(0, 174, 239, 0.35);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.22s var(--ease-out), box-shadow 0.22s var(--ease-out), border-color 0.22s;
  box-shadow: var(--shadow-sm);
}

.shop-rail-more__glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 120%, rgba(255, 255, 255, 0.35), transparent 62%);
  opacity: 0;
  transition: opacity 0.25s;
  pointer-events: none;
}

.shop-rail-more__icon {
  font-size: var(--text-h2);
  line-height: 1;
  transition: transform 0.25s var(--ease-out);
}

.shop-rail-more__label {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.shop-rail-more:hover {
  border-color: var(--color-cyan);
  box-shadow: 0 8px 24px rgba(0, 174, 239, 0.28);
}

.shop-rail-more:hover .shop-rail-more__glow { opacity: 1; }
.shop-rail-more:hover .shop-rail-more__icon { transform: translateX(3px); }

.shop-rail-more:active,
.shop-rail-more.is-activating {
  transform: scale(0.94);
  box-shadow: 0 2px 8px rgba(0, 119, 179, 0.35);
}

.shop-rail-more.is-activating {
  border-color: var(--color-cyan);
  animation: shop-rail-more-pulse 0.34s var(--ease-out);
}

.shop-rail-more.is-activating .shop-rail-more__icon { transform: translateX(6px); }

@keyframes shop-rail-more-pulse {
  0%   { filter: brightness(1); }
  40%  { filter: brightness(1.15); }
  100% { filter: brightness(1); }
}

.shop-brand-filter {
  display: flex;
  flex: 1;
  flex-direction: row;
  flex-wrap: wrap;
  align-content: center;
  justify-content: flex-start;
  gap: var(--space-2);
  padding: var(--space-2);
  min-width: 0;
  max-height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.shop-brand-filter__label {
  flex: 0 0 100%;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted-foreground);
  text-align: right;
  padding-right: 2px;
}

.shop-brand-filter::-webkit-scrollbar { width: 4px; }
.shop-brand-filter::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.shop-brand-chip {
  border: 1px solid var(--border);
  background: var(--color-white);
  color: var(--muted-foreground);
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 7px 10px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast), box-shadow var(--duration-fast), transform 0.22s var(--ease-out);
}

.shop-brand-chip:hover { border-color: var(--color-cyan); color: var(--primary); }

.shop-brand-chip.is-active {
  background: rgba(0, 174, 239, 0.12);
  border-color: var(--color-cyan);
  color: var(--primary);
  box-shadow: inset 0 0 0 1px rgba(0, 174, 239, 0.2);
}

.shop-brand-chip:active,
.shop-brand-chip.is-activating { transform: scale(0.94); }

.shop-brand-chip.is-activating {
  border-color: var(--color-cyan);
  animation: shop-brand-chip-pulse 0.34s var(--ease-out);
}

@keyframes shop-brand-chip-pulse {
  0%   { filter: brightness(1); box-shadow: inset 0 0 0 1px rgba(0, 174, 239, 0.2); }
  40%  { filter: brightness(1.08); box-shadow: 0 0 0 3px rgba(0, 174, 239, 0.22); }
  100% { filter: brightness(1); box-shadow: inset 0 0 0 1px rgba(0, 174, 239, 0.2); }
}

.shop-rail-empty {
  flex: 0 0 min(260px, 78vw);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 245px;
  padding: var(--space-5);
  margin: 0;
  font-size: var(--text-small);
  color: var(--muted-foreground);
  background: var(--background-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.shop-product-rail {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-2);
}

.shop-product-rail__viewport {
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.shop-product-rail__viewport::-webkit-scrollbar { display: none; }

.shop-product-rail__track {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-1) var(--space-1) var(--space-3);
  transition: opacity 0.18s var(--ease-out);
}

.shop-product-rail__track.is-filtering {
  opacity: 0.42;
  pointer-events: none;
}

.shop-rail-card-wrap {
  flex: 0 0 min(260px, 78vw);
  scroll-snap-align: start;
  max-width: 245px;
  animation: shop-rail-card-in 0.38s var(--ease-out) both;
  animation-delay: calc(var(--rail-i, 0) * 45ms);
}

@keyframes shop-rail-card-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .shop-rail-card-wrap { animation: none; }
  .shop-product-rail__track.is-filtering { transition: none; }
}

.shop-product-rail__track .product-card { flex: 1 1 auto; max-width: none; }

.shop-product-rail--fill .shop-product-rail__viewport { overflow-x: visible; }

.shop-product-rail__track--fill { width: 100%; }
.shop-product-rail__track--fill .shop-rail-card-wrap { flex: 1 1 0; min-width: 200px; max-width: none; }

.shop-product-rail__nav {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-h4);
  line-height: 1;
  color: var(--primary);
  background: var(--color-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--duration-fast), opacity var(--duration-fast);
}

.shop-product-rail__nav:hover:not(:disabled) {
  border-color: var(--color-cyan);
  box-shadow: var(--shadow-sm);
}

.shop-product-rail__nav:disabled { opacity: 0.35; cursor: not-allowed; }

@media (max-width: 640px) {
  .shop-rail-panel { grid-template-columns: 1fr; gap: var(--space-2); }
  .shop-rail-tabs  { margin-bottom: var(--space-3); }
  .shop-rail-panel__aside { order: 1; min-width: 0; align-items: stretch; }

  .shop-rail-more {
    flex-direction: row;
    min-height: auto;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    writing-mode: horizontal-tb;
  }

  .shop-rail-more__label { writing-mode: horizontal-tb; transform: none; letter-spacing: 0.06em; }
  .shop-rail-card-wrap { flex: 0 0 min(240px, 82vw); }
  .shop-product-rail { grid-template-columns: 1fr; }
  .shop-product-rail__nav { display: none; }
  .shop-product-rail__viewport { grid-column: 1; }
}

/* ============================================================
   Product card compact on mobile
   ============================================================ */
@media (max-width: 360px) {
  .shop-product-grid--2col { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .product-card__body { padding: var(--space-3); gap: var(--space-1); }

  .product-card__actions .btn-primary,
  .product-card__actions .btn-outline-sm {
    min-height: 36px;
    height: 36px;
  }
}
