/* ============== CART TOGGLE BUTTON ============== */
/* Hidden on pages that use the new site-header cart icon */
.cart-toggle {
  display: none;
}

.cart-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #dc2626;
  color: white;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  border: 2px solid white;
  animation: badgePop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes badgePop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* ============== OVERLAY ============== */
.cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  animation: overlayFadeIn 0.3s ease;
  backdrop-filter: blur(2px);
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ============== SIDEBAR ============== */
.cart-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 420px;
  background: white;
  z-index: 301;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(26, 39, 68, 0.2);
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cart-sidebar.open {
  transform: translateX(0);
}

/* ============== HEADER ============== */
.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
}

.cart-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #1a1a1a;
}

.cart-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6b7280;
  padding: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: all 0.2s ease;
  margin: -8px -8px -8px 0;
}

.cart-close-btn:hover {
  background: #f3f4f6;
  color: #1a1a1a;
}

/* ============== EMPTY STATE ============== */
.cart-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.cart-empty h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  color: #1a1a1a;
}

.cart-empty p {
  margin: 0 0 20px 0;
  font-size: 14px;
  color: #6b7280;
  line-height: 1.5;
}

.btn-back {
  display: inline-block;
  padding: 10px 16px;
  background: #2563eb;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-back:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
}

/* ============== ITEMS LIST ============== */
.cart-items {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  border-bottom: 1px solid #e5e7eb;
}

.cart-items::-webkit-scrollbar {
  width: 6px;
}

.cart-items::-webkit-scrollbar-track {
  background: transparent;
}

.cart-items::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 3px;
}

.cart-items::-webkit-scrollbar-thumb:hover {
  background: #9ca3af;
}

.cart-item {
  display: grid;
  grid-template-columns: 70px 1fr 32px;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  align-items: start;
}

.cart-item:last-child {
  border-bottom: none;
}

.item-image {
  width: 70px;
  height: 70px;
  background: #f3f4f6;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}

.item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-name {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.3;
}

.item-price {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #2563eb;
}

.quantity-control {
  display: flex;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
  width: fit-content;
}

.qty-btn {
  background: #f9fafb;
  border: none;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qty-btn:hover {
  background: #e5e7eb;
  color: #1a1a1a;
}

.qty-input {
  width: 40px;
  text-align: center;
  border: none;
  background: #f9fafb;
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
}

.qty-input:focus {
  outline: none;
}

.item-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
}

.subtotal {
  font-size: 14px;
  font-weight: 700;
  color: #1a1a1a;
}

.btn-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.2s ease;
  opacity: 0.6;
}

.btn-remove:hover {
  background: #fee2e2;
  opacity: 1;
}

/* ============== CUPÓN ============== */
.coupon-section {
  padding: 16px 20px;
  border-bottom: 1px solid #e5e7eb;
  background: #f9fafb;
}

.coupon-section label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: #6b7280;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.coupon-input-group {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.coupon-input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.2s ease;
}

.coupon-input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.coupon-btn {
  padding: 10px 16px;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s ease;
}

.coupon-btn:hover:not(:disabled) {
  background: #1d4ed8;
}

.coupon-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.coupon-remove {
  width: 100%;
  padding: 8px 12px;
  background: #fee2e2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.coupon-remove:hover {
  background: #fecaca;
}

.coupon-message {
  margin: 8px 0 0 0;
  font-size: 12px;
  font-weight: 600;
  animation: slideUp 0.3s ease;
}

.coupon-message.success {
  color: #059669;
}

.coupon-message.error {
  color: #dc2626;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============== SUMMARY ============== */
.cart-summary {
  padding: 16px 20px;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 13px;
  color: #6b7280;
}

.summary-row span:last-child {
  font-weight: 600;
  color: #1a1a1a;
}

.summary-row.free-shipping {
  color: #059669;
  font-weight: 600;
}

.summary-row.free-shipping span:last-child {
  color: #059669;
}

.summary-row.discount {
  color: #dc2626;
}

.summary-row.discount span:first-child {
  color: #6b7280;
}

.summary-row.discount span:last-child {
  color: #dc2626;
}

.summary-row.total {
  border-top: 2px solid #e5e7eb;
  padding-top: 12px;
  margin-top: 12px;
  font-size: 16px;
  color: #1a1a1a;
  font-weight: 700;
}

.summary-row.total span:last-child {
  font-size: 18px;
  color: #2563eb;
}

/* ============== ACTIONS ============== */
.cart-actions {
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  flex-direction: column;
}

.btn {
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  text-decoration: none;
  text-align: center;
  display: block;
}

.btn-primary {
  background: #2563eb;
  color: white;
}

.btn-primary:hover {
  background: #1d4ed8;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
  background: #f3f4f6;
  color: #1a1a1a;
  border: 1px solid #d1d5db;
}

.btn-secondary:hover {
  background: #e5e7eb;
  border-color: #9ca3af;
}

.btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 480px) {
  .cart-sidebar {
    max-width: 100%;
  }

  .cart-toggle {
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
  }

  .cart-toggle svg {
    width: 20px;
    height: 20px;
  }

  .cart-item {
    grid-template-columns: 60px 1fr 28px;
    gap: 8px;
  }

  .item-image {
    width: 60px;
    height: 60px;
  }

  .cart-header {
    padding: 16px;
  }

  .cart-header h2 {
    font-size: 18px;
  }

  .coupon-input-group {
    flex-direction: column;
  }

  .coupon-btn {
    width: 100%;
  }
}
