/* ═══════════════════════════════════════════════════
   CHAT CROSS-MARKETPLACE COMPARISON WIDGET
   Designed for a 350–400px chat panel, mobile-first.
   All touch targets meet the 44×44px minimum (WCAG 2.5.5).
   ═══════════════════════════════════════════════════ */

/* ── Outer wrapper injected as a chat message ──────── */
.chat-compare-widget {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  font-size: var(--font-sm);
}

/* ── Section header bar (Amazon / AliExpress) ──────── */
.chat-compare-section-header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-weight: 700;
  font-size: var(--font-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.chat-compare-section-header--amazon {
  background: #fff8ee;
  border-bottom: 2px solid #ff9900;
  color: #7a4400;
}

.chat-compare-section-header--aliexpress {
  background: #fff3f3;
  border-bottom: 2px solid #e62e04;
  color: #7a1500;
  margin-top: 1px; /* visual separator between sections */
}

/* Marketplace colour dots */
.chat-compare-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.chat-compare-dot--amazon  { background: #ff9900; }
.chat-compare-dot--aliexpress { background: #e62e04; }

/* ── Horizontal scroll rail for product cards ──────── */
.chat-compare-rail {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  /* Hide scrollbar visually but keep it functional */
  scrollbar-width: none;
}

.chat-compare-rail::-webkit-scrollbar {
  display: none;
}

/* ── Individual mini-card ──────────────────────────── */
.chat-compare-card {
  flex: 0 0 140px; /* fixed width so 2+ cards peek on narrow panels */
  scroll-snap-align: start;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.chat-compare-card:focus-within {
  box-shadow: 0 0 0 2px var(--accent);
  outline: none;
}

/* Product image */
.chat-compare-card__img-wrap {
  position: relative;
  width: 100%;
  height: 100px;
  background: #f7f7f7;
  flex-shrink: 0;
}

.chat-compare-card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: var(--space-1);
  display: block;
}

/* Marketplace badge overlaid on image corner */
.chat-compare-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  padding: 2px 5px;
  border-radius: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.4;
  pointer-events: none;
}

.chat-compare-badge--amazon {
  background: #ff9900;
  color: #fff;
}

.chat-compare-badge--aliexpress {
  background: #e62e04;
  color: #fff;
}

/* Best-price highlight ring */
.chat-compare-card--best-price {
  border-color: var(--success-green);
  box-shadow: 0 0 0 1px var(--success-green);
}

.chat-compare-card--best-price .chat-compare-card__img-wrap::after {
  content: 'Best Price';
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: var(--success-green);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  letter-spacing: 0.02em;
}

/* Card body */
.chat-compare-card__body {
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.chat-compare-card__title {
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-dark);
  /* Clamp to 3 lines */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Rating row */
.chat-compare-card__rating {
  font-size: 0.68rem;
  color: var(--rating-gold);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.chat-compare-card__rating-count {
  color: var(--text-secondary);
  font-size: 0.65rem;
}

/* Price */
.chat-compare-card__price {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--price-red);
  white-space: nowrap;
}

.chat-compare-card__was-price {
  font-size: 0.65rem;
  color: var(--text-secondary);
  text-decoration: line-through;
  white-space: nowrap;
}

.chat-compare-card__discount {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--success-green);
  white-space: nowrap;
}

/* Currency label (muted, appended after amount) */
.chat-compare-card__currency {
  font-size: 0.65rem;
  font-weight: 400;
  color: var(--text-secondary);
  margin-left: 1px;
}

/* ── CTA button ────────────────────────────────────── */
/* Height is set to 44px to guarantee WCAG 2.5.5 touch target */
.chat-compare-card__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  width: 100%;
  padding: 0 var(--space-2);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  border: none;
  border-top: 1px solid var(--border-color);
  transition: background var(--transition-fast), color var(--transition-fast);
  gap: 4px;
  flex-shrink: 0;
}

.chat-compare-card__cta--amazon {
  background: #ff9900;
  color: #fff;
}

.chat-compare-card__cta--amazon:hover,
.chat-compare-card__cta--amazon:focus-visible {
  background: #e68a00;
}

.chat-compare-card__cta--aliexpress {
  background: #e62e04;
  color: #fff;
}

.chat-compare-card__cta--aliexpress:hover,
.chat-compare-card__cta--aliexpress:focus-visible {
  background: #c42803;
}

.chat-compare-card__cta:active {
  opacity: 0.85;
  transform: scale(0.98);
}

/* Arrow icon in CTA */
.chat-compare-card__cta-arrow {
  font-size: 0.9rem;
  line-height: 1;
}

/* ── Price summary banner ──────────────────────────── */
/*
  Shown between the two marketplace sections.
  Communicates the cheapest option at a glance.
*/
.chat-compare-summary {
  display: flex;
  align-items: stretch;
  border-top: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
  background: #f9f9f9;
}

.chat-compare-summary__cell {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-compare-summary__cell + .chat-compare-summary__cell {
  border-left: 1px solid var(--border-color);
}

.chat-compare-summary__label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.chat-compare-summary__label--amazon   { color: #7a4400; }
.chat-compare-summary__label--aliexpress { color: #7a1500; }

.chat-compare-summary__price {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dark);
}

.chat-compare-summary__price--winner {
  color: var(--success-green);
}

.chat-compare-summary__from {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Winner "Cheapest" pill */
.chat-compare-summary__winner-pill {
  align-self: center;
  background: var(--success-green);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  letter-spacing: 0.03em;
  margin-top: 2px;
  display: inline-block;
}

/* ── Tab toggle (switches between Compact and Full view) */
.chat-compare-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  background: #f5f5f5;
}

.chat-compare-tab {
  flex: 1;
  /* 44px height for touch */
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  padding: 0;
}

.chat-compare-tab[aria-selected="true"] {
  color: var(--text-dark);
  border-bottom-color: var(--accent);
}

.chat-compare-tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ── Tab panels ────────────────────────────────────── */
.chat-compare-panel {
  display: none;
}

.chat-compare-panel[aria-hidden="false"] {
  display: block;
}

/* ── Fullscreen mode adjustments ───────────────────── */
.chat-panel.fullscreen .chat-compare-card {
  flex-basis: 180px;
}

.chat-panel.fullscreen .chat-compare-card__img-wrap {
  height: 140px;
}

/* ── Reduced motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .chat-compare-card__cta:active {
    transform: none;
  }
}

/* ── RTL support ───────────────────────────────────── */
[dir="rtl"] .chat-compare-badge {
  left: auto;
  right: 4px;
}

[dir="rtl"] .chat-compare-card--best-price .chat-compare-card__img-wrap::after {
  right: auto;
  left: 4px;
}

[dir="rtl"] .chat-compare-summary__cell + .chat-compare-summary__cell {
  border-left: none;
  border-right: 1px solid var(--border-color);
}
