/* CX-09A — Unified Product Card Redesign */

/* ── Card Shell ──────────────────────────────────────────────────── */
.upc-card {
  background: #FFFFFF;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.15s;
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
  position: relative;
  width: 100%;
  min-height: 100%;
  outline: none;
}

.upc-card:hover,
.upc-card:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.11);
  border-color: rgba(229, 75, 0, 0.2);
}

.upc-card:focus-visible {
  outline: 2px solid #E54B00;
  outline-offset: 2px;
}

.upc-card.upc-highlight {
  outline: 2px solid #16A34A;
  box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.15);
}

.upc-card.pc-selected,
.upc-card.hp2-selected,
.upc-card.smq-analyzing {
  outline: 2px solid #F97316;
  box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.15);
}

/* ── Image ──────────────────────────────────────────────────────── */
.upc-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: #F7F7F7;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

.upc-img-skeleton {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, #EEEEEE 25%, #F5F5F5 50%, #EEEEEE 75%);
  background-size: 200% 100%;
  animation: upcShimmer 1.4s ease-in-out infinite;
  z-index: 0;
}

.upc-img-skeleton.loaded {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

@keyframes upcShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.upc-img-track {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.upc-img,
.upc-card .hp2-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: transform 0.3s;
}

.upc-card:hover .upc-img { transform: scale(1.04); }

.upc-img-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #CBD5E1;
}

/* ── Badge ──────────────────────────────────────────────────────── */
.upc-decision-badge {
  position: absolute;
  top: 8px;
  inset-inline-start: 8px;
  z-index: 3;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding: 4px 10px;
  border-radius: 999px;
  line-height: 1.4;
  white-space: nowrap;
  color: #fff;
  max-width: calc(100% - 16px);
  overflow: hidden;
  text-overflow: ellipsis;
  backdrop-filter: blur(4px);
}

.upc-decision-badge[data-badge="best_value"]    { background: rgba(5,150,105,0.92); }
.upc-decision-badge[data-badge="fast_shipping"] { background: rgba(3,105,161,0.92); }
.upc-decision-badge[data-badge="highest_rated"] { background: rgba(124,58,237,0.92); }
.upc-decision-badge[data-badge="best_seller"]   { background: rgba(220,38,38,0.92); }
.upc-decision-badge[data-badge="madar_pick"]    { background: rgba(15,118,110,0.92); }
.upc-decision-badge[data-badge="best_overall"]  { background: rgba(180,83,9,0.92); }
.upc-decision-badge[data-badge="reference"]     { background: rgba(71,85,105,0.9); }

.upc-rank {
  position: absolute;
  top: 8px;
  inset-inline-end: 8px;
  z-index: 3;
  font-size: 10px;
  font-weight: 700;
  color: #475569;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 4px;
  padding: 2px 6px;
}

.upc-img-dots {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  z-index: 3;
}

.upc-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.upc-dot.active {
  background: #E54B00;
  transform: scale(1.2);
}

/* ── Body ───────────────────────────────────────────────────────── */
.upc-body {
  padding: 10px 10px 6px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 0;
}

.upc-title {
  font-size: 12px;
  font-weight: 600;
  color: #1E293B;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0 0 1px;
  flex: 0 0 auto;
}

[dir="rtl"] .upc-title { line-height: 1.65; }

/* ── Reason ─────────────────────────────────────────────────────── */
.upc-reason {
  font-size: 10px;
  color: #64748B;
  line-height: 1.4;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  background: #F8FAFC;
  border-inline-start: 2px solid #E54B00;
  padding: 3px 6px;
  border-radius: 0 4px 4px 0;
}

[dir="rtl"] .upc-reason {
  border-inline-start: none;
  border-inline-end: 2px solid #E54B00;
  border-radius: 4px 0 0 4px;
}

/* ── Meta (rating · orders · store) ────────────────────────────── */
.upc-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: #64748B;
  flex-wrap: wrap;
}

.upc-meta-rating {
  color: #F59E0B;
  font-weight: 700;
}

.upc-meta-orders-dot { color: #94A3B8; font-size: 10px; }

.upc-meta-sep {
  color: #CBD5E1;
  margin: 0 1px;
  font-size: 10px;
}

.upc-meta-store {
  color: #475569;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Trust badges ───────────────────────────────────────────────── */
.upc-trust {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.upc-trust-chip {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
  white-space: nowrap;
}

.upc-trust-verified { background: #ECFDF5; color: #059669; border: 1px solid #BBF7D0; }
.upc-trust-fast     { background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE; }
.upc-trust-free     { background: #F0FDF4; color: #16A34A; border: 1px solid #BBF7D0; }
.upc-trust-official { background: #FFF7ED; color: #C2410C; border: 1px solid #FED7AA; }
.upc-trust-conf     { background: #F5F3FF; color: #7C3AED; border: 1px solid #DDD6FE; }

/* ── Price Block ────────────────────────────────────────────────── */
.upc-price-block {
  margin-top: auto;
  padding-top: 6px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Total cost — main emphasis */
.upc-total-cost {
  display: flex;
  align-items: baseline;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.upc-price-current {
  font-size: 16px;
  font-weight: 800;
  color: #E54B00;
  line-height: 1.2;
}

.upc-total-sub {
  font-size: 9px;
  color: #94A3B8;
  font-weight: 500;
}

/* Breakdown rows (Product / Shipping) */
.upc-price-rows {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upc-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 10px;
}

.upc-price-lbl {
  color: #94A3B8;
  flex-shrink: 0;
}

.upc-price-val {
  color: #475569;
  font-weight: 600;
  text-align: end;
}

.upc-price-val.upc-free-ship { color: #16A34A; }

.upc-price-original {
  font-size: 9px;
  color: #94A3B8;
  text-decoration: line-through;
}

.upc-price-discount {
  font-size: 9px;
  font-weight: 700;
  color: #DC2626;
  background: #FEF2F2;
  padding: 1px 4px;
  border-radius: 3px;
}

.upc-ship-meta {
  font-size: 10px;
  color: #94A3B8;
  margin-top: 2px;
}

/* ── Delivery ───────────────────────────────────────────────────── */
.upc-delivery {
  font-size: 10px;
  color: #475569;
  display: flex;
  align-items: center;
  gap: 3px;
}

/* ── Freshness ──────────────────────────────────────────────────── */
.upc-freshness {
  font-size: 9px;
  color: #64748B;
  font-style: italic;
}

.upc-future-slots { display: none; }

/* ── Quick Preview Tooltip ──────────────────────────────────────── */
.upc-quick-preview {
  display: none;
  position: absolute;
  inset-inline: 8px;
  bottom: calc(100% - 8px);
  background: rgba(15, 23, 42, 0.94);
  color: #F1F5F9;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.45;
  z-index: 5;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.upc-preview-line + .upc-preview-line { margin-top: 3px; }

@media (hover: hover) {
  .upc-card:hover .upc-quick-preview,
  .upc-card:focus-within .upc-quick-preview {
    display: block;
  }
}

.upc-card.upc-preview-open .upc-quick-preview {
  display: block;
  position: relative;
  inset: auto;
  margin: 0 8px 4px;
  pointer-events: auto;
}

/* ── Actions ────────────────────────────────────────────────────── */
.upc-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
  margin-top: auto;
}

/* Homepage/discovery layout: View + Buy on top row, Search full-width below */
.upc-actions.upc-actions-hp {
  display: flex;
  flex-direction: column;
}

.upc-act-top-row {
  display: flex;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.upc-act-top-row .upc-act {
  flex: 1;
}

.upc-act-top-row .upc-act:not(:last-child) {
  border-inline-end: 1px solid rgba(0, 0, 0, 0.06);
}

/* Full-width "Search for Best Deal" button */
.upc-act-find-full {
  width: 100%;
  background: linear-gradient(90deg, #FFF7ED 0%, #FFFBEB 100%);
  color: #C2410C;
  font-weight: 700;
  font-size: 12px;
  padding: 10px 8px;
  border-top: none;
  border-inline-end: none !important;
}

.upc-act-find-full:hover,
.upc-act-find-full:focus-visible {
  background: linear-gradient(90deg, #FFEDD5 0%, #FEF3C7 100%);
  color: #9A3412;
  outline: none;
}

.upc-act {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 9px 6px;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  line-height: 1.2;
  text-align: center;
}

.upc-act:not(:last-child) {
  border-inline-end: 1px solid rgba(0, 0, 0, 0.06);
}

.upc-act-view {
  color: #475569;
  background: #F8FAFC;
}

.upc-act-view:hover,
.upc-act-view:focus-visible {
  background: #F1F5F9;
  color: #1E293B;
  outline: none;
}

.upc-act-find {
  color: #C2410C;
  background: #FFF7ED;
}

.upc-act-find:hover,
.upc-act-find:focus-visible {
  background: #FFEDD5;
  color: #9A3412;
  outline: none;
}

.upc-act-buy {
  color: #0369A1;
  background: #F0F9FF;
}

.upc-act-buy:hover,
.upc-act-buy:focus-visible {
  background: #E0F2FE;
  color: #0284C7;
  outline: none;
}

/* Single button: full-width */
.upc-actions:has(.upc-act:only-child) .upc-act,
.upc-actions.upc-single-btn .upc-act {
  grid-column: 1 / -1;
}

/* ── Madar Overlay ──────────────────────────────────────────────── */
.upc-madar { margin: 0 8px 4px; }

/* ── Grid / container overrides ─────────────────────────────────── */
.asp-dec-grid .upc-card,
.pc-grid .upc-card {
  min-height: 320px;
}

/* Analysis decision page — compact horizontal cards */
.asp-dec-grid .upc-card {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  min-height: 0;
  padding: 12px;
  gap: 12px;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
}

.asp-dec-grid .upc-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}

.asp-dec-grid .upc-card .upc-img-wrap {
  width: 80px;
  height: 80px;
  aspect-ratio: auto;
  flex-shrink: 0;
  border-radius: 10px;
}

.asp-dec-grid .upc-card .upc-img,
.asp-dec-grid .upc-card .hp2-card-img {
  object-fit: contain;
}

.asp-dec-grid .upc-card .upc-img-dots { display: none; }

.asp-dec-grid .upc-card .upc-body {
  flex: 1;
  min-width: 0;
  padding: 0;
}

.asp-dec-grid .upc-card .upc-title {
  font-size: 13px;
  -webkit-line-clamp: 2;
}

.asp-dec-grid .upc-card .upc-price-current {
  font-size: 17px;
}

.asp-dec-grid .upc-card .upc-actions {
  grid-template-columns: 1fr;
  width: 100%;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  margin-top: 0;
}

.asp-dec-grid .upc-card .upc-act-find { display: none; }

.asp-dec-grid .upc-card .upc-quick-preview { display: none !important; }

.asp-dec-grid .upc-card .upc-decision-badge {
  font-size: 9px;
  padding: 2px 6px;
  top: 4px;
  inset-inline-start: 4px;
  max-width: calc(100% - 8px);
}

/* Collection grid */
.col-grid .upc-card { min-height: 300px; }

.hp2-carousel,
.hp2-search-grid,
.pc-grid,
.asp-dec-grid,
.col-grid {
  align-items: stretch;
}

/* ── Compact variant chips (homepage / discovery cards) ─────────
 * AliExpress-style compact image / text chips with +N overflow tile.
 * Must not increase card height or break grid alignment.
 * ─────────────────────────────────────────────────────────────── */
.upc-vc-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 6px 0 2px;
  overflow: hidden;
  align-items: center;
}

.upc-vc-chip {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1.5px solid #E2E8F0;
  background: #F8FAFC;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.upc-vc-chip:hover {
  border-color: #F97316;
  box-shadow: 0 0 0 2px rgba(249,115,22,0.12);
}

/* Image chip */
.upc-vc-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Text chip */
.upc-vc-txt {
  font-size: 9px;
  font-weight: 500;
  color: #475569;
  white-space: nowrap;
  padding: 0 4px;
  width: auto;
  min-width: 20px;
  max-width: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* +N overflow tile */
.upc-vc-more {
  font-size: 10px;
  font-weight: 700;
  color: #64748B;
  width: 28px;
  flex-shrink: 0;
}

/* Responsive: fewer chips on very narrow cards */
@media (max-width: 400px) {
  .upc-vc-chip { width: 24px; height: 24px; }
  .upc-vc-more { width: 24px; }
}
