/* ─── Cart toggle (header) ─────────────────────────────────────────────── */

.cart-toggle {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--color-muted);
  transition: color var(--transition-fast), background var(--transition-fast);
  cursor: pointer;
}
.cart-toggle:hover {
  color: var(--color-white);
  background: var(--color-surface-2);
}

.cart-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gradient-purple);
  color: #fff;
  font-size: 10px;
  font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
  padding: 0 4px;
  line-height: 1;
  pointer-events: none;
}

/* ─── Cart drawer ──────────────────────────────────────────────────────── */

.cart-drawer {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2500;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.cart-drawer.open {
  display: flex;
}

.cart-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.cart-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(400px, 90vw);
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  z-index: 1;
  animation: cart-slide-in 0.3s var(--ease-spring) both;
}

@keyframes cart-slide-in {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}

/* ─── Cart header ──────────────────────────────────────────────────────── */

.cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}
.cart-header h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-white);
}

/* ─── Cart items ───────────────────────────────────────────────────────── */

.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-lg);
}

.cart-empty {
  text-align: center;
  color: var(--color-muted);
  padding: var(--space-3xl) 0;
  font-size: var(--text-sm);
}

.cart-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md) 0;
  border-bottom: 1px solid var(--color-border);
}
.cart-item:last-child {
  border-bottom: none;
}

.cart-item-image {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface-2);
  flex-shrink: 0;
}
.cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cart-item-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-muted-2);
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}
.cart-item-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item-variant {
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-top: 2px;
}
.cart-item-price {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-purple-light);
  margin-top: 4px;
}

/* ─── Cart quantity & actions ──────────────────────────────────────────── */

.cart-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.cart-qty {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.cart-qty-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
}
.cart-qty-btn:hover {
  background: var(--color-purple);
  color: #fff;
}
.cart-qty-value {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-white);
  min-width: 28px;
  text-align: center;
  line-height: 28px;
}

.cart-remove-btn {
  color: var(--color-muted-2);
  cursor: pointer;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  padding: 4px;
}
.cart-remove-btn:hover {
  color: #ef4444;
}

/* ─── Cart footer ──────────────────────────────────────────────────────── */

.cart-footer {
  padding: var(--space-lg) var(--space-xl);
  padding-bottom: calc(var(--space-lg) + env(safe-area-inset-bottom));
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.cart-total {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-white);
}
.cart-total-amount {
  color: var(--color-purple-light);
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
}

.cart-checkout-btn {
  width: 100%;
  justify-content: center;
}

/* ─── Badge pulse animation ───────────────────────────────────────────── */

.cart-badge-pulse {
  animation: badge-pulse 0.4s ease;
}
@keyframes badge-pulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1); }
}

/* ─── Add to cart toast ───────────────────────────────────────────────── */

.cart-toast {
  position: fixed;
  bottom: var(--space-2xl);
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-surface);
  border: 1px solid rgba(124, 58, 237, 0.4);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-xl);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-white);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(124, 58, 237, 0.15);
  z-index: 3000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.cart-toast svg {
  color: #4ade80;
  flex-shrink: 0;
}
.cart-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
