/* ==========================================================================
   Cart Page Styles
   Matches React Cart.tsx layout: 3-column grid (2 + 1 sidebar)
   ========================================================================== */

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.pe-cart-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1024px) {
  .pe-cart-layout {
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
  }
}


/* --------------------------------------------------------------------------
   Cart Header (desktop only)
   -------------------------------------------------------------------------- */
.pe-cart-header {
  display: none;
}

@media (min-width: 768px) {
  .pe-cart-header {
    display: grid;
    grid-template-columns: 1fr 120px 120px 40px;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid hsl(var(--border));
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
  }

  .pe-cart-header__qty {
    text-align: center;
  }

  .pe-cart-header__total {
    text-align: right;
  }
}


/* --------------------------------------------------------------------------
   Cart Items
   -------------------------------------------------------------------------- */
.pe-cart-items {
  /* no special styles needed */
}


/* --------------------------------------------------------------------------
   Cart Item Row
   -------------------------------------------------------------------------- */
.pe-cart-item {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 1rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid hsl(var(--border));
  align-items: center;
}

@media (min-width: 768px) {
  .pe-cart-item {
    grid-template-columns: 1fr 120px 120px 40px;
    gap: 1rem;
  }
}


/* Product info (image + name + variant) */
.pe-cart-item__product {
  display: flex;
  align-items: center;
  gap: 1rem;
  grid-column: 1 / -1;
}

@media (min-width: 768px) {
  .pe-cart-item__product {
    grid-column: auto;
  }
}

.pe-cart-item__image {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
}

.pe-cart-item__image img {
  width: 80px;
  height: 80px;
  border-radius: var(--pe-radius-md);
  object-fit: cover;
  border: 1px solid hsl(var(--border));
}

.pe-cart-item__info {
  min-width: 0;
}

.pe-cart-item__name {
  font-weight: 500;
  color: hsl(var(--foreground));
  text-decoration: none;
  transition: color var(--pe-transition-fast);
  display: block;
}

.pe-cart-item__name:hover {
  color: hsl(var(--primary));
}

.pe-cart-item__variant {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.125rem;
}

.pe-cart-item__mobile-price {
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 0.25rem;
}

@media (min-width: 768px) {
  .pe-cart-item__mobile-price {
    display: none;
  }
}


/* Quantity controls */
.pe-cart-item__qty {
  display: flex;
  align-items: center;
  justify-content: center;
  grid-column: 2;
}

@media (min-width: 768px) {
  .pe-cart-item__qty {
    grid-column: auto;
  }
}

.pe-cart-item__qty-controls {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pe-cart-item__qty-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 0.25rem;
  border: 1px solid hsl(var(--border));
  background: transparent;
  cursor: pointer;
  transition: background-color var(--pe-transition-fast);
  color: hsl(var(--foreground));
  padding: 0 !important; /* override Storefront button padding */
}

.pe-cart-item__qty-btn:hover {
  background-color: hsl(var(--secondary));
}

.pe-cart-item__qty-input {
  width: 2.5rem;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  background: transparent;
  color: hsl(var(--foreground));
  -moz-appearance: textfield;
  appearance: textfield;
  padding: 0;
}

.pe-cart-item__qty-input::-webkit-outer-spin-button,
.pe-cart-item__qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}


/* Subtotal */
.pe-cart-item__subtotal {
  display: none;
}

@media (min-width: 768px) {
  .pe-cart-item__subtotal {
    display: block;
    text-align: right;
    font-weight: 600;
    color: hsl(var(--foreground));
  }
}


/* Remove button */
.pe-cart-item__remove {
  display: none;
}

@media (min-width: 768px) {
  .pe-cart-item__remove {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}

.pe-cart-remove-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: hsl(var(--muted-foreground));
  transition: color var(--pe-transition-fast);
  padding: 0 !important;
  background: none !important;
  border: none !important;
  width: 2rem !important;
  height: 2rem !important;
  font-size: 1rem !important;    /* Reset from Storefront's em-based sizing */
  text-indent: 0 !important;     /* Override Storefront's -9999px */
  overflow: visible !important;  /* Override Storefront's hidden */
  position: relative;
}

.pe-cart-remove-btn svg {
  display: block;
  flex-shrink: 0;
}

.pe-cart-remove-btn:hover {
  color: hsl(var(--destructive));
  background: none !important;
}

/* Remove the default WC × character and FA icons */
.pe-cart-remove-btn::before,
.pe-cart-remove-btn::after {
  display: none !important;
  content: none !important;
}


/* --------------------------------------------------------------------------
   Coupon + Update Cart actions
   -------------------------------------------------------------------------- */
.pe-cart-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.pe-cart-coupon {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.pe-cart-coupon__input {
  max-width: 220px;
}

.pe-cart-coupon__btn {
  white-space: nowrap;
}

/* Hide the "Update cart" button — quantity changes auto-submit via JS */
.pe-cart-update {
  display: none !important;
}

@media (max-width: 767px) {
  .pe-cart-update {
    display: none !important;
  }
}


/* --------------------------------------------------------------------------
   Order Summary Sidebar
   -------------------------------------------------------------------------- */
.pe-cart-summary {
  border: 1px solid hsl(var(--border));
  border-radius: var(--pe-radius);
  padding: 1.5rem;
  background-color: hsl(var(--card));
}

@media (min-width: 1024px) {
  .pe-cart-summary {
    position: sticky;
    top: 6rem; /* below sticky header */
  }
}

.pe-cart-summary__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.125rem;
  margin-bottom: 1rem;
  color: hsl(var(--foreground));
}

.pe-cart-summary__rows {
  font-size: 0.875rem;
}

.pe-cart-summary__row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
}

.pe-cart-summary__row--border {
  border-bottom: 1px solid hsl(var(--border));
}

.pe-cart-summary__row--total {
  border-bottom: none;
  padding-top: 0.75rem;
  font-size: 1rem;
}

.pe-cart-summary__label {
  color: hsl(var(--muted-foreground));
}

.pe-cart-summary__label--total {
  font-weight: 700;
  color: hsl(var(--foreground));
}

.pe-cart-summary__value {
  font-weight: 500;
}

.pe-cart-summary__value--total {
  font-weight: 700;
  font-size: 1.125rem;
  color: hsl(var(--foreground));
}

.pe-cart-summary__value--free {
  font-weight: 500;
  color: hsl(var(--primary));
}

.pe-cart-summary__value--shipping {
  text-align: right;
}

/* Shipping method radios within summary */
.pe-cart-summary__value--shipping .woocommerce-shipping-methods {
  list-style: none;
  margin: 0;
  padding: 0;
  text-align: right;
}

.pe-cart-summary__value--shipping .woocommerce-shipping-methods li {
  margin-bottom: 0.25rem;
}

.pe-cart-summary__value--shipping .woocommerce-shipping-methods label {
  font-size: 0.8125rem;
}


/* Checkout button */
.pe-cart-summary__checkout {
  margin-top: 1rem;
}

.pe-cart-summary__checkout .checkout-button,
.pe-cart-summary__checkout .wc-forward {
  display: block;
  width: 100%;
  text-align: center;
  padding: 0.875rem 1.75rem;
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  border-radius: var(--pe-radius-md);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: background-color var(--pe-transition-fast);
  text-decoration: none;
}

.pe-cart-summary__checkout .checkout-button:hover,
.pe-cart-summary__checkout .wc-forward:hover {
  background-color: hsl(0, 0%, 20%);
  color: hsl(var(--primary-foreground));
}


/* --------------------------------------------------------------------------
   Empty Cart
   -------------------------------------------------------------------------- */
.pe-cart-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4rem 2rem;
  min-height: 40vh;
}

.pe-cart-empty__icon {
  margin-bottom: 1.5rem;
  color: hsl(var(--muted-foreground));
}

.pe-cart-empty__title {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

.pe-cart-empty__text {
  color: hsl(var(--muted-foreground));
  margin-bottom: 1.5rem;
  font-size: 0.9375rem;
}

/* Hide the default WC "cart is empty" message — we show our own */
.woocommerce-info.cart-empty,
.cart-empty.woocommerce-info {
  display: none;
}


/* --------------------------------------------------------------------------
   Cart Collaterals (cross-sells)
   -------------------------------------------------------------------------- */
.pe-cart-collaterals {
  margin-top: 3rem;
}

.pe-cart-collaterals .cross-sells h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
}


/* --------------------------------------------------------------------------
   WooCommerce notices override for cart page
   -------------------------------------------------------------------------- */
.pe-cart-page .woocommerce-message,
.pe-cart-page .woocommerce-info,
.pe-cart-page .woocommerce-error {
  border-radius: var(--pe-radius-md);
  font-family: var(--font-body);
  margin-bottom: 1.5rem;
}


/* --------------------------------------------------------------------------
   Page wrapper (breadcrumb + title)
   Storefront wraps cart content inside .content-area > main
   -------------------------------------------------------------------------- */
.pe-cart-page .site-main > .page > .entry-content,
.pe-cart-page .site-main .woocommerce {
  padding-top: 0;
}

/* Remove Storefront's default cart_totals which is now replaced by our sidebar */
.pe-cart-page .cart_totals {
  display: none !important;
}


/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
  .pe-cart-item {
    grid-template-columns: 1fr auto;
    gap: 0.75rem;
    padding: 1rem 0;
  }

  .pe-cart-item__product {
    grid-column: 1 / -1;
  }

  .pe-cart-item__qty {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .pe-cart-summary {
    margin-top: 0;
  }
}


/* --------------------------------------------------------------------------
   Cart/Checkout page header (breadcrumb + title)
   -------------------------------------------------------------------------- */
.pe-cart-page .entry-header,
.pe-checkout-page .entry-header {
  margin-bottom: 0.5rem;
}

/* Override Storefront's centered entry-title and large padding on page header */
.pe-wc-page-header {
  padding: 0 !important;
  margin: 0 0 1rem 0 !important;
}

.pe-cart-page .entry-title,
.pe-checkout-page .entry-title {
  font-family: var(--font-heading) !important;
  font-weight: 700 !important;
  font-size: 1.75rem !important;
  color: hsl(var(--foreground)) !important;
  margin-bottom: 1rem;
  text-align: left !important;
}

/* Remove Storefront's default article bottom margin */
.pe-cart-page .hentry,
.pe-checkout-page .hentry {
  margin-bottom: 0 !important;
}

/* Tighten gap between header and cart page content */
.pe-cart-page .site-main > .page,
.pe-checkout-page .site-main > .page {
  padding-top: 0;
}

.pe-cart-page #primary,
.pe-checkout-page #primary {
  padding-top: 0;
}

/* Remove Storefront default page top margin */
.pe-cart-page .site-main,
.pe-checkout-page .site-main {
  padding-top: 0 !important;
}

/* Breadcrumb above cart page title */
.pe-cart-page .pe-breadcrumbs,
.pe-checkout-page .pe-breadcrumbs {
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* Override Storefront breadcrumb wrapper if still present */
.pe-cart-page .storefront-breadcrumb,
.pe-checkout-page .storefront-breadcrumb {
  margin: 0 !important;
  padding: 0 !important;
}

/* Remove WC default notices top-margin that creates gap */
.pe-cart-page .woocommerce-notices-wrapper:empty {
  display: none;
}
