/* components.css — reusable UI components */

/* Cards & surfaces */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

/* Hero */
.hero {
  padding: var(--space-lg) var(--space-md);
  text-align: center;
}

.hero__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  padding: 4px 12px;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.hero__badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.hero__title {
  font-size: var(--font-size-2xl);
  margin: var(--space-md) 0 var(--space-sm);
}

.hero__subtitle {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* Stats banner */
.stats-banner {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  text-align: center;
}

.stat-card__value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-accent);
}

.stat-card__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Reward banner */
.reward-banner {
  background: linear-gradient(135deg, #ff6b35, #ff8c5e);
  color: white;
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  margin: var(--space-md) 0;
}

.reward-banner__title {
  font-weight: 700;
  font-size: var(--font-size-md);
}

.reward-banner__requirement {
  font-size: var(--font-size-xs);
  opacity: 0.9;
  margin-top: 4px;
}

/* AI notice */
.ai-notice {
  background: rgba(16, 185, 129, 0.1);
  color: var(--color-success);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
}

/* Retailer tabs */
.retailer-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
}

.retailer-tab {
  flex: 0 0 auto;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  font-size: var(--font-size-sm);
  font-weight: 600;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.retailer-tab--active {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.retailer-tab__count {
  background: var(--color-surface-alt);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* Progress bar */
.progress {
  margin: var(--space-md) 0;
}

.progress__label {
  display: flex;
  justify-content: space-between;
  font-size: var(--font-size-sm);
  margin-bottom: var(--space-xs);
}

.progress__bar {
  height: 8px;
  background: var(--color-surface-alt);
  border-radius: 999px;
  overflow: hidden;
}

.progress__fill {
  height: 100%;
  background: var(--color-accent);
  transition: width 500ms ease;
}

.progress__detail {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

/* Search */
.search-box {
  margin: var(--space-md) 0;
}

.search-box input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
}

.search-box input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.product-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform 150ms ease;
}

.product-card:active {
  transform: scale(0.98);
}

.product-card__image {
  aspect-ratio: 1;
  background: var(--color-surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

.product-card__badge {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  background: var(--color-accent);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.product-card__need-badge {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  background: rgba(239, 68, 68, 0.9);
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--font-size-xs);
  font-weight: 600;
}

.product-card__body {
  padding: var(--space-sm);
}

.product-card__name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(2 * 1.3em);
}

.product-card__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-xs);
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

.product-card__price {
  color: var(--color-accent);
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: var(--font-size-md);
  min-height: 44px;
  transition: background 150ms ease, opacity 150ms ease;
}

.btn--primary {
  background: var(--color-accent);
  color: white;
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn--block {
  width: 100%;
}

.btn--disabled,
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Load more button under product grid */
.load-more-btn {
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
}

/* Loading spinner */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
  margin: var(--space-md) auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------------------------------------------------------------------------
 * Chat view (community tab when CHAT_ENABLED=true)
 * See docs/superpowers/plans/2026-04-12-scanner-chat-implementation.md
 * ------------------------------------------------------------------------- */

.chat__header {
  margin-bottom: var(--space-md);
}

.chat__title {
  margin: 0 0 4px;
}

.chat__subtitle {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  margin: 0;
}

.chat__feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 55vh;
  overflow-y: auto;
  padding: var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.chat__loading,
.chat__empty,
.chat__error {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-md) 0;
  font-size: var(--font-size-sm);
}

.chat__error {
  color: #ef4444;
}

.chat__load-older {
  align-self: center;
  margin-bottom: var(--space-sm);
}

.chat__message {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-surface-alt);
  border-radius: var(--radius-sm);
}

.chat__message-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-sm);
  font-size: var(--font-size-xs);
}

.chat__message-nick {
  font-weight: 600;
  color: var(--color-accent);
}

.chat__message-time {
  color: var(--color-text-muted);
}

.chat__message-body {
  font-size: var(--font-size-sm);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat__sign-in-banner {
  margin-top: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface-alt);
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.chat__sign-in-link {
  color: var(--color-accent);
  font-weight: 600;
  text-decoration: none;
}

.chat__composer {
  margin-top: var(--space-md);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-sm);
  align-items: end;
}

.chat__composer-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  font-family: inherit;
  resize: vertical;
  min-height: 44px;
}

.chat__composer-input:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.chat__composer-send {
  min-height: 44px;
}

.chat__send-error {
  margin-top: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-radius: var(--radius-sm);
  font-size: var(--font-size-xs);
  text-align: center;
}
