/* ═══════════════════════════════════════
   SPG Category Page
═══════════════════════════════════════ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Hero ── */
.spg-cat__hero {
  position: relative;
  padding: 3rem 2rem;
  background: var(--color-surface, #f5f5f5);
  overflow: hidden;
}

.spg-cat__hero--has-img {
  background: linear-gradient(135deg, rgba(0, 0, 0, .55) 0%, rgba(0, 0, 0, .3) 100%),
    var(--hero-bg) center/cover no-repeat;
  color: #fff;
}

.spg-cat__hero-inner {
  max-width: 860px;
  margin: 0 auto;
}

.spg-cat__breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  font-size: .8rem;
  opacity: .75;
  margin-bottom: 1rem;
}

.spg-cat__breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.spg-cat__breadcrumb a:hover {
  text-decoration: underline;
}

.spg-cat__title {
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  margin: 0 0 .4rem;
}

.spg-cat__count {
  font-size: .85rem;
  opacity: .7;
  margin: 0 0 .75rem;
}

.spg-cat__desc {
  font-size: .95rem;
  line-height: 1.7;
  max-width: 640px;
  opacity: .9;
}

/* ── Body ── */
.spg-cat__body {
  max-width: 1280px;
  margin: 0 auto;
  padding: 50px 1.5rem 75px;
}

/* ── Subcategories ── */
.spg-cat__subcats {
  margin-bottom: 2.5rem;
}

.spg-cat__subcats-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--color-muted, #666);
}

.spg-cat__subcats-grid {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
}

.spg-subcat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color .2s, box-shadow .2s;
  min-width: 90px;
}

.spg-subcat:hover {
  border-color: var(--main-color, #ff0000);
  box-shadow: 0 2px 12px rgba(37, 99, 235, .12);
}

.spg-subcat__img-wrap {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--color-surface, #f5f5f5);
  display: flex;
  align-items: center;
  justify-content: center;
}

.spg-subcat__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.spg-subcat__img-wrap--empty {
  color: var(--color-muted, #999);
}

.spg-subcat__name {
  font-size: .85rem;
  font-weight: 500;
  text-align: center;
}

.spg-subcat__count {
  font-size: .75rem;
  color: var(--color-muted, #888);
  background: var(--color-surface, #f0f0f0);
  padding: .1rem .45rem;
  border-radius: 99px;
}

/* ── Toolbar ── */
.spg-cat__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: .75rem 0;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border, #e5e5e5);
}

.spg-cat__result-count {
  font-size: .85rem;
  color: var(--color-muted, #666);
  margin: 0;
}

.spg-cat__toolbar-controls {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.spg-cat__select {
  padding: .4rem .75rem;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  font-size: .85rem;
  background: #fff;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left .6rem center;
  padding-left: 2rem;
}

.spg-cat__select:focus {
  outline: 2px solid var(--main-color, #ff0000);
  outline-offset: 2px;
}

/* ── View Toggle ── */
.spg-cat__view-toggle {
  display: flex;
  gap: .25rem;
}

.spg-cat__view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--color-border, #ddd);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  color: var(--color-muted, #888);
  transition: all .2s;
}

.spg-cat__view-btn.is-active,
.spg-cat__view-btn:hover {
  background: var(--main-color, #ff0000);
  border-color: var(--main-color, #ff0000);
  color: #fff;
}

/* ── Products Grid ── */
.spg-cat__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(23.33%, 1fr));
  gap: 1.25rem;
  transition: all .3s;
}

.spg-cat__grid[data-view="list"] {
  grid-template-columns: 1fr;
}

/* ── Product Card ── */
.spg-pcard {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border, #e5e5e5);
  overflow: hidden;
  background: #fff;
  transition: box-shadow .25s, transform .25s;
}

.spg-pcard:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, .1);
  transform: translateY(-3px);
}

.spg-pcard--out-of-stock {
  opacity: .7;
}

/* Image */
.spg-pcard__img-wrap {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--color-surface, #f8f8f8);
}

.spg-pcard__img-link {
  display: block;
  width: 100%;
  height: 100%;
}

.spg-pcard__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}

.spg-pcard:hover .spg-pcard__img {
  transform: scale(1.06);
}

.spg-pcard__img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spg-pcard__img-placeholder img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: .4;
}

/* Badges */
.spg-pcard__badges {
  position: absolute;
  top: .6rem;
  right: .6rem;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  z-index: 2;
}

.spg-pcard__badge {
  display: inline-block;
  padding: .2rem .5rem;
  border-radius: 6px;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
}

.spg-pcard__badge--sale {
  background: #ef4444;
  color: #fff;
}

.spg-pcard__badge--new {
  background: #22c55e;
  color: #fff;
}

.spg-pcard__badge--featured {
  background: #f59e0b;
  color: #fff;
}

.spg-pcard__badge--oos {
  background: #6b7280;
  color: #fff;
}

/* Quick Actions */
.spg-pcard__actions {
  position: absolute;
  bottom: .6rem;
  left: .6rem;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  z-index: 2;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity .25s, transform .25s;
}

.spg-pcard:hover .spg-pcard__actions,
.spg-pcard:focus-within .spg-pcard__actions {
  opacity: 1;
  transform: translateX(0);
}

.spg-pcard__action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(4px);
  border: none;
  cursor: pointer;
  color: #333;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
  transition: background .2s, color .2s;
  text-decoration: none;
}

.spg-pcard__action-btn:hover {
  background: var(--main-color, #ff0000);
  color: #fff;
}

.spg-pcard__action-btn--wishlist.is-active {
  color: #ef4444;
}

/* Body */
.spg-pcard__body {
  padding: .9rem 1rem .5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  text-align: center;
}

.spg-pcard__cat {
  font-size: .72rem;
  color: var(--main-color, #ff0000);
  font-weight: 500;
}

.spg-pcard__title {
  font-size: .9rem;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
}

.spg-pcard__title a {
  color: inherit;
  text-decoration: none;
}

.spg-pcard__title a:hover {
  color: var(--main-color, #ff0000);
}

/* Rating */
.spg-pcard__rating {
  display: flex;
  align-items: center;
  gap: .35rem;
}

.spg-pcard__stars {
  display: flex;
  gap: 1px;
  color: #f59e0b;
}

.spg-pcard__rating-count {
  font-size: .75rem;
  color: var(--color-muted, #888);
}

/* Price */
.spg-pcard__price {
  font-size: .95rem;
  font-weight: 700;
}

.spg-pcard__price ins {
  text-decoration: none;
  color: #111;
}

.spg-pcard__price del {
  font-size: .8rem;
  color: var(--color-muted, #aaa);
  font-weight: 400;
}

.spg-pcard__price-oos {
  font-size: .85rem;
  color: var(--color-muted, #999);
}

/* Short desc — only in list view */
.spg-pcard__short-desc {
  display: none;
  font-size: .85rem;
  color: var(--color-muted, #666);
  line-height: 1.6;
}

.spg-cat__grid[data-view="list"] .spg-pcard__short-desc {
  display: block;
}

/* Footer */
.spg-pcard__footer {
  padding: .75rem 1rem 1rem;
}

.spg-pcard__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  width: 100%;
  padding: .6rem 1rem;
  font-size: .85rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s, opacity .2s;
}

.spg-pcard__btn--atc {
  background: var(--main-color);
  color: #fff;
}

.spg-pcard__btn--atc:hover {
  background: #a70011;
}

.spg-pcard__btn--atc.is-loading {
  opacity: .65;
  pointer-events: none;
}

.spg-pcard__btn--atc.is-added {
  background: #22c55e;
  pointer-events: none;
}

.spg-pcard__btn--select {
  background: transparent;
  color: var(--main-color, #ff0000);
  border: 1.5px solid var(--main-color, #ff0000);
}

.spg-pcard__btn--select:hover {
  background: var(--main-color, #ff0000);
  color: #fff;
}

.spg-pcard__btn--view {
  background: var(--color-surface, #f3f4f6);
  color: #333;
}

.spg-pcard__btn--view:hover {
  background: #e5e7eb;
}

/* ── List view card layout ── */
.spg-cat__grid[data-view="list"] .spg-pcard {
  flex-direction: row;
  align-items: stretch;
}

.spg-cat__grid[data-view="list"] .spg-pcard__img-wrap {
  width: 180px;
  min-width: 180px;
  aspect-ratio: auto;
}

.spg-cat__grid[data-view="list"] .spg-pcard__body {
  padding: 1.25rem 1.25rem .75rem;
}

.spg-cat__grid[data-view="list"] .spg-pcard__footer {
  display: flex;
  align-items: flex-end;
  padding: .75rem 1.25rem 1.25rem;
  min-width: 160px;
}

.spg-cat__grid[data-view="list"] .spg-pcard__btn {
  width: auto;
  min-width: 130px;
}

/* ── Pagination ── */
.spg-cat__pagination {
  margin-top: 2.5rem;
  display: flex;
  justify-content: center;
}

.spg-cat__pagination .page-numbers {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.spg-cat__pagination .page-numbers li a,
.spg-cat__pagination .page-numbers li span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: 1px solid var(--color-border, #e5e5e5);
  font-size: .85rem;
  text-decoration: none;
  color: inherit;
  transition: all .2s;
}

.spg-cat__pagination .page-numbers li a:hover {
  border-color: var(--main-color, #ff0000);
  color: var(--main-color, #ff0000);
}

.spg-cat__pagination .page-numbers li span.current {
  background: var(--main-color, #ff0000);
  border-color: var(--main-color, #ff0000);
  color: #fff;
  font-weight: 700;
}

/* ── Empty State ── */
.spg-cat__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 5rem 2rem;
  text-align: center;
  color: var(--color-muted, #888);
}

.spg-cat__empty h2 {
  font-size: 1.2rem;
  color: #333;
  margin: 0;
}

.spg-cat__empty p {
  margin: 0;
  font-size: .9rem;
}

.spg-cat__btn-back {
  margin-top: .5rem;
  padding: .6rem 1.5rem;
  background: var(--main-color, #ff0000);
  color: #fff;
  border-radius: 10px;
  text-decoration: none;
  font-size: .9rem;
  transition: background .2s;
}

.spg-cat__btn-back:hover {
  background: var(--main-color-dark, #1d4ed8);
}

/* ── Skeleton Loading ── */
.spg-pcard--skeleton .spg-pcard__img-wrap,
.spg-pcard--skeleton .spg-pcard__title,
.spg-pcard--skeleton .spg-pcard__price,
.spg-pcard--skeleton .spg-pcard__btn {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: spg-skeleton 1.4s infinite;
  border-radius: 6px;
  color: transparent;
}

@keyframes spg-skeleton {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ── Responsive ── */
@media (max-width: 768px) {

  .spg-cat__grid[data-view="list"] .spg-pcard {
    flex-direction: column;
  }

  .spg-cat__grid[data-view="list"] .spg-pcard__img-wrap {
    width: 100%;
    aspect-ratio: 1/1;
  }

  .spg-cat__grid[data-view="list"] .spg-pcard__footer {
    min-width: unset;
  }

  .spg-cat__hero {
    padding: 2rem 1rem;
  }

  .spg-cat__toolbar {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 570px) {
  .spg-cat__grid {
    grid-template-columns: 1fr;
  }
}

/* ── Cat Notice ── */
.spg-cat-notice {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 9999;
  padding: .75rem 1.5rem;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .15);
  opacity: 0;
  transition: opacity .3s, transform .3s;
  pointer-events: none;
  white-space: nowrap;
}

.spg-cat-notice.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.spg-cat-notice--success {
  background: #22c55e;
  color: #fff;
}

.spg-cat-notice--error {
  background: #ef4444;
  color: #fff;
}