/* Copyright (c) 2025-2026 Spwig contributors. Licensed under AGPL-3.0. */

/**
 * Cart Page Styles
 * Scoped to the shopping cart page
 */

/* Cart Layout */
.cart-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--theme-space-8, 2rem);
}

@media (min-width: 768px) {
  .cart-layout {
    grid-template-columns: 1fr 360px;
  }
}

/* Empty Cart */
.cart-empty {
  text-align: center;
  padding: var(--theme-space-16, 4rem) var(--theme-space-4, 1rem);
}

.cart-empty__icon {
  font-size: 4rem;
  color: var(--theme-color-text-muted, #6b7280);
  margin-bottom: var(--theme-space-4, 1rem);
}

.cart-empty__title {
  font-size: var(--theme-font-size-2xl, 1.5rem);
  font-weight: var(--theme-font-weight-semibold, 600);
  color: var(--theme-color-text, #1f2937);
  margin-bottom: var(--theme-space-2, 0.5rem);
}

.cart-empty__text {
  color: var(--theme-color-text-muted, #6b7280);
  margin-bottom: var(--theme-space-6, 1.5rem);
}

/* Cart List */
.cart-list {
  background: var(--theme-color-surface, #fff);
  border-radius: var(--theme-radius-lg, 0.75rem);
  box-shadow: var(--theme-shadow-base, 0 1px 3px rgba(0, 0, 0, 0.1));
  overflow: hidden;
}

/* Cart Item - Mobile First */
.cart-item {
  display: flex;
  gap: var(--theme-space-2, 0.5rem);
  padding: var(--theme-space-3, 0.75rem);
  border-bottom: 1px solid var(--theme-color-border, #e5e7eb);
}

@media (min-width: 640px) {
  .cart-item {
    gap: var(--theme-space-4, 1rem);
    padding: var(--theme-space-4, 1rem);
  }
}

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

/* Image - Mobile First (smaller on mobile) */
.cart-item__image {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--theme-radius-base, 0.375rem);
  background-color: var(--theme-color-background-secondary, #f9fafb);
  flex-shrink: 0;
}

@media (min-width: 640px) {
  .cart-item__image {
    width: 80px;
    height: 80px;
  }
}

@media (min-width: 768px) {
  .cart-item__image {
    width: 100px;
    height: 100px;
  }
}

.cart-item__details {
  flex: 1;
  min-width: 0;
}

.cart-item__name {
  font-weight: var(--theme-font-weight-medium, 500);
  color: var(--theme-color-text, #1f2937);
  margin-bottom: var(--theme-space-1, 0.25rem);
  text-decoration: none;
  display: block;
  overflow-wrap: break-word;
  word-break: break-word;
  font-size: var(--theme-font-size-sm, 0.875rem);
}

@media (min-width: 640px) {
  .cart-item__name {
    font-size: var(--theme-font-size-base, 1rem);
  }
}

.cart-item__name:hover {
  color: var(--theme-color-primary, #2563eb);
}

.cart-item__variant {
  font-size: var(--theme-font-size-sm, 0.875rem);
  color: var(--theme-color-text-muted, #6b7280);
  margin-bottom: var(--theme-space-2, 0.5rem);
}

/* Price - Mobile First (smaller on mobile) */
.cart-item__price {
  font-weight: var(--theme-font-weight-semibold, 600);
  color: var(--theme-color-text, #1f2937);
  margin-bottom: var(--theme-space-2, 0.5rem);
  font-size: var(--theme-font-size-sm, 0.875rem);
}

@media (min-width: 640px) {
  .cart-item__price {
    font-size: var(--theme-font-size-base, 1rem);
  }
}

/* Actions - Mobile First (smaller gap) */
.cart-item__actions {
  display: flex;
  align-items: center;
  gap: var(--theme-space-2, 0.5rem);
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .cart-item__actions {
    gap: var(--theme-space-4, 1rem);
  }
}

/* Quantity - Mobile First (smaller controls) */
.cart-item__quantity {
  display: flex;
  align-items: center;
  gap: var(--theme-space-1, 0.25rem);
}

@media (min-width: 640px) {
  .cart-item__quantity {
    gap: var(--theme-space-2, 0.5rem);
  }
}

.cart-item__quantity button {
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--theme-color-border, #e5e7eb);
  border-radius: var(--theme-radius-base, 0.375rem);
  background: var(--theme-color-surface, #fff);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--theme-color-text, #1f2937);
  font-size: 0.625rem;
  transition: background-color 0.15s ease;
}

@media (min-width: 640px) {
  .cart-item__quantity button {
    width: 2rem;
    height: 2rem;
    font-size: 0.75rem;
  }
}

.cart-item__quantity button:hover {
  background: var(--theme-color-background-secondary, #f9fafb);
}

/* Quantity Input - Mobile First */
.cart-item__quantity input {
  width: 2.5rem;
  text-align: center;
  border: 1px solid var(--theme-color-border, #e5e7eb);
  border-radius: var(--theme-radius-base, 0.375rem);
  padding: var(--theme-space-1, 0.25rem);
  font-size: var(--theme-font-size-xs, 0.75rem);
}

@media (min-width: 640px) {
  .cart-item__quantity input {
    width: 3rem;
    font-size: var(--theme-font-size-sm, 0.875rem);
  }
}

/* Line Total - Mobile First */
.cart-item__line-total {
  font-weight: var(--theme-font-weight-semibold, 600);
  color: var(--theme-color-text, #1f2937);
  font-size: var(--theme-font-size-sm, 0.875rem);
  white-space: nowrap;
}

@media (min-width: 640px) {
  .cart-item__line-total {
    font-size: var(--theme-font-size-base, 1rem);
  }
}

.cart-item__remove {
  color: var(--theme-color-text-muted, #6b7280);
  cursor: pointer;
  padding: var(--theme-space-2, 0.5rem);
  background: none;
  border: none;
  font-size: 0.875rem;
  transition: color 0.15s ease;
}

.cart-item__remove:hover {
  color: var(--theme-color-error, #ef4444);
}

/* Cart Summary */
.cart-summary__card {
  background: var(--theme-color-surface, #fff);
  padding: var(--theme-space-6, 1.5rem);
  border-radius: var(--theme-radius-lg, 0.75rem);
  box-shadow: var(--theme-shadow-base, 0 1px 3px rgba(0, 0, 0, 0.1));
  position: sticky;
  top: var(--theme-space-4, 1rem);
}

.cart-summary__title {
  font-size: var(--theme-font-size-lg, 1.125rem);
  font-weight: var(--theme-font-weight-semibold, 600);
  color: var(--theme-color-text, #1f2937);
  margin-bottom: var(--theme-space-4, 1rem);
  padding-bottom: var(--theme-space-4, 1rem);
  border-bottom: 1px solid var(--theme-color-border, #e5e7eb);
}

.cart-summary__row {
  display: flex;
  justify-content: space-between;
  margin-bottom: var(--theme-space-3, 0.75rem);
  color: var(--theme-color-text-muted, #6b7280);
}

.cart-summary__row--discount {
  color: var(--theme-color-success, #059669);
}

.cart-summary__row--total {
  font-size: var(--theme-font-size-lg, 1.125rem);
  font-weight: var(--theme-font-weight-semibold, 600);
  color: var(--theme-color-text, #1f2937);
  padding-top: var(--theme-space-3, 0.75rem);
  border-top: 1px solid var(--theme-color-border, #e5e7eb);
  margin-top: var(--theme-space-3, 0.75rem);
}

.cart-voucher {
  margin: var(--theme-space-4, 1rem) 0;
  padding: var(--theme-space-4, 1rem) 0;
  border-top: 1px solid var(--theme-color-border, #e5e7eb);
  border-bottom: 1px solid var(--theme-color-border, #e5e7eb);
}

.cart-voucher__input {
  display: flex;
  gap: var(--theme-space-2, 0.5rem);
}

.cart-voucher__input .form-input {
  flex: 1;
}

.cart-voucher__error {
  color: var(--theme-color-error, #ef4444);
  font-size: var(--theme-font-size-sm, 0.875rem);
  margin-top: var(--theme-space-2, 0.5rem);
}

.cart-voucher__success {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--theme-color-success-bg, #f0fdf4);
  color: var(--theme-color-success, #059669);
  padding: var(--theme-space-2, 0.5rem) var(--theme-space-3, 0.75rem);
  border-radius: var(--theme-radius-base, 0.375rem);
  font-size: var(--theme-font-size-sm, 0.875rem);
  margin-top: var(--theme-space-2, 0.5rem);
}

.cart-voucher__remove {
  background: none;
  border: none;
  color: var(--theme-color-text-muted, #6b7280);
  cursor: pointer;
  font-size: 0.75rem;
  padding: var(--theme-space-1, 0.25rem);
}

.cart-voucher__remove:hover {
  color: var(--theme-color-error, #ef4444);
}

.cart-summary__continue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--theme-space-2, 0.5rem);
  margin-top: var(--theme-space-4, 1rem);
  color: var(--theme-color-text-muted, #6b7280);
  font-size: var(--theme-font-size-sm, 0.875rem);
  text-decoration: none;
}

.cart-summary__continue:hover {
  color: var(--theme-color-primary, #2563eb);
}

.btn--full {
  width: 100%;
  justify-content: center;
}

/* Loading state */
.cart-loading {
  text-align: center;
  padding: var(--theme-space-8, 2rem);
  color: var(--theme-color-text-muted, #6b7280);
}

.cart-loading__spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--theme-color-border, #e5e7eb);
  border-top-color: var(--theme-color-primary, #2563eb);
  border-radius: 50%;
  animation: cart-spin 0.8s linear infinite;
  margin: 0 auto var(--theme-space-3, 0.75rem);
}

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