/*
 * AITopUp — shop, product listing, search, and product card styles.
 *
 * Loaded on homepage and WooCommerce catalog contexts.
 */

/* Product grid — mobile 2 col, desktop 4 col */
.product-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 1024px) {
  .product-grid {
    gap: 1.25rem;
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Need-based taxonomy UI */
.need-filter {
  position: relative;
  margin-bottom: 2rem;
}

.need-filter::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 2.5rem;
  height: calc(100% - 0.25rem);
  background: linear-gradient(to left, var(--color-bg), transparent);
  pointer-events: none;
}

.need-filter-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  scroll-padding-inline: 1rem;
}

.need-filter-scroll::-webkit-scrollbar {
  height: 4px;
}

.need-filter-scroll::-webkit-scrollbar-thumb {
  background: var(--border-glow);
  border-radius: 9999px;
}

.need-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
  min-height: var(--touch-min);
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--surface-chip);
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.2s, color 0.2s, background 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-card);
}

.need-chip:hover {
  border-color: var(--color-border-glow);
  color: var(--fg);
  background: var(--surface-chip-hover);
  box-shadow: var(--shadow-card-hover);
}

.need-chip.is-active {
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  background: var(--gradient-primary);
  background-size: 200% auto;
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.28);
}

.need-chip.is-active .icon,
.need-chip.is-active .need-chip-icon .icon {
  color: #fff;
  filter: none;
}

.need-chip-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.need-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .need-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) {
  .need-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  .need-grid { grid-template-columns: repeat(4, 1fr); }
}

.need-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.25rem;
  border-radius: var(--radius);
  text-decoration: none;
  transition: border-color 0.25s, box-shadow 0.25s, transform 0.2s;
}

.need-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.need-card-icon {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

.need-card-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.0625rem;
  font-weight: 700;
}

.need-card-desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ── Combo CTA banner — below the need-grid ─────────────────────────────── */
.combo-cta-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 1rem 1.5rem;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(0,82,255,0.05) 0%, rgba(0,200,255,0.04) 100%);
  border: 1px solid rgba(0,82,255,0.14);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.combo-cta-banner:hover {
  border-color: rgba(0,82,255,0.28);
  box-shadow: 0 4px 16px rgba(0,82,255,0.08);
}
.combo-cta-banner__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, rgba(0,82,255,0.10), rgba(0,200,255,0.07));
  border: 1px solid rgba(0,82,255,0.14);
  color: var(--accent-link);
}
.combo-cta-banner__copy {
  flex: 1;
  min-width: 0;
}
.combo-cta-banner__copy strong {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--fg-bright);
  margin-bottom: 0.2rem;
}
.combo-cta-banner__copy span {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.4;
}
[data-theme="dark"] .combo-cta-banner {
  background: rgba(0,82,255,0.08);
  border-color: rgba(0,82,255,0.22);
}
[data-theme="dark"] .combo-cta-banner:hover {
  box-shadow: 0 4px 16px rgba(0,82,255,0.18);
}
@media (max-width: 600px) {
  .combo-cta-banner {
    flex-direction: column;
    text-align: center;
    padding: 1.25rem 1rem;
  }
  .combo-cta-banner .btn {
    width: 100%;
    justify-content: center;
  }
}

.search-empty {
  padding: 2rem 1.5rem;
  border-radius: 1rem;
  text-align: center;
}

.search-empty__title {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
}

.search-empty__desc {
  margin: 0 auto 1.25rem;
  max-width: 36rem;
}

.search-empty__chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.search-empty__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.search-context-bar {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  background: var(--accent-surface);
}

.search-context-bar__hint {
  margin: 0.5rem 0 0;
  font-size: 0.75rem;
}

.search-active-bar {
  margin-bottom: 0;
}

.search-active-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.55rem 0.5rem 0.75rem;
  border-radius: 9999px;
  border: 1px solid rgba(14, 165, 233, 0.35);
  background: var(--accent-surface-strong);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--fg-bright);
  box-shadow: 0 2px 10px rgba(14, 165, 233, 0.12);
}

.search-active-chip__icon {
  display: inline-flex;
}

.need-filter--secondary {
  margin-bottom: 1.25rem;
  opacity: 0.95;
}

.need-filter--secondary .need-chip {
  font-size: 0.8125rem;
}

.shop-search-results[aria-busy="true"] {
  min-height: 12rem;
}

.search-skeleton {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

@media (min-width: 768px) {
  .search-skeleton {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .search-skeleton {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.search-skeleton__card {
  height: 16rem;
  border-radius: 1rem;
  background: linear-gradient(90deg, var(--accent-surface) 25%, var(--accent-surface-strong) 50%, var(--accent-surface) 75%);
  background-size: 200% 100%;
  animation: search-skeleton-shimmer 1.2s ease-in-out infinite;
}

@keyframes search-skeleton-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

.search-active-chip__label {
  line-height: 1.2;
}

.search-active-chip__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: var(--accent-surface);
  color: var(--muted);
  text-decoration: none;
  font-size: 1.1rem;
  line-height: 1;
}

.search-active-chip__clear:hover {
  color: var(--fg-bright);
  background: var(--border);
}

.aitopup-product-search .woocommerce-result-count,
.aitopup-product-search .woocommerce-ordering {
  display: none !important;
}

/* Shop loop toolbar — result count + sort (need filter view) */
.shop-loop-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
  padding: 0.625rem 0.875rem 0.625rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  box-shadow: var(--shadow-card);
}

.shop-loop-toolbar .woocommerce-result-count {
  margin: 0;
  float: none;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  line-height: 1.4;
}

.shop-loop-toolbar .woocommerce-result-count::before {
  content: "";
  display: inline-block;
  width: 0.4375rem;
  height: 0.4375rem;
  margin-right: 0.5rem;
  border-radius: 9999px;
  background: var(--gradient-primary);
  vertical-align: 0.05em;
  box-shadow: 0 0 0 3px var(--accent-surface);
}

.shop-loop-toolbar .woocommerce-ordering {
  margin: 0;
  float: none;
  flex: 0 0 auto;
}

.shop-loop-toolbar .woocommerce-ordering select {
  appearance: none;
  -webkit-appearance: none;
  min-height: 2.375rem;
  min-width: 10.5rem;
  max-width: 100%;
  margin: 0;
  padding: 0.4375rem 2.25rem 0.4375rem 0.875rem;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background-color: var(--surface-chip);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
  color: var(--fg-bright);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.shop-loop-toolbar .woocommerce-ordering select:hover {
  border-color: var(--color-border-glow);
  background-color: var(--surface-chip-hover);
}

.shop-loop-toolbar .woocommerce-ordering select:focus {
  outline: none;
  border-color: var(--color-border-glow);
  box-shadow: 0 0 0 3px var(--accent-focus-ring);
}

@media (max-width: 479px) {
  .shop-loop-toolbar {
    flex-direction: column;
    align-items: stretch;
    padding: 0.75rem 1rem;
  }

  .shop-loop-toolbar .woocommerce-ordering,
  .shop-loop-toolbar .woocommerce-ordering select {
    width: 100%;
  }
}

.need-section {
  margin-bottom: 3rem;
}

.need-section:last-child {
  margin-bottom: 0;
}

.need-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.need-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--fg-bright);
}

.need-section-icon {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.need-section-desc {
  margin: 0.35rem 0 0;
  font-size: 0.875rem;
  max-width: 36rem;
}

.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  overflow: hidden;
  transition: border-color 0.3s, box-shadow 0.3s, background 0.3s, transform 0.25s;
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  box-shadow: var(--shadow-card);
}

.product-card--pro::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--gradient-border-conic);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
  animation: none;
  z-index: 2;
}

.product-card--pro::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: calc(var(--radius) - 1px);
  background: var(--card);
  backdrop-filter: blur(12px) saturate(1.15);
  -webkit-backdrop-filter: blur(12px) saturate(1.15);
  z-index: 0;
  pointer-events: none;
  transition: background 0.3s;
}

.product-card--pro > * {
  position: relative;
  z-index: 1;
}

.product-card:hover {
  border-color: transparent;
  background: transparent;
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.product-card--pro:hover::before { opacity: 1; }

.product-card--pro:hover::after {
  background: var(--card-hover);
}

/* Product banner: design at 1200×600 (2:1) */
.product-card-image {
  aspect-ratio: 2 / 1;
  width: 100%;
  flex-shrink: 0;
  display: block;
  background: var(--color-bg-elevated);
  position: relative;
  overflow: hidden;
  border-radius: 0.75rem 0.75rem 0 0;
}

.product-card__holo {
  display: none;
}

.product-card__thumb {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-card__thumb img,
.product-card-image > img,
.attachment-aitopup_product_card,
.woocommerce ul.products li.product .woocommerce-loop-product__link img,
.attachment-woocommerce_thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.product-card__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-badges {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 600;
}

.badge-hot {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.18), rgba(99, 102, 241, 0.16));
  color: var(--color-accent-end);
  border: 1px solid rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 12px var(--glow-secondary), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.badge-hot__icon {
  flex-shrink: 0;
}

.badge-sale {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.12);
}

.badge-cat {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  margin-bottom: 0.5rem;
}

.product-card-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.product-card-body h3 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  transition: color 0.2s;
  color: var(--fg-bright);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-body h3 a {
  color: inherit;
  text-decoration: none;
}

.product-card:hover h3 a { color: var(--accent-link); }

.product-grid .product-excerpt {
  display: none;
}

.product-excerpt {
  margin: 0.25rem 0 0;
  font-size: 0.8125rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  margin-top: 0.75rem;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  position: relative;
}

.product-price .price-sale,
.product-price .woocommerce-Price-amount,
.product-price ins {
  position: relative;
  display: inline-block;
}

.product-grid .product-price .price-sale::after,
.product-grid .product-price .woocommerce-Price-amount:not(del *)::after,
.product-grid .product-price ins .woocommerce-Price-amount::after {
  display: none;
}
.price-sale { font-size: clamp(1.0625rem, 4vw, 1.25rem); font-weight: 700; color: var(--accent-link); }
.price-regular { font-size: 0.875rem; color: var(--muted-dim); text-decoration: line-through; }
.product-warranty { font-size: 0.75rem; color: var(--muted-dim); margin-top: 0.25rem; }
/* ── Product card v2 additions ──────────────────────────────────────────── */
.product-badges {
  z-index: 2;
}

.product-warranty-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
  padding: 0.2rem 0.625rem 0.2rem 0.4rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid rgba(16,185,129,0.25);
  line-height: 1;
}
.product-warranty-chip__icon {
  display: inline-flex;
  flex-shrink: 0;
}

.product-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.4rem;
  margin-top: 0.375rem;
  font-size: 0.725rem;
  line-height: 1.3;
  color: var(--muted);
}
.product-rating {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.product-rating__stars {
  color: #f59e0b;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  line-height: 1;
}
.product-rating__score {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--fg-bright);
}
.product-meta__sep {
  color: var(--muted-dim);
  font-weight: 600;
  user-select: none;
}
.product-meta__reviews {
  font-weight: 500;
  color: var(--muted);
}
.product-meta__sold {
  font-weight: 600;
  color: #cb1c22;
}

/* Badge-cat hidden in featured grids (already shown in section heading) */
.product-grid--featured .badge-cat {
  display: none;
}


/* Product card action buttons — equal width, unified typography */
.product-card__actions {
  margin-top: auto;
  padding-top: 1rem;
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.product-card__actions .product-card__btn,
.product-card__actions .btn,
.product-card__actions a,
.product-card__actions button,
.product-card__actions .button {
  flex: 1 1 0;
  min-width: 0;
  min-height: var(--touch-min, 44px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  white-space: nowrap;
  font-family: var(--font-body) !important;
  font-size: 0.8125rem !important;
  font-weight: 600 !important;
  line-height: 1.25 !important;
  letter-spacing: 0;
  padding: 0.5rem 0.625rem !important;
  margin: 0 !important;
  width: auto !important;
  border-radius: 0.5rem !important;
}

.product-card__actions .btn-secondary,
.product-card__actions .product-card__btn.btn-secondary {
  flex: 0 0 auto !important;
  min-width: 5.5rem;
  font-size: 0.75rem !important;
  color: var(--accent-link) !important;
  border: 1px solid var(--accent-border) !important;
  background: transparent !important;
  box-shadow: none !important;
}

.product-card__actions .btn-secondary:hover,
.product-card__actions .product-card__btn.btn-secondary:hover {
  color: var(--fg-bright) !important;
  border-color: var(--color-border-glow) !important;
  background: var(--card) !important;
}

.product-card__actions .button,
.product-card__actions .btn-primary,
.product-card__actions .product-card__btn.btn-primary {
  background: var(--gradient-brand) !important;
  background-size: 200% auto !important;
  color: var(--btn-primary-fg) !important;
  border: none !important;
  box-shadow: var(--glow-layered-primary), 0 0 0 1px var(--accent-border), inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

@media (min-width: 1024px) {
  .product-grid .product-card-body { padding: 1rem; }
  .product-grid .product-card-body h3 { font-size: 0.9375rem; }
  .product-grid .product-excerpt { font-size: 0.8125rem; }
  .woocommerce ul.products li.product .woocommerce-loop-product__title { font-size: 0.9375rem; }
}
