/* ================================================================
   4RAU — Component Library CSS
   Phase 3: Reusable UI components
   All colors via design-system.css variables
================================================================ */


/* ── 1. PRODUCT CARD ──────────────────────────────────────────── */

.product-card {
  background: #fff;
  border: 1px solid var(--cp-border-light);
  border-radius: var(--cp-radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: box-shadow .22s ease, transform .22s ease;
}

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

/* Image wrapper */
.product-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: #f8f8f8;
  flex-shrink: 0;
}

.product-thumb > a {
  display: block;
  width: 100%; height: 100%;
}

.product-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .35s ease;
}

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

/* Badges */
.sticker-new {
  position: absolute;
  top: 10px; left: 10px;
  padding: 3px 9px;
  border-radius: var(--cp-radius-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  line-height: 1.4;
  z-index: 2;
}

.sticker-new.label-sale {
  background: var(--cp-sale);
  color: #fff;
}

.sticker-new.soldout-title {
  background: #374151;
  color: #fff;
}

.sap-low-stock {
  position: absolute;
  bottom: 8px; left: 8px;
  padding: 2px 8px;
  border-radius: var(--cp-radius-pill);
  font-size: 10px;
  font-weight: 700;
  background: #fff3cd;
  color: #92400e;
  border: 1px solid #fcd34d;
  z-index: 2;
}

/* Countdown timer (flash sale) */
.product-countdown {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 4px 8px;
  background: rgba(0,0,0,.55);
  text-align: center;
  z-index: 2;
}

.product-countdown [data-countdown] {
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .02em;
}

/* Quick-view hover overlay */
.product-card-actions {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  background: linear-gradient(to top, rgba(0,0,0,.35), transparent);
  opacity: 0;
  transition: opacity .22s ease;
  z-index: 3;
}

.product-card:hover .product-card-actions {
  opacity: 1;
}

.pca-btn {
  width: 34px; height: 34px;
  border-radius: 9999px;
  border: none;
  background: rgba(255,255,255,.92);
  color: var(--cp-text-primary);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, transform .15s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
}

.pca-btn:hover {
  background: var(--cp-primary);
  color: #fff;
  transform: scale(1.08);
}

/* Info area */
.product-info {
  padding: 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--cp-text-primary);
  line-height: 1.45;
  margin: 0;
}

.product-name-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-name a {
  color: inherit;
  text-decoration: none;
  transition: color .15s ease;
}

.product-name a:hover {
  color: var(--cp-primary);
  text-decoration: none;
}

/* Price */
.product-price {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
}

.product-price .current-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--cp-sale);
}

.product-price .old-price {
  font-size: 12px;
  font-weight: 400;
  color: var(--cp-text-muted);
  text-decoration: line-through;
}

/* Sold count chip */
.sap-sold-chip {
  font-size: 11.5px;
  color: var(--cp-text-muted);
  margin-top: 2px;
}

.sap-sold-chip strong {
  color: var(--cp-text-secondary);
  font-weight: 600;
}

/* Action buttons */
.card-btn-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
}

.btn-listing-cart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--cp-radius-sm);
  border: 1.5px solid var(--cp-primary);
  background: transparent;
  color: var(--cp-primary);
  font-family: var(--cp-font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
  flex-shrink: 0;
}

.btn-listing-cart:hover {
  background: var(--cp-primary);
  color: #fff;
}

.btn-buynow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border-radius: var(--cp-radius-sm);
  border: none;
  background: var(--cp-gradient);
  color: #fff;
  font-family: var(--cp-font-body);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity .15s ease;
}

.btn-buynow:hover {
  opacity: .88;
  color: #fff;
}

.btn-listing-cart--soldout {
  display: block;
  width: 100%;
  padding: 7px;
  border-radius: var(--cp-radius-sm);
  border: 1px solid var(--cp-border);
  background: #f9f9f9;
  color: var(--cp-text-muted);
  font-size: 12px;
  cursor: not-allowed;
}


/* ── 2. SECTION HEADER ────────────────────────────────────────── */

.cp-section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--cp-primary);
  margin-bottom: 24px;
}

.cp-section-title {
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  font-weight: 700;
  color: var(--cp-primary);
  letter-spacing: .03em;
  text-transform: uppercase;
  margin: 0;
  line-height: 1.2;
}

.cp-section-link {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--cp-primary);
  text-decoration: none;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-bottom: 1px solid transparent;
  transition: border-color .15s ease;
  flex-shrink: 0;
}

.cp-section-link:hover {
  border-bottom-color: var(--cp-primary);
  text-decoration: none;
  color: var(--cp-primary);
}

.cp-section-link i {
  font-size: 11px;
}


/* ── 3. BREADCRUMB ────────────────────────────────────────────── */

.cp-breadcrumb {
  padding: 10px 0;
}

.cp-breadcrumb .breadcrumb {
  margin: 0;
  padding: 0;
  background: none;
  flex-wrap: wrap;
}

.cp-breadcrumb .breadcrumb-item {
  font-size: 12.5px;
  color: var(--cp-text-muted);
}

.cp-breadcrumb .breadcrumb-item a {
  color: var(--cp-text-muted);
  text-decoration: none;
  transition: color .15s ease;
}

.cp-breadcrumb .breadcrumb-item a:hover {
  color: var(--cp-primary);
  text-decoration: none;
}

.cp-breadcrumb .breadcrumb-item.active {
  color: var(--cp-text-primary);
  font-weight: 600;
}

.cp-breadcrumb .breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  color: var(--cp-border);
  font-size: 14px;
  line-height: 1;
}


/* ── 4. PAGINATION ────────────────────────────────────────────── */

.cp-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.cp-pagination .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  border-radius: var(--cp-radius-sm);
  border: 1.5px solid var(--cp-border);
  background: #fff;
  color: var(--cp-text-primary);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all .15s ease;
  line-height: 1;
}

.cp-pagination .page-link:hover {
  border-color: var(--cp-primary);
  color: var(--cp-primary);
  text-decoration: none;
}

.cp-pagination .page-item.active .page-link {
  background: var(--cp-gradient);
  border-color: var(--cp-primary);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(67,88,70,.3);
}

.cp-pagination .page-item.disabled .page-link {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

.cp-pagination-info {
  font-size: 12.5px;
  color: var(--cp-text-muted);
  text-align: center;
  margin-top: 8px;
}


/* ── 5. TOAST ─────────────────────────────────────────────────── */

.cp-toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 320px;
  width: calc(100vw - 48px);
}

.cp-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--cp-radius);
  background: #fff;
  border-left: 4px solid var(--cp-primary);
  box-shadow: 0 8px 24px rgba(0,0,0,.14);
  pointer-events: all;
  animation: cpToastIn .25s ease;
}

.cp-toast.is-success { border-left-color: var(--cp-primary); }
.cp-toast.is-error   { border-left-color: var(--cp-sale); }
.cp-toast.is-warning { border-left-color: #f59e0b; }
.cp-toast.is-info    { border-left-color: #3b82f6; }

.cp-toast__icon {
  font-size: 16px;
  margin-top: 1px;
  flex-shrink: 0;
}

.cp-toast.is-success .cp-toast__icon { color: var(--cp-primary); }
.cp-toast.is-error   .cp-toast__icon { color: var(--cp-sale); }
.cp-toast.is-warning .cp-toast__icon { color: #f59e0b; }
.cp-toast.is-info    .cp-toast__icon { color: #3b82f6; }

.cp-toast__body {
  flex: 1;
  min-width: 0;
}

.cp-toast__title {
  font-size: 13px;
  font-weight: 700;
  color: var(--cp-text-primary);
  margin: 0 0 2px;
  line-height: 1.3;
}

.cp-toast__msg {
  font-size: 12.5px;
  color: var(--cp-text-secondary);
  margin: 0;
  line-height: 1.4;
}

.cp-toast__close {
  background: none;
  border: none;
  padding: 0;
  color: var(--cp-text-muted);
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 1px;
  transition: color .15s ease;
}

.cp-toast__close:hover {
  color: var(--cp-text-primary);
}

.cp-toast.is-leaving {
  animation: cpToastOut .22s ease forwards;
}

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

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


/* ── 6. RESPONSIVE ────────────────────────────────────────────── */

@media (max-width: 575.98px) {
  .product-info { padding: 10px; }
  .product-name { font-size: 12.5px; }
  .card-btn-row { grid-template-columns: 1fr; }
  .btn-listing-cart { display: none; } /* mobile: chỉ giữ nút Mua ngay */
  .btn-buynow { grid-column: 1; }

  .cp-toast-container {
    bottom: 16px; right: 12px;
    width: calc(100vw - 24px);
  }
}
