/*
 * Cart styles: the add-to-cart form on the product page, the header link and
 * the cart page itself (includes/cart.php). Everything is server-rendered —
 * there is no JavaScript behind any of it.
 * Selectors stay namespaced under cart- / tomm-cart- / box-ecommerce so they
 * cannot touch the existing site styling.
 */

/* --- Add to cart form (product page) ------------------------------------- */
.box-ecommerce .tomm-cart-add-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}
.tomm-cart-add {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}
.tomm-cart-add-qty {
  width: 70px;
  padding: 6px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-align: center;
}

/* --- Header link ---------------------------------------------------------- */
.cart-link {
  position: relative;
}
.cart-link img {
  width: 18px;
  margin-right: 4px;
  vertical-align: middle;
}
.cart-link .cart-count {
  display: inline-block;
  min-width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 10px;
  background: #e52729;
  color: #fff;
  font-size: 12px;
  line-height: 20px;
  text-align: center;
}

/* --- Floating button + drawer (includes/cart_drawer.php) -------------------
 * Open/close is pure CSS: #tomm-cart-switch is a hidden checkbox and the
 * button, overlay and close control are labels for it. No JavaScript.
 */
/* Bottom-right corner. #back-to-top (right:19 bottom:110 desktop, right:15
 * bottom:15 mobile) appears on scroll: on desktop it stacks above this button,
 * on mobile it takes the corner, so there the cart sits above it instead. */
#tomm-cart-toggle {
  position: fixed;
  right: 19px;
  bottom: 30px;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  margin: 0;
  border-radius: 50%;
  background: #e52729;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  cursor: pointer;
}
#tomm-cart-toggle:hover { background: #a50d26; }
#tomm-cart-toggle svg { width: 25px; }

@media (max-width: 768px) {
  #tomm-cart-toggle { right: 15px; bottom: 80px; }
}

#tomm-cart-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: #222;
  color: #fff;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

#tomm-cart-overlay {
  position: fixed;
  inset: 0;
  z-index: 1060;
  margin: 0;
  background: rgba(0, 0, 0, .4);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility .25s ease;
  cursor: pointer;
}

#tomm-cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1070;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: 90vw;
  height: 100%;
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, .2);
  transform: translateX(100%);
  transition: transform .25s ease;
}

/* The switch itself */
.tomm-cart-switch:checked ~ #tomm-cart-overlay { opacity: 1; visibility: visible; }
.tomm-cart-switch:checked ~ #tomm-cart-drawer  { transform: translateX(0); }

.tomm-cart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}
.tomm-cart-title { font-size: 18px; font-weight: 700; text-transform: uppercase; }
#tomm-cart-close {
  margin: 0;
  font-size: 28px;
  line-height: 1;
  color: #777;
  cursor: pointer;
}

#tomm-cart-body { flex: 1; overflow-y: auto; padding: 12px 20px; }
.tomm-cart-empty { color: #888; text-align: center; margin-top: 40px; }

.tomm-cart-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #f0f0f0;
}
.tomm-cart-line-title { font-weight: 600; }

.tomm-cart-line-sku { font-size: 12px; color: #999; }
.tomm-cart-line-price { margin-top: 4px; font-weight: 600; }

.tomm-cart-line-actions { display: flex; align-items: flex-start; gap: 6px; }
.tomm-cart-line-actions form { display: flex; align-items: center; gap: 4px; margin: 0; }
.tomm-cart-qty {
  width: 56px;
  padding: 5px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-align: center;
}
.tomm-cart-remove {
  border: none;
  background: none;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}
.tomm-cart-remove { font-size: 20px; color: #b3261e; }

.tomm-cart-foot { padding: 16px 20px; border-top: 1px solid #eee; }
.tomm-cart-subtotal {
  display: flex;
  justify-content: space-between;
  font-size: 16px;
  line-height: 16px;
  margin-bottom: 12px;
}

.tomm-cart-subtotal small {
  font-weight: 100 !important;
}
.tomm-cart-foot .btn { width: 100%; }
.tomm-cart-foot .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* --- Messages ------------------------------------------------------------- */
.cart-msg {
  white-space: pre-line;
  margin: 12px 0;
  padding: 10px 14px;
  border-radius: 4px;
  font-size: 14px;
}
.cart-msg.error   { background: #fdecea; color: #b3261e; }
.cart-msg.warn    { background: #fff4e5; color: #8a5300; }
.cart-msg.success { background: #e8f5e9; color: #1b5e20; }

/* --- Cart page ------------------------------------------------------------ */
.cart-page .title { margin-bottom: 24px; }

.cart-empty {
  padding: 40px 0 60px;
  text-align: center;
}
.cart-empty h3 { margin-bottom: 10px; }
.cart-empty .btn { margin-top: 18px; }

.cart-lines { border-top: 1px solid #eee; }

.cart-line {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 18px 0;
  border-bottom: 1px solid #eee;
  flex-wrap: wrap;
}
.cart-line-info { flex: 1 1 240px; }
.cart-line-title { font-weight: 600; }
.cart-line-title a { color: inherit; }
.cart-line-title a:hover { text-decoration: underline !important; }
.cart-line-sku { font-size: 12px; color: #999; }
.cart-line-price { margin-top: 4px; }
.cart-line-img img{
  width: 150px;
}
.cart-line-qty {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.cart-line-qty label {
  margin: 0;
  font-size: 12px;
  color: #777;
}
.cart-line-qty input {
  width: 72px;
  padding: 5px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  text-align: center;
}

.cart-line-total {
  min-width: 110px;
  font-weight: 700;
  text-align: right;
}

.cart-line-remove {
  border: none;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: #b3261e;
  cursor: pointer;
}

.cart-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 30px;
  flex-wrap: wrap;
  padding: 24px 0 60px;
}
.cart-total {
  display: flex;
  align-items: baseline;
  gap: 12px;
  font-size: 18px;
}

.cart-page .cart-total {
  justify-content: space-between;
}

.cart-page .cart-foot{
  justify-content: space-between;
  align-items: start;
}

@media (min-width: 575px) {
  .cart-foot-col-total{
    width: 35%;
  }
}

.cart-foot-col-total .tomm-cart-shipping-free{
  display: flex;
  justify-content: space-between;
}

.cart-total strong { font-size: 22px; }

@media (min-width: 575px) {
  .cart-foot-checkout{
    order: 2;
  }
}

@media (max-width: 575px) {
  .cart-line { gap: 12px; }
  .cart-line-total { min-width: 0; text-align: left; }
  .cart-foot { justify-content: space-between; padding-bottom: 40px; }

}

.tomm-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.6);
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.tomm-modal.active {
  display: flex;
}
.tomm-modal-content {
  background-color: #fff;
  padding: 30px;
  border-radius: 15px;
  max-width: 600px;
  width: 90%;
  text-align: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.2);
  animation: tommModalFadeIn 0.3s ease-out;
}
@keyframes tommModalFadeIn {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}
.tomm-modal-content h3 {
  margin-top: 0;
  font-weight: 700;
  color: #333;
  font-size: 1.5rem;
}
.tomm-modal-content p {
  margin-bottom: 20px;
  color: #666;
  font-size: 1rem;
}


@media screen and (min-width: 575px) {
  .tomm-modal-content .tomm-modal-input {
    display: flex;
    gap: 10px;
    align-items: center;
  }

}

.tomm-modal-content input[type="text"] {
  width: 70%;
  padding: 12px;
  margin-bottom: 0;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
  box-sizing: border-box;
}

@media screen and (max-width: 575px) {
  .tomm-modal-content input[type="text"] {
    margin-bottom: 10px;
  }
}


.tomm-modal-actions {
  display: flex;
  justify-content: center;
  gap: 15px;
}
#tomm-modal-submit {
  padding: 7px 30px !important;
}
.tomm-free-shipping-notice {
  background: #f8f9fa;
  border: 1px dashed #ccc;
  padding: 10px;
  border-radius: 8px;
  text-align: center;
  font-size: 0.9rem;
  margin-bottom: 15px;
  color: #555;
}
.tomm-modal-icon {
  font-size: 3rem;
  margin-bottom: 10px;
}
.tomm-cart-shipping-free {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  margin-bottom: 15px;
  font-size: 0.9rem;
  color: #666;
}
.tomm-cart-shipping-free strong {
  color: #28a745;
}