﻿/* ============================================================
   COMPONENTS — Cards, buttons, badges, cart drawer, toast
   ============================================================ */

/* ---------- Product card ---------- */
.product-card {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform var(--tr-base), box-shadow var(--tr-base), border-color var(--tr-base);
  position: relative;
}

.product-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--sh-lg);
  border-color: var(--c-primary);
}

.product-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(135deg, #FFF8E1, #FFFDF5);
  overflow: hidden;
}

.product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--tr-slow);
}

.product-card:hover .product-img {
  transform: scale(1.05);
}

.product-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  background: var(--c-secondary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: var(--r-full);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.product-badge[data-variant="sale"]     { background: var(--c-danger); }
.product-badge[data-variant="new"]      { background: #0288D1; }
.product-badge[data-variant="value"]    { background: var(--c-primary); color: var(--c-secondary); }

.product-body {
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}

.product-name {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-size {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  font-weight: 500;
}

.product-price-row {
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  margin-top: auto;
}

.product-price {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--c-secondary);
  letter-spacing: -0.3px;
}

.product-old-price {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
  text-decoration: line-through;
}

.product-add {
  margin-top: var(--sp-2);
  width: 100%;
  padding: 10px 12px;
  background: var(--c-primary);
  color: var(--c-secondary);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--tr-fast);
}

.product-add:hover {
  background: var(--c-primary-dark);
  transform: translateY(-1px);
}

.product-add:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.product-out {
  margin-top: var(--sp-2);
  width: 100%;
  padding: 10px 12px;
  background: var(--c-border);
  color: var(--c-text-muted);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: not-allowed;
}

/* ---------- Cart drawer ---------- */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tr-base);
  z-index: 200;
}

.cart-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 420px;
  background: var(--c-card);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--tr-base);
  z-index: 201;
  box-shadow: -8px 0 32px rgba(0,0,0,0.15);
}

.cart-drawer.open {
  transform: translateX(0);
}

.cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--c-border);
}

.cart-head h2 {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--c-secondary);
}

.cart-close {
  width: 36px;
  height: 36px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-text-muted);
  transition: background var(--tr-fast);
}

.cart-close:hover {
  background: var(--c-bg);
}

.cart-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4);
}

.cart-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-bottom: 1px solid var(--c-border);
  align-items: center;
}

.cart-item:last-child { border-bottom: none; }

.cart-item-img {
  width: 64px;
  height: 64px;
  border-radius: var(--r-sm);
  object-fit: cover;
  background: var(--c-bg);
}

.cart-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cart-item-name {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-item-price {
  font-size: var(--fs-xs);
  color: var(--c-text-muted);
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: 4px;
}

.qty-btn {
  width: 26px;
  height: 26px;
  border-radius: var(--r-sm);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--c-secondary);
  transition: all var(--tr-fast);
}

.qty-btn:hover {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: var(--c-secondary);
}

.qty-val {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: var(--fs-sm);
}

.cart-item-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.cart-item-total {
  font-weight: 800;
  font-size: var(--fs-sm);
  color: var(--c-secondary);
}

.cart-item-remove {
  color: var(--c-danger);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  transition: opacity var(--tr-fast);
}

.cart-item-remove:hover {
  opacity: 0.7;
}

.cart-empty {
  text-align: center;
  padding: var(--sp-7) var(--sp-4);
  color: var(--c-text-muted);
}

.cart-empty-icon {
  font-size: 56px;
  margin-bottom: var(--sp-3);
}

.cart-foot {
  border-top: 1px solid var(--c-border);
  padding: var(--sp-4);
  background: var(--c-bg);
}

.cart-summary {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--fs-sm);
}

.summary-row.total {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--c-secondary);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--c-border);
  margin-top: var(--sp-2);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--c-secondary);
  color: #fff;
  border-radius: var(--r-md);
  font-weight: 700;
  font-size: var(--fs-md);
  transition: all var(--tr-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--c-secondary-dark);
  transform: translateY(-1px);
  box-shadow: var(--sh-md);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-ghost {
  width: 100%;
  padding: 12px;
  background: transparent;
  color: var(--c-secondary);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: var(--fs-sm);
  transition: all var(--tr-fast);
}

.btn-ghost:hover {
  border-color: var(--c-secondary);
  background: #fff;
}

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}

.toast {
  background: var(--c-secondary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-weight: 600;
  box-shadow: var(--sh-lg);
  animation: slideIn 300ms ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.toast[data-type="success"] { background: var(--c-success); }
.toast[data-type="error"]   { background: var(--c-danger); }
.toast[data-type="info"]    { background: #0288D1; }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(30px); }
}

.toast.out { animation: slideOut 250ms ease forwards; }

/* ---------- Mobile sticky checkout bar ---------- */
.checkout-bar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  background: var(--c-card);
  border-top: 1px solid var(--c-border);
  padding: var(--sp-3) var(--sp-4);
  z-index: 80;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

.checkout-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
}

.checkout-bar-total {
  font-weight: 800;
  color: var(--c-secondary);
  font-size: var(--fs-lg);
}

@media (max-width: 640px) {
  .checkout-bar.visible { display: block; }
  body { padding-bottom: 76px; }
  .cart-drawer { max-width: 100%; }
}

/* ---------- Loading skeleton ---------- */
.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
/* Hero feature card polish */
.feature {
  min-height: 80px;
  align-items: center;
}
.feature-icon {
  font-size: 14px;
  font-weight: 800;
  color: var(--c-secondary);
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 6px 10px;
  flex-shrink: 0;
  text-align: center;
  min-width: 60px;
}
.feature-title {
  line-height: 1.2;
  margin-bottom: 2px;
}
.feature-desc {
  line-height: 1.2;
}

/* Product card image ratio fix */
.product-media {
  aspect-ratio: 1 / 1;
  background: #fff;
}
.product-img {
  object-fit: contain;
  padding: 8px;
}

/* ---------- Product card polish (Phase 5) ---------- */
.product-card {
  border-radius: var(--r-md);
}
.product-media {
  aspect-ratio: 1 / 1;
}
.product-body {
  padding: 14px;
  gap: 6px;
}
.product-name {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.35;
}
.product-size {
  font-size: 12px;
  font-weight: 600;
}
.product-price {
  font-size: 20px;
}
.product-add {
  padding: 12px;
  font-size: 14px;
  font-weight: 800;
}

/* Larger grid on desktop */
@media (min-width: 900px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
}
@media (min-width: 1200px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Larger feature cards in hero */
.feature {
  padding: 16px 20px;
  min-height: 90px;
}
.feature-icon {
  font-size: 15px;
  padding: 8px 12px;
  min-width: 68px;
}
.feature-title {
  font-size: 15px;
}
.feature-desc {
  font-size: 12px;
}
