/**
 * Slide Cart - Carrello Intelligente (stile front)
 * Drawer da destra, overlay, barra soglie, righe carrello, upsell.
 * Variabili colore iniettate inline dal tema (--slidecart-primary / --slidecart-bar).
 * @license GPL-2.0-or-later
 */

/* ---- icona header ---- */
.slidecart-icon-wrapper {
  display: inline-block;
}
.slidecart-icon-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: inherit;
}
.slidecart-icon-cart {
  font-size: 26px;
  line-height: 1;
}
.slidecart-icon-count {
  position: absolute;
  top: -6px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--slidecart-primary, #AF2C28);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}

/* ---- overlay ---- */
.slidecart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 99998;
}
.slidecart-overlay.slidecart-overlay-visible {
  opacity: 1;
}
body.slidecart-no-scroll {
  overflow: hidden;
}

/* ---- drawer ---- */
.slidecart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 380px;
  max-width: 92vw;
  background: #fff;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.18);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  font-size: 14px;
  color: #222;
}
.slidecart-drawer.slidecart-open {
  transform: translateX(0);
}

.slidecart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid #eee;
}
.slidecart-title {
  font-size: 17px;
  font-weight: 700;
}
.slidecart-close {
  background: none;
  border: 0;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #888;
  padding: 0 4px;
}
.slidecart-close:hover {
  color: #222;
}

/* ---- barra soglie ---- */
.slidecart-progress-wrap {
  padding: 12px 18px;
  border-bottom: 1px solid #f1f1f1;
  background: #fafafa;
}
.slidecart-progress-msg {
  font-size: 13px;
  margin-bottom: 8px;
  text-align: center;
}
.slidecart-progress-msg.slidecart-goal-reached {
  color: var(--slidecart-bar, #2ecc71);
  font-weight: 700;
}
.slidecart-progress-track {
  height: 8px;
  border-radius: 4px;
  background: #e6e6e6;
  overflow: hidden;
}
.slidecart-progress-fill {
  height: 100%;
  width: 0;
  background: var(--slidecart-bar, #2ecc71);
  transition: width 0.4s ease;
}
.slidecart-reward-msg {
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
  color: #555;
}
.slidecart-reward-msg.slidecart-goal-reached {
  color: var(--slidecart-primary, #AF2C28);
  font-weight: 700;
}

/* ---- body / righe ---- */
.slidecart-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 0;
  position: relative;
}
.slidecart-loading {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}
.slidecart-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #ddd;
  border-top-color: var(--slidecart-primary, #AF2C28);
  border-radius: 50%;
  animation: slidecart-spin 0.8s linear infinite;
}
@keyframes slidecart-spin {
  to { transform: rotate(360deg); }
}

.slidecart-items {
  list-style: none;
  margin: 0;
  padding: 0;
}
.slidecart-item {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #f3f3f3;
}
.slidecart-item-img,
.slidecart-upsell-img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 6px;
  background: #f5f5f5;
  display: block;
}
.slidecart-item-noimg {
  display: inline-block;
}
.slidecart-item-info {
  flex: 1 1 auto;
  min-width: 0;
}
.slidecart-item-name {
  display: block;
  font-weight: 600;
  color: #222;
  text-decoration: none;
  line-height: 1.3;
  margin-bottom: 2px;
}
.slidecart-item-name:hover {
  color: var(--slidecart-primary, #AF2C28);
}
.slidecart-item-attrs {
  font-size: 12px;
  color: #888;
  margin-bottom: 4px;
}
.slidecart-item-price {
  font-weight: 700;
  margin-bottom: 6px;
}
.slidecart-item-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.slidecart-qty-btn {
  width: 26px;
  height: 26px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  color: #333;
}
.slidecart-qty-btn:hover {
  border-color: var(--slidecart-primary, #AF2C28);
  color: var(--slidecart-primary, #AF2C28);
}
.slidecart-qty-val {
  min-width: 24px;
  text-align: center;
  font-weight: 600;
}
.slidecart-remove {
  margin-left: auto;
  background: none;
  border: 0;
  color: #b00;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
}

.slidecart-empty {
  text-align: center;
  color: #888;
  padding: 40px 18px;
}

/* ---- upsell ---- */
.slidecart-upsell {
  padding: 14px 18px 4px;
  border-top: 8px solid #f5f5f5;
}
.slidecart-upsell-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 10px;
}
.slidecart-upsell-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f3f3f3;
}
.slidecart-upsell-img {
  width: 48px;
  height: 48px;
}
.slidecart-upsell-info {
  flex: 1 1 auto;
  min-width: 0;
}
.slidecart-upsell-name {
  display: block;
  font-size: 13px;
  color: #222;
  text-decoration: none;
  line-height: 1.25;
}
.slidecart-upsell-name:hover {
  color: var(--slidecart-primary, #AF2C28);
}
.slidecart-upsell-price {
  font-size: 13px;
  font-weight: 700;
  color: #444;
}
.slidecart-upsell-add {
  flex: 0 0 auto;
  border: 1px solid var(--slidecart-primary, #AF2C28);
  background: #fff;
  color: var(--slidecart-primary, #AF2C28);
  border-radius: 4px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.slidecart-upsell-add:hover {
  background: var(--slidecart-primary, #AF2C28);
  color: #fff;
}

/* ---- footer ---- */
.slidecart-footer {
  border-top: 1px solid #eee;
  padding: 14px 18px;
  background: #fff;
}
.slidecart-subtotal {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 10px;
}
.slidecart-checkout-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: var(--slidecart-primary, #AF2C28);
  color: #fff;
  text-decoration: none;
  padding: 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 15px;
}
.slidecart-checkout-btn:hover {
  filter: brightness(0.92);
  color: #fff;
}

@media (max-width: 480px) {
  .slidecart-drawer {
    width: 100%;
    max-width: 100%;
  }
}
