/* =============================================================
   Sliding Cart — Frontend Styles
   All colors/sizes come from CSS variables set by cart.js
   ============================================================= */

/* CSS Variables (defaults overridden by JS) */
:root {
  --sc-bg:            #ffffff;
  --sc-btn-color:     #000000;
  --sc-btn-text:      #ffffff;
  --sc-text-primary:  #111827;
  --sc-text-secondary:#6b7280;
  --sc-link:          #0073aa;
  --sc-border:        #e5e7eb;
  --sc-progress:      #000000;
  --sc-progress-bg:   #e5e5e5;
  --sc-progress-h:    6px;
  --sc-radius:        8px;
  --sc-speed:         300ms;
  --sc-width:         400px;
  --sc-font:          inherit;
  --sc-badge-bg:      #dc2626;
  --sc-badge-text:    #ffffff;
  --sc-icon-bg:       #ffffff;
  --sc-icon-color:    #000000;
  --sc-icon-size:     48px;
  --sc-upsell-bg:     #f9fafb;
}

/* Body lock when cart is open */
body.sc-body-lock {
  overflow: hidden;
}

/* Root wrapper */
#sliding-cart-root {
  font-family: var(--sc-font);
  position: fixed;
  z-index: 99998;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}
#sliding-cart-root * {
  box-sizing: border-box;
}

/* =============================================================
   Trigger Button
   ============================================================= */
.sc-trigger {
  pointer-events: all;
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: var(--sc-icon-size);
  height: var(--sc-icon-size);
  border-radius: 50%;
  background: var(--sc-icon-bg);
  color: var(--sc-icon-color);
  border: 1px solid var(--sc-border);
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  z-index: 99999;
}
.sc-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.sc-trigger-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

/* Badge */
.sc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: var(--sc-badge-bg);
  color: var(--sc-badge-text);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  pointer-events: none;
}

/* =============================================================
   Overlay
   ============================================================= */
.sc-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  transition: opacity var(--sc-speed) ease;
  z-index: 99998;
}
.sc-overlay--visible {
  pointer-events: all;
  opacity: 1;
}

/* =============================================================
   Cart wrap (sidebar + drawer together)
   ============================================================= */
.sc-cart-wrap {
  pointer-events: none;
  position: fixed;
  top: 0;
  bottom: 0;
  z-index: 99999;
  display: flex;
  flex-direction: row;
  transition: transform var(--sc-speed) cubic-bezier(.4,0,.2,1);
}
.sc-cart-wrap--right {
  right: 0;
  transform: translateX(100%);
  flex-direction: row-reverse; /* sidebar on left, drawer on right */
}
.sc-cart-wrap--left {
  left: 0;
  transform: translateX(-100%);
  flex-direction: row; /* sidebar on right, drawer on left */
  box-shadow: 4px 0 24px rgba(0,0,0,.12);
}
.sc-cart-wrap--open {
  pointer-events: all;
  transform: translateX(0) !important;
}

/* Loading state */
.sc-loading .sc-drawer-inner {
  opacity: .6;
  pointer-events: none;
}

/* =============================================================
   Sidebar upsells panel
   ============================================================= */
.sc-sidebar {
  width: 200px;
  background: var(--sc-upsell-bg);
  border-left: 1px solid var(--sc-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
.sc-cart-wrap--left .sc-sidebar {
  border-left: none;
  border-right: 1px solid var(--sc-border);
}
.sc-sidebar-header {
  padding: 16px 14px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--sc-text-secondary);
  border-bottom: 1px solid var(--sc-border);
  flex-shrink: 0;
}
.sc-sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sc-sidebar-list .sc-upsell-item--sidebar {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 10px 8px;
  width: 100%;
}
.sc-sidebar-list .sc-upsell-img {
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
}
.sc-sidebar-list .sc-upsell-info {
  align-items: center;
  margin-bottom: 6px;
  width: 100%;
}
.sc-sidebar-list .sc-upsell-add {
  width: auto;
}

/* =============================================================
   Drawer (inner cart panel)
   ============================================================= */
.sc-drawer {
  width: var(--sc-width);
  max-width: 100vw;
  background: var(--sc-bg);
  box-shadow: -4px 0 24px rgba(0,0,0,.12);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sc-cart-wrap--left .sc-drawer {
  box-shadow: 4px 0 24px rgba(0,0,0,.12);
}

/* Inner wrapper */
.sc-drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  transition: opacity 0.2s;
  position: relative;
}

/* =============================================================
   Header
   ============================================================= */
.sc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--sc-border);
  flex-shrink: 0;
}
.sc-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sc-header-icon {
  color: var(--sc-text-primary);
  display: flex;
  align-items: center;
}
.sc-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--sc-text-primary);
  line-height: 1.3;
}
.sc-header-count {
  font-weight: 400;
  color: var(--sc-text-secondary);
  font-size: 14px;
}
.sc-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sc-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background 0.15s, color 0.15s;
}
.sc-close-btn:hover {
  background: var(--sc-border);
  color: var(--sc-text-primary);
}

/* =============================================================
   Rewards bar
   ============================================================= */
.sc-rewards {
  padding: 14px 20px 10px;
  border-bottom: 1px solid var(--sc-border);
  background: #fff;
  flex-shrink: 0;
}
.sc-reward-msg {
  font-size: 13px;
  color: var(--sc-text-secondary);
  margin-bottom: 10px;
  line-height: 1.4;
}

/* Progress bar sits behind milestone dots */
.sc-reward-prog-wrap {
  position: relative;
}
.sc-reward-track {
  position: absolute;
  left: 18px;
  right: 18px;
  top: calc(18px - var(--sc-progress-h) / 2);
  height: var(--sc-progress-h);
  background: var(--sc-progress-bg);
  border-radius: calc(var(--sc-progress-h) / 2);
  overflow: hidden;
  z-index: 0;
}
.sc-reward-fill {
  height: 100%;
  background: var(--sc-progress);
  border-radius: inherit;
  transition: width var(--sc-speed) ease;
}

/* Milestones row */
.sc-milestones {
  display: flex;
  justify-content: space-between;
  position: relative;
  z-index: 1;
  padding-bottom: 20px;
}
.sc-milestone {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}
.sc-milestone-dot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 2px solid var(--sc-border);
  position: relative;
  z-index: 2;
  transition: background 0.3s, border-color 0.3s;
  color: var(--sc-text-secondary);
}
.sc-milestone--achieved .sc-milestone-dot {
  background: var(--sc-progress);
  border-color: var(--sc-progress);
  color: #fff;
}
.sc-milestone-label {
  font-size: 10px;
  color: var(--sc-text-secondary);
  margin-top: 5px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 64px;
}
.sc-milestone--achieved .sc-milestone-label {
  color: var(--sc-text-primary);
  font-weight: 600;
}

/* =============================================================
   Body (scrollable)
   ============================================================= */
.sc-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* =============================================================
   Cart Items
   ============================================================= */
.sc-items {
  padding: 8px 0;
}
.sc-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--sc-border);
  transition: background 0.15s;
}
.sc-item:hover {
  background: #fafafa;
}
.sc-item-img-wrap {
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: calc(var(--sc-radius) / 2);
  overflow: hidden;
  background: #f3f4f6;
  border: 1px solid var(--sc-border);
}
.sc-item-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.sc-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sc-item-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--sc-text-primary);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
  display: block;
}
.sc-item-name:hover {
  color: var(--sc-link);
}
.sc-item-price-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sc-item-regular {
  font-size: 12px;
  color: var(--sc-text-secondary);
  text-decoration: line-through;
}
.sc-item-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--sc-text-primary);
}
.sc-item-free-badge {
  font-size: 11px;
  font-weight: 700;
  color: #166534;
  background: #dcfce7;
  border-radius: 4px;
  padding: 2px 7px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sc-item-gift-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: #166534;
}
.sc-item--gift {
  border-left: 3px solid #22c55e;
}
.sc-item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

/* Quantity control */
.sc-qty {
  display: flex;
  align-items: center;
  border: 1px solid var(--sc-border);
  border-radius: calc(var(--sc-radius) / 1.5);
  overflow: hidden;
  background: #fff;
}
.sc-qty-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  color: var(--sc-text-primary);
  transition: background 0.15s;
  line-height: 0;
}
.sc-qty-btn:hover {
  background: var(--sc-border);
}
.sc-qty-val {
  padding: 4px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--sc-text-primary);
  min-width: 28px;
  text-align: center;
  border-left: 1px solid var(--sc-border);
  border-right: 1px solid var(--sc-border);
}
.sc-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--sc-text-secondary);
  display: flex;
  align-items: center;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  line-height: 0;
  margin-left: auto;
}
.sc-remove-btn:hover {
  color: #ef4444;
  background: #fee2e2;
}

/* =============================================================
   Empty cart
   ============================================================= */
.sc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}
.sc-empty-icon {
  color: var(--sc-border);
  line-height: 0;
}
.sc-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--sc-text-primary);
  margin: 0;
}
.sc-empty-desc {
  font-size: 13px;
  color: var(--sc-text-secondary);
  margin: 0;
}
.sc-empty-btn {
  display: inline-block;
  margin-top: 8px;
  padding: 10px 24px;
  background: var(--sc-btn-color);
  color: var(--sc-btn-text);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--sc-radius);
  text-decoration: none;
  transition: opacity 0.15s;
}
.sc-empty-btn:hover {
  opacity: .85;
}

/* =============================================================
   Upsells
   ============================================================= */
.sc-upsells {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--sc-border);
  background: var(--sc-upsell-bg);
}
.sc-upsells-heading {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--sc-text-secondary);
  margin: 0 0 10px;
}
.sc-upsells-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
/* Sidebar style: horizontal scroll row */
.sc-upsells-list--sidebar {
  flex-direction: row;
  overflow-x: auto;
  gap: 10px;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.sc-upsells-list--sidebar::-webkit-scrollbar {
  height: 4px;
}
.sc-upsells-list--sidebar::-webkit-scrollbar-track { background: transparent; }
.sc-upsells-list--sidebar::-webkit-scrollbar-thumb { background: var(--sc-border); border-radius: 2px; }
.sc-upsell-item--sidebar {
  flex-direction: column;
  align-items: center;
  min-width: 110px;
  max-width: 110px;
  scroll-snap-align: start;
  text-align: center;
  padding: 10px 8px;
}
.sc-upsell-item--sidebar .sc-upsell-img {
  width: 64px;
  height: 64px;
  margin-bottom: 6px;
}
.sc-upsell-item--sidebar .sc-upsell-info {
  align-items: center;
  margin-bottom: 6px;
}
.sc-upsell-item--sidebar .sc-upsell-add {
  width: 24px;
  height: 24px;
  font-size: 16px;
}
.sc-upsell-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius);
  padding: 8px 12px;
}
.sc-upsell-img {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: calc(var(--sc-radius) / 2);
  flex-shrink: 0;
  background: #f3f4f6;
}
.sc-upsell-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sc-upsell-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--sc-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sc-upsell-price {
  font-size: 12px;
  color: var(--sc-text-secondary);
}
.sc-upsell-add {
  flex-shrink: 0;
  width: 40px;
  height: 28px;
  border-radius: calc(var(--sc-radius) / 1.5);
  background: var(--sc-btn-color);
  color: var(--sc-btn-text);
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.sc-upsell-add:hover {
  opacity: .8;
}

/* =============================================================
   Footer
   ============================================================= */
.sc-footer {
  border-top: 1px solid var(--sc-border);
  padding: 16px 20px 20px;
  flex-shrink: 0;
  background: var(--sc-bg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Coupon */
.sc-coupon-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--sc-border);
  border-radius: var(--sc-radius);
  overflow: hidden;
  background: #fafafa;
  padding: 0 10px;
}
.sc-coupon-icon {
  color: var(--sc-text-secondary);
  display: flex;
  align-items: center;
  line-height: 0;
  flex-shrink: 0;
}
.sc-coupon-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 9px 6px;
  font-size: 13px;
  color: var(--sc-text-primary);
  outline: none;
}
.sc-coupon-input::placeholder {
  color: var(--sc-text-secondary);
}
.sc-coupon-apply {
  flex-shrink: 0;
  background: var(--sc-btn-color);
  color: var(--sc-btn-text);
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: calc(var(--sc-radius) - 2px);
  margin: 4px 0;
  transition: opacity 0.15s;
}
.sc-coupon-apply:hover {
  opacity: .85;
}
.sc-coupons-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.sc-coupon-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #d1fae5;
  color: #065f46;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 12px;
}
.sc-coupon-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #065f46;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  margin-left: 2px;
}

/* Summary */
.sc-summary-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sc-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--sc-text-secondary);
}
.sc-summary-row em {
  font-style: normal;
  font-size: 11px;
  color: var(--sc-text-secondary);
}
.sc-savings {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #f0fdf4;
  border-radius: 8px;
  padding: 8px 12px;
  margin: 2px 0;
  color: #166534;
  font-weight: 600;
  font-size: 13px !important;
}
.sc-discount {
  color: #16a34a;
}
.sc-total {
  font-size: 15px !important;
  font-weight: 700;
  color: var(--sc-text-primary) !important;
  padding-top: 8px;
  border-top: 1px solid var(--sc-border);
  margin-top: 4px;
}

/* Checkout button */
.sc-checkout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--sc-btn-color);
  color: var(--sc-btn-text);
  text-decoration: none;
  padding: 13px 20px;
  border-radius: var(--sc-radius);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  transition: opacity 0.2s;
}
.sc-checkout-btn:hover {
  opacity: .88;
  color: var(--sc-btn-text);
}
.sc-lock {
  display: flex;
  align-items: center;
  line-height: 0;
  opacity: .8;
}

/* Continue shopping */
.sc-continue {
  display: block;
  text-align: center;
  font-size: 12px;
  color: var(--sc-text-secondary);
  text-decoration: underline;
  transition: color 0.15s;
}
.sc-continue:hover {
  color: var(--sc-link);
}

/* =============================================================
   Notice
   ============================================================= */
.sc-notice {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.sc-notice--success {
  background: #d1fae5;
  color: #065f46;
}
.sc-notice--error {
  background: #fee2e2;
  color: #991b1b;
}

/* =============================================================
   Responsive
   ============================================================= */
@media (max-width: 480px) {
  .sc-drawer {
    width: 100vw !important;
  }
  .sc-sidebar {
    display: none !important;
  }
}
