/**
 * Glasprinsen Caddy cart drawer customizations
 *
 * Minimal override-only styles. The goal is to keep Caddy's existing
 * design intact and only adjust the specific pieces required by the
 * conversion-improvement brief.
 */

/* ------------------------------------------------------------------
   1. Hide contradictory / duplicated elements
   ------------------------------------------------------------------ */

/* Remove "Frakt beräknas i kassan" subtext under subtotal. */
.cc-cart-actions .cc-subtotal-subtext {
  display: none !important;
}

/* Hide the English "Save X%" line; we render a Swedish equivalent. */
.cc-cart-items .cc_saved_amount {
  display: none !important;
}

/* Hide the original Caddy totals block; our custom summary replaces it. */
.cc-cart-actions .cc-totals {
  display: none !important;
}

/* ------------------------------------------------------------------
   2. Custom totals summary (injected before the real .cc-totals)
   ------------------------------------------------------------------ */

.gp-cart-totals {
  padding: 12px 0 8px;
  border-top: 1px solid var(--cc-window-border-color, #dedede);
  margin-top: 8px;
}

.gp-cart-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 15px;
  line-height: 1.4;
}

.gp-cart-total-row .gp-cart-total-label {
  color: var(--cc-window-text-color, #000);
}

.gp-cart-total-row .gp-cart-total-amount {
  white-space: nowrap;
  margin-left: 12px;
  text-align: right;
}

.gp-cart-grandtotal-row {
  font-size: 19px;
  font-weight: 700;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--cc-window-border-color, #dedede);
}

.gp-cart-grandtotal-row .gp-cart-total-amount {
  font-weight: 700;
}

.gp-cart-shipping-remaining {
  font-size: 13px;
  color: var(--cc-window-muted-text-color, #777);
  margin-top: 2px;
  margin-bottom: 4px;
  min-height: 1.4em;
}

.gp-cart-shipping-remaining:empty {
  display: none;
}

/* ------------------------------------------------------------------
   3. Checkout button
   ------------------------------------------------------------------ */

.cc-cart-actions a.cc-button-primary {
  min-height: 52px;
  padding-top: 14px;
  padding-bottom: 14px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

/* Amount injected by JS should sit cleanly inside the button. */
.cc-button-primary .gp-checkout-total {
  font-weight: 700;
}

/* ------------------------------------------------------------------
   4. Trust bar
   ------------------------------------------------------------------ */

.gp-trust-bar {
  text-align: center;
  font-size: 12px;
  color: var(--cc-window-muted-text-color, #777);
  padding: 10px 25px 16px;
  line-height: 1.4;
}

.gp-trust-bar .gp-trust-bar-free,
.gp-trust-bar .gp-trust-bar-not-free {
  display: none;
}

.gp-trust-bar.gp-free-shipping-active .gp-trust-bar-free {
  display: block;
}

.gp-trust-bar:not(.gp-free-shipping-active) .gp-trust-bar-not-free {
  display: block;
}

.gp-trust-bar-shipping {
  margin-top: 6px;
}

/* Hide the custom summary and discounts only when the cart is actually empty. */
body.gp-caddy-cart-empty .gp-cart-totals,
body.gp-caddy-cart-empty .cc-cart-actions .cc-discounts,
body.gp-caddy-cart-empty .cc-cart-actions .cc-totals {
  display: none !important;
}

body.gp-caddy-cart-has-items .gp-cart-totals,
body.gp-caddy-cart-has-items .cc-cart-actions .cc-discounts {
  display: block;
}

body.gp-caddy-cart-has-items .cc-cart-actions .cc-discounts {
  display: flex !important;
}

body.gp-caddy-cart-has-items .cc-cart-actions.cc-hidden {
  display: block !important;
}

/* ------------------------------------------------------------------
   5. Product item tweaks
   ------------------------------------------------------------------ */

/* Keep thumbnails at a consistent size without breaking Caddy's layout. */
.cc-cart-product .cc-product-thumb {
  flex-shrink: 0;
}

.cc-cart-product .cc-product-thumb img {
  object-fit: contain;
}

/* Product name should break across lines on narrow screens. */
.cc_item_title a.cc-product-link {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
  line-height: 1.35;
}

/* Compact variation display under the name. */
.cc_item_variation,
.cc-cart .cc-cart-items .cc_item_title dl.variation {
  font-size: 13px;
  color: var(--cc-window-muted-text-color, #777);
  margin: 4px 0 6px;
  line-height: 1.4;
  font-weight: normal;
}

.cc_item_variation:empty,
.cc-cart .cc-cart-items .cc_item_title dl.variation:empty {
  display: none;
}

.cc-cart .cc-cart-items .cc_item_title dl.variation dt,
.cc-cart .cc-cart-items .cc_item_title dl.variation dd {
  display: inline;
  margin: 0;
  float: none;
}

.cc-cart .cc-cart-items .cc_item_title dl.variation dt {
  font-weight: normal;
}

.cc-cart .cc-cart-items .cc_item_title dl.variation dt::after {
  content: ": ";
}

.cc-cart .cc-cart-items .cc_item_title dl.variation dd + dt::before {
  content: " • ";
}

.cc-cart .cc-cart-items .cc_item_title dl.variation dd p {
  margin: 0;
}

/* Swedish savings text injected by JS. */
.gp-item-savings {
  font-size: 13px;
  color: #12b97c;
  margin-top: 2px;
}

/* ------------------------------------------------------------------
   6. Coupon toggle
   ------------------------------------------------------------------ */

.cc-coupon-title {
  display: inline;
  font-size: 14px;
  color: var(--cc-window-link-color, #000);
  text-decoration: underline;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.cc-coupon-title svg {
  display: none;
}

.cc-coupon-form .coupon {
  display: flex;
  gap: 8px;
}

.cc-coupon-form input#cc_coupon_code {
  flex: 1 1 auto;
  min-height: 40px;
}

.cc-coupon-form .cc-coupon-btn {
  min-height: 40px;
}

/* ------------------------------------------------------------------
   7. Mobile adaptations
   ------------------------------------------------------------------ */

@media (max-width: 768px) {
  .cc-window {
    --cc-window-width: 100%;
    max-width: 100vw;
  }

  .cc-cart-actions a.cc-button-primary {
    min-height: 50px;
  }

  .gp-cart-grandtotal-row {
    font-size: 17px;
  }
}

@media (max-width: 430px) {
  .gp-cart-totals,
  .gp-trust-bar,
  .cc-cart-actions {
    padding-left: 20px;
    padding-right: 20px;
  }
}

@media (max-width: 375px) {
  .cc_item_title a.cc-product-link {
    font-size: 14px;
  }

  .cc_item_total_price {
    text-align: left;
  }
}

@media (max-width: 320px) {
  .cc-cart-product .cc-product-thumb {
    width: 70px;
    max-width: 70px;
  }
}
