/* ==========================================================================
   BOURGIGROUP — SHOP & CART
   Stripe / Linear aesthetic — premium product experience
   ========================================================================== */

/* --------------------------------------------------------------------------
   CATALOGUE PAGE
   -------------------------------------------------------------------------- */
.shop-page {
  max-width: var(--content-max);
  margin: 0 auto;
}

.shop-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}

.shop-count {
  margin-left: auto;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 10px;
  border-radius: var(--r-full);
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   PRODUCT GRID — fluid, never breaks
   -------------------------------------------------------------------------- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr));
  gap: var(--sp-4);
}

/* --------------------------------------------------------------------------
   PRODUCT CARD — Apple-store level polish
   -------------------------------------------------------------------------- */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition:
    box-shadow var(--ease-md),
    transform var(--ease-md),
    border-color var(--ease);
  text-decoration: none;
  position: relative;
}
.product-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
  border-color: var(--border);
}
.product-card:active {
  transform: translateY(0);
}

/* Image */
.product-card-image {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface-2);
  overflow: hidden;
  flex-shrink: 0;
}
.product-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.product-card:hover .product-card-image img {
  transform: scale(1.04);
}
.product-card-image .no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--surface-3);
  font-size: 2rem;
}

/* Stock status badge */
.stock-badge {
  position: absolute;
  top: var(--sp-2);
  left: var(--sp-2);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-full);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.stock-badge.in-stock {
  background: rgba(240, 253, 244, 0.92);
  color: var(--success);
  border: 1px solid rgba(134, 239, 172, 0.5);
}
.stock-badge.out-of-stock {
  background: rgba(254, 242, 242, 0.92);
  color: var(--danger);
  border: 1px solid rgba(252, 165, 165, 0.5);
}

/* Card body */
.product-card-body {
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  flex: 1;
}

.product-card-ref {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-4);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.product-card-name {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-1);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}

.product-card-price {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-top: var(--sp-2);
  letter-spacing: -0.3px;
}
.product-card-price small {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--accent-dark);
  margin-left: 2px;
  opacity: 0.75;
}

/* Add to cart button */
.btn-add-cart {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  margin-top: var(--sp-3);
  padding: 0;
  background: var(--primary);
  border: none;
  border-radius: var(--r-sm);
  color: #fff;
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  transition:
    background var(--ease),
    box-shadow var(--ease),
    transform 0.1s;
  letter-spacing: 0.01em;
}
.btn-add-cart:hover {
  background: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.btn-add-cart:active {
  transform: scale(0.98);
}
.btn-add-cart:disabled {
  background: var(--surface-2);
  color: var(--text-4);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Qty stepper — replaces button when in cart */
.qty-stepper {
  display: flex;
  align-items: center;
  margin-top: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
  height: 36px;
}
.qty-stepper button {
  flex-shrink: 0;
  width: 36px;
  height: 100%;
  border: none;
  background: var(--surface-1);
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background var(--ease),
    color var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
}
.qty-stepper button:hover {
  background: var(--primary-light);
}
.qty-stepper button:disabled {
  color: var(--text-4);
  cursor: not-allowed;
}
.qty-stepper button:disabled:hover {
  background: var(--surface-1);
}
.qty-stepper .qty-value {
  flex: 1;
  text-align: center;
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-1);
  background: var(--surface);
  border: none;
  outline: none;
  padding: 0;
  min-width: 0;
}

/* Pagination */
.shop-pagination {
  display: flex;
  justify-content: center;
  padding: var(--sp-6) 0 var(--sp-2);
}

/* --------------------------------------------------------------------------
   CART PAGE
   -------------------------------------------------------------------------- */
.cart-page {
  max-width: 860px;
  margin: 0 auto;
}

.cart-page-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.cart-page-header h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.3px;
}

/* Empty cart */
.cart-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-align: center;
  padding: var(--sp-12) var(--sp-8);
}
.cart-empty-icon {
  font-size: 2.5rem;
  opacity: 0.3;
  margin-bottom: var(--sp-3);
}
.cart-empty p {
  font-size: var(--text-base);
  color: var(--text-3);
  margin-bottom: var(--sp-5);
}

/* Cart table */
.cart-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-3);
  box-shadow: var(--shadow-sm);
}
.cart-table thead th {
  background: var(--surface-1);
  padding: 10px 16px;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.cart-table tbody tr {
  border-bottom: 1px solid var(--border-soft);
  transition: background var(--ease);
}
.cart-table tbody tr:last-child {
  border-bottom: none;
}
.cart-table tbody tr:hover {
  background: var(--surface-1);
}
.cart-table td {
  padding: var(--sp-3) 16px;
  vertical-align: middle;
  font-size: var(--text-base);
  color: var(--text-2);
}

/* Cart images */
.cart-item-image {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.cart-item-img-placeholder {
  width: 48px;
  height: 48px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--surface-3);
  font-size: 1.2rem;
}
.cart-item-name {
  font-weight: 600;
  color: var(--text-1);
  font-size: var(--text-base);
  text-decoration: none;
  display: block;
  line-height: 1.4;
}
.cart-item-name:hover {
  color: var(--primary);
}
.cart-item-ref {
  font-size: var(--text-xs);
  color: var(--text-4);
  font-weight: 500;
  margin-top: 2px;
}
.cart-stock-val {
  font-size: var(--text-sm);
  font-weight: 600;
}

/* Cart stepper */
.cart-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface);
  height: 34px;
}
.cart-stepper button {
  width: 32px;
  height: 100%;
  border: none;
  background: var(--surface-1);
  color: var(--primary);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  flex-shrink: 0;
}
.cart-stepper button:hover {
  background: var(--primary-light);
}
.cart-stepper button:disabled {
  color: var(--text-4);
  cursor: not-allowed;
}
.cart-stepper button:disabled:hover {
  background: var(--surface-1);
}
.cart-stepper .cart-qty {
  width: clamp(3ch, 4ch, 8ch);
  height: 100%;
  text-align: center;
  font-size: var(--text-base);
  font-weight: 700;
  border: none;
  outline: none;
  padding: 0 4px;
  background: var(--surface);
  color: var(--text-1);
  -moz-appearance: textfield;
  appearance: textfield;
}
.cart-stepper .cart-qty::-webkit-outer-spin-button,
.cart-stepper .cart-qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
}

/* Row total */
.cart-item-total {
  font-weight: 700;
  color: var(--accent);
  white-space: nowrap;
  font-size: var(--text-md);
}

/* Remove button */
.btn-remove-item {
  background: none;
  border: none;
  color: var(--surface-3);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--r-sm);
  transition:
    color var(--ease),
    background var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-remove-item:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* Cart summary */
.cart-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6);
  box-shadow: var(--shadow-sm);
}
.cart-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-base);
  color: var(--text-3);
  padding: 3px 0;
}
.cart-summary-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-3) 0;
}
.cart-summary-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--text-1);
}

/* Order CTA */
.btn-order {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: var(--sp-4);
  background: var(--accent);
  border: none;
  border-radius: var(--r-sm);
  color: #fff;
  font-family: var(--font);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  transition:
    background var(--ease),
    box-shadow var(--ease),
    transform 0.1s;
  letter-spacing: 0.02em;
}
.btn-order:hover {
  background: var(--accent-dark);
  box-shadow: 0 2px 10px rgba(249, 115, 22, 0.35);
}
.btn-order:active {
  transform: scale(0.99);
}
.btn-order:disabled {
  background: var(--surface-2);
  color: var(--text-4);
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-3);
  }
  .product-card-body {
    padding: var(--sp-2) var(--sp-3) var(--sp-3);
  }
  .product-card-name {
    font-size: var(--text-sm);
  }

  .cart-table thead {
    display: none;
  }
  .cart-table tr {
    display: block;
    border-bottom: 1px solid var(--border-soft);
  }
  .cart-table td {
    display: block;
    padding: var(--sp-2) var(--sp-3);
    border: none;
  }
  .cart-table tr:first-child td:first-child {
    padding-top: var(--sp-3);
  }
  .cart-table tr:last-child td:last-child {
    padding-bottom: var(--sp-3);
  }
  .cart-summary {
    padding: var(--sp-4);
  }
}

@media (max-width: 400px) {
  .product-grid {
    gap: var(--sp-2);
  }
}

/* ── Grid + Details stepper — typeable quantity input ─────────────────── */
.qty-stepper input.qty-value {
  border: none;
  outline: none;
  background: transparent;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  color: inherit;
  padding: 0;
  min-width: 1ch;
  -moz-appearance: textfield;
  appearance: textfield;
}
.qty-stepper input.qty-value::-webkit-outer-spin-button,
.qty-stepper input.qty-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}
.qty-stepper input.qty-value:focus {
  outline: none;
  box-shadow: none;
}
