/**
 * Maatos cart design (classic [woocommerce_cart]); markup added by
 * Maatos\V2\Plugin\Cart and assets/js/cart.js.
 *
 * The accent colour is the brand colour from the onboarding form, exposed by
 * the theme as --maatos-theme-color.
 */

body.woocommerce-cart {
  --m-accent: var(--maatos-theme-color, #d6105f);
  --m-bg: #f2f5f9;
  --m-text: #1f2328;
  --m-muted: #555b64;
  --m-line: #e3e5e8;
  --m-field: #8b929c;
  background: var(--m-bg);
  color: var(--m-text);
}

.woocommerce-cart a {
  color: var(--m-accent);
}

/* Layout: products on the left, summary on the right ------------------- */

/* The theme limits the page content to 800px; the two columns need more. */
body.woocommerce-cart main#content.site-main,
body.woocommerce-cart main#content .page-content {
  max-width: 1040px;
}

.woocommerce-cart .woocommerce {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto auto auto 1fr;
  column-gap: 24px;
  align-items: start;
  max-width: 1040px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}

.woocommerce-cart .woocommerce > .woocommerce-notices-wrapper,
.woocommerce-cart .woocommerce > .maatos-cart-title {
  grid-column: 1 / -1;
}

.woocommerce-cart .woocommerce > .woocommerce-cart-form {
  grid-column: 1;
  grid-row: 3;
}

.woocommerce-cart .woocommerce > .maatos-continue {
  grid-column: 1;
  grid-row: 4;
  margin-top: 16px;
}

.woocommerce-cart .woocommerce > .cart-collaterals {
  grid-column: 2;
  grid-row: 3 / span 2;
  width: auto;
  float: none;
}

.woocommerce-cart .cart-collaterals .cart_totals {
  float: none !important;
  width: 100% !important;
}

.maatos-cart-title {
  margin: 0 0 24px;
  font-size: 32px;
  font-weight: 800;
  color: var(--m-text);
}

/* Cards ---------------------------------------------------------------- */

.woocommerce-cart .woocommerce-cart-form,
.woocommerce-cart .cart-collaterals .cart_totals {
  background: #fff;
  border: 1px solid var(--m-line);
  border-radius: 12px;
  padding: 24px;
}

.maatos-cart-heading,
.woocommerce-cart .cart_totals > h2 {
  margin: 0 0 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--m-line);
  font-size: 18px;
  font-weight: 700;
  color: var(--m-text);
}

/* Product rows: the table becomes a list ------------------------------- */

.woocommerce-cart table.shop_table.cart,
.woocommerce-cart table.shop_table.cart tbody {
  display: block;
  width: 100%;
  border: 0;
  margin: 0;
}

.woocommerce-cart table.shop_table.cart thead {
  display: none;
}

.woocommerce-cart table.shop_table.cart tr.cart_item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  grid-template-areas:
    "thumb name subtotal"
    "thumb price qty"
    "thumb remove qty";
  column-gap: 16px;
  row-gap: 2px;
  align-items: start;
  padding: 16px 0;
  border: 0;
  border-bottom: 1px solid var(--m-line);
}

.woocommerce-cart table.shop_table.cart tr.cart_item:last-of-type {
  border-bottom: 0;
}

.woocommerce-cart table.shop_table.cart tr.cart_item td {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  text-align: left !important;
}

.woocommerce-cart table.shop_table.cart tr.cart_item td::before {
  content: none;
}

.woocommerce-cart td.product-thumbnail {
  grid-area: thumb;
}

.woocommerce-cart td.product-thumbnail img {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: #dbe2ea;
}

.woocommerce-cart td.product-name {
  grid-area: name;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.woocommerce-cart td.product-name a {
  color: var(--m-text);
  text-decoration: none;
}

.woocommerce-cart td.product-price {
  grid-area: price;
  font-size: 14px;
  color: var(--m-muted);
}

.woocommerce-cart td.product-subtotal {
  grid-area: subtotal;
  font-size: 16px;
  font-weight: 700;
  text-align: right !important;
}

.woocommerce-cart td.product-quantity {
  grid-area: qty;
  justify-self: end;
}

.woocommerce-cart td.product-remove {
  grid-area: remove;
}

/* Remove link: icon and text, not WooCommerce's red circle ------------- */

.woocommerce-cart a.remove.maatos-remove {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: auto;
  height: auto;
  margin-top: 8px;
  border-radius: 0;
  background: none;
  font-size: 14px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--m-muted) !important;
  text-decoration: none;
}

.woocommerce-cart a.remove.maatos-remove:hover {
  background: none;
  color: var(--m-accent) !important;
}

/* Quantity stepper ------------------------------------------------------ */

.woocommerce-cart .quantity.maatos-stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--m-field);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}

.woocommerce-cart .maatos-stepper .maatos-qty-btn {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 18px;
  line-height: 1;
  color: var(--m-text);
  cursor: pointer;
}

.woocommerce-cart .maatos-stepper .maatos-qty-btn:hover {
  background: var(--m-bg);
}

.woocommerce-cart .maatos-stepper input.qty {
  width: 44px;
  height: 36px;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--m-line);
  border-right: 1px solid var(--m-line);
  border-radius: 0;
  background: none;
  text-align: center;
  font-size: 15px;
  -moz-appearance: textfield;
}

.woocommerce-cart .maatos-stepper input.qty::-webkit-outer-spin-button,
.woocommerce-cart .maatos-stepper input.qty::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Coupon and update button --------------------------------------------- */

.woocommerce-cart table.shop_table.cart tr:has(td.actions) {
  display: block;
}

.woocommerce-cart table.shop_table.cart td.actions {
  display: block;
  padding: 16px 0 0;
  border: 0;
  background: none;
  text-align: left;
}

.woocommerce-cart td.actions .coupon {
  float: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.woocommerce-cart td.actions .coupon .input-text {
  flex: 1;
  min-width: 0;
  width: auto;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--m-field);
  border-radius: 6px;
  font-size: 15px;
}

.woocommerce-cart td.actions .coupon .button {
  height: 46px;
  border-radius: 6px;
}

.woocommerce-cart .maatos-coupon-toggle {
  padding: 0;
  border: 0;
  background: none;
  font-size: 14px;
  color: var(--m-accent);
  text-decoration: underline;
  cursor: pointer;
}

.woocommerce-cart .coupon.is-collapsed > :not(.maatos-coupon-toggle) {
  display: none !important;
}

.woocommerce-cart .coupon:not(.is-collapsed) .maatos-coupon-toggle {
  flex-basis: 100%;
  text-align: left;
}

.woocommerce-cart td.actions > .button {
  float: none;
  margin-top: 12px;
}

/* The stepper updates the cart on its own. */
.maatos-cart-js.woocommerce-cart td.actions > [name="update_cart"] {
  display: none !important;
}

/* Empty cart: message and button on their own lines, in the full container. */

.woocommerce-cart .woocommerce > .wc-empty-cart-message,
.woocommerce-cart .woocommerce > .cart-empty,
.woocommerce-cart .woocommerce > .return-to-shop {
  grid-column: 1 / -1;
}

.woocommerce-cart .return-to-shop {
  margin: 0;
}

.woocommerce-cart .return-to-shop a.button.wc-backward {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 54px;
  margin: 0;
  padding: 0 32px;
  border: 0;
  border-radius: 8px;
  background: var(--m-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
}

.woocommerce-cart .return-to-shop a.button.wc-backward:hover {
  background: var(--maatos-button-hover-color, var(--m-accent));
  filter: brightness(0.95);
}

/* Continue shopping ----------------------------------------------------- */

.maatos-continue {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  text-decoration: none;
}

/* Summary --------------------------------------------------------------- */

.woocommerce-cart .cart_totals table.shop_table {
  display: table;
  width: 100%;
  margin: 0 0 16px;
  border: 0;
  border-collapse: separate;
  border-spacing: 0;
  background: none;
}

.woocommerce-cart .cart_totals table.shop_table th,
.woocommerce-cart .cart_totals table.shop_table td {
  display: table-cell;
  padding: 10px 0;
  border: 0;
  border-top: 1px solid var(--m-line);
  background: none;
  font-size: 14px;
  text-align: left;
  vertical-align: top;
}

.woocommerce-cart .cart_totals table.shop_table tr {
  display: table-row;
}

.woocommerce-cart .cart_totals table.shop_table th,
.woocommerce-cart .cart_totals table.shop_table td {
  display: table-cell !important;
  width: auto;
  background: none !important;
}

.woocommerce-cart .cart_totals table.shop_table td {
  text-align: right !important;
}

.woocommerce-cart .cart_totals table.shop_table td::before {
  content: none;
}

.woocommerce-cart .cart_totals table.shop_table tr:first-child th,
.woocommerce-cart .cart_totals table.shop_table tr:first-child td {
  border-top: 0;
}

.woocommerce-cart .cart_totals .order-total th,
.woocommerce-cart .cart_totals .order-total td {
  padding-top: 16px;
  font-size: 18px;
  font-weight: 700;
}

.woocommerce-cart .cart_totals .includes_tax {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--m-muted);
}

.woocommerce-cart .wc-proceed-to-checkout {
  padding: 0;
}

.woocommerce-cart .wc-proceed-to-checkout a.checkout-button.button.alt {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  margin: 0;
  padding: 0 16px;
  border: 0;
  border-radius: 8px;
  background: var(--m-accent);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
}

.woocommerce-cart .wc-proceed-to-checkout a.checkout-button.button.alt:hover {
  background: var(--maatos-button-hover-color, var(--m-accent));
  filter: brightness(0.95);
}

.woocommerce-cart .maatos-trust {
  text-align: center;
  font-size: 13px;
  color: var(--m-muted);
  margin: 10px 0 0;
}

/* Mobile: one column ---------------------------------------------------- */

@media (max-width: 800px) {
  .woocommerce-cart .woocommerce {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
  }

  .woocommerce-cart .woocommerce > .woocommerce-cart-form,
  .woocommerce-cart .woocommerce > .maatos-continue,
  .woocommerce-cart .woocommerce > .cart-collaterals {
    grid-column: 1;
    grid-row: auto;
  }

  .woocommerce-cart .woocommerce > .cart-collaterals {
    margin-top: 24px;
  }

  .woocommerce-cart .woocommerce-cart-form,
  .woocommerce-cart .cart-collaterals .cart_totals {
    padding: 20px;
  }

  .woocommerce-cart table.shop_table.cart tr.cart_item {
    grid-template-columns: 72px minmax(0, 1fr);
    grid-template-areas:
      "thumb name"
      "thumb price"
      "thumb remove"
      "qty subtotal";
    row-gap: 4px;
  }

  .woocommerce-cart td.product-quantity {
    justify-self: start;
    margin-top: 8px;
  }

  .woocommerce-cart td.product-subtotal {
    align-self: end;
  }
}
