/**
 * Luxury Persian Mobile & Accessory Storefront - Cart Drawer & Checkout CSS
 * Full RTL support, high-velocity GPU slide transitions, SnappPay BNPL widget,
 * and adaptive dark mode styling.
 */

/* ==========================================================================
   Backdrop & Drawer Shell
   ========================================================================== */
.cart-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

.cart-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--color-surface, #ffffff);
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 380ms cubic-bezier(0.16, 1, 0.3, 1), visibility 380ms;
  direction: rtl;
  font-family: inherit;
}

.cart-drawer.is-open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

/* ==========================================================================
   Header Section
   ========================================================================== */
.cart-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border-subtle, #f1f5f9);
  background: var(--color-surface, #ffffff);
}

.cart-drawer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-text-main, #0f172a);
}

.cart-drawer-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--color-primary-50, #eff6ff);
  color: var(--color-primary-600, #2563eb);
  font-size: 0.8rem;
  font-weight: 700;
}

.cart-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle, #e2e8f0);
  background: var(--bg-surface-muted, #f1f5f9);
  color: var(--text-primary, #64748b);
  cursor: pointer;
  transition: all 220ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 0;
  flex-shrink: 0;
}

.cart-drawer-close:hover {
  background: var(--bg-surface-sunken, #e2e8f0);
  border-color: var(--border-default, #cbd5e1);
  color: var(--text-primary, #0f172a);
  transform: scale(1.06);
}

.cart-drawer-close:active {
  transform: scale(0.95);
}

[data-theme="dark"] .cart-drawer-close {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: #94a3b8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .cart-drawer-close:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: scale(1.06);
}

/* ==========================================================================
   Free Shipping Meter Bar
   ========================================================================== */
.shipping-meter {
  padding: 14px 24px;
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 1px solid var(--color-border-subtle, #e2e8f0);
}

.shipping-meter-text {
  font-size: 0.84rem;
  color: var(--color-text-muted, #475569);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.shipping-meter-text strong {
  color: var(--color-primary-600, #2563eb);
}

.shipping-meter-text.is-qualified strong {
  color: #047857;
}

.shipping-meter-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.shipping-meter-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
  transition: width 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* ==========================================================================
   Cart Item List (Scrollable)
   ========================================================================== */
.cart-items-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cart-item-card {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 16px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  background: var(--bg-surface, #ffffff);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  transition: all 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.cart-item-card:hover {
  border-color: #cbd5e1;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

.cart-item-thumb {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: var(--bg-surface-muted, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid var(--border-subtle, #e2e8f0);
  flex-shrink: 0;
}

.cart-item-thumb img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.cart-item-details {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.cart-item-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-text-main, #1e293b);
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cart-item-variant {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--color-text-muted, #64748b);
  margin-bottom: 8px;
}

.cart-item-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.cart-item-price {
  font-weight: 800;
  font-size: 1rem;
  color: var(--color-text-main, #0f172a);
}

.cart-item-price small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-text-muted, #64748b);
  margin-right: 4px;
}

.cart-qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle, #e2e8f0);
  background: var(--bg-surface-muted, #f8fafc);
  transition: border-color 150ms ease;
}

.cart-qty-stepper:hover {
  border-color: #cbd5e1;
}

.cart-qty-btn {
  background: transparent;
  border: none;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--text-secondary, #475569);
  cursor: pointer;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 150ms ease;
  user-select: none;
}

.cart-qty-btn:hover {
  color: #2563eb;
  transform: scale(1.15);
}

.cart-qty-btn:active {
  transform: scale(0.9);
}

.cart-qty-val {
  min-width: 24px;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #0f172a;
}

.cart-item-delete {
  background: transparent;
  border: none;
  color: #475569;
  cursor: pointer;
  padding: 4px;
  transition: color 150ms ease;
  display: inline-flex;
  align-items: center;
}

.cart-item-delete:hover {
  color: #ef4444;
}

/* ==========================================================================
   Coupon Input Section
   ========================================================================== */
.coupon-box {
  padding: 12px 24px;
  background: var(--color-surface, #ffffff);
  border-top: 1px solid var(--color-border-subtle, #f1f5f9);
}

.coupon-form {
  display: flex;
  gap: 8px;
}

.coupon-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  font-family: inherit;
  font-size: 0.85rem;
  background: #f8fafc;
  outline: none;
  transition: border-color 150ms ease;
}

.coupon-input:focus {
  border-color: #3b82f6;
  background: #ffffff;
}

.coupon-btn {
  padding: 10px 16px;
  border-radius: 10px;
  background: #0f172a;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease;
}

.coupon-btn:hover {
  background: #1e293b;
}

.coupon-msg {
  font-size: 0.78rem;
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  display: none;
}

.coupon-msg.is-success {
  display: block;
  background: #ecfdf5;
  color: #065f46;
}

.coupon-msg.is-error {
  display: block;
  background: #fef2f2;
  color: #991b1b;
}

/* ==========================================================================
   Gateway BNPL Selector
   ========================================================================== */
.gateway-selection {
  padding: 14px 24px;
  background: #f8fafc;
  border-top: 1px solid var(--color-border-subtle, #e2e8f0);
}

.gateway-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: #334155;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.gateway-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gateway-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: all 180ms ease;
}

.gateway-card.is-selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 1px #2563eb;
}

.gateway-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #1e293b;
}

.gateway-pill {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: #dbeafe;
  color: #1d4ed8;
  font-weight: 700;
}

.gateway-pill.snapp {
  background: #fce7f3;
  color: #be185d;
}

/* ==========================================================================
   SnappPay BNPL Monthly Ticker
   ========================================================================== */
.snapppay-ticker {
  margin: 12px 24px;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(135deg, #fff1f2 0%, #fdf2f8 100%);
  border: 1px solid #fecdd3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.snapppay-ticker-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.snapppay-badge-logo {
  font-size: 0.75rem;
  font-weight: 900;
  background: #e11d48;
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: -0.5px;
}

.snapppay-text {
  font-size: 0.82rem;
  color: #881337;
  font-weight: 600;
  line-height: 1.35;
}

.snapppay-text strong {
  font-weight: 900;
  color: #e11d48;
}

/* ==========================================================================
   Footer Summary & Sticky CTA
   ========================================================================== */
.cart-drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border-subtle, #e2e8f0);
  background: var(--color-surface, #ffffff);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.cart-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.88rem;
  color: var(--color-text-muted, #64748b);
  margin-bottom: 8px;
}

.cart-summary-row.is-total {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--color-text-main, #0f172a);
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #e2e8f0;
}

.cart-summary-val {
  font-weight: 800;
  color: var(--color-text-main, #0f172a);
}

.cart-summary-val.is-discount {
  color: #dc2626;
}

.cart-checkout-btn {
  width: 100%;
  padding: 14px 20px;
  margin-top: 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 900;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(2, 132, 199, 0.35);
  transition: all 180ms ease;
}

[data-theme="dark"] .cart-checkout-btn {
  background: linear-gradient(135deg, #0284c7 0%, #026496 100%);
  box-shadow: 0 6px 22px rgba(2, 132, 199, 0.5);
}

.cart-checkout-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(2, 132, 199, 0.5);
}

.cart-checkout-btn:active {
  transform: translateY(0);
}

/* ==========================================================================
   Empty Cart State
   ========================================================================== */
.cart-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
}

.cart-empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  color: #94a3b8;
}

.cart-empty-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--color-text-main, #0f172a);
  margin-bottom: 8px;
}

.cart-empty-desc {
  font-size: 0.88rem;
  color: var(--color-text-muted, #64748b);
  max-width: 280px;
  line-height: 1.5;
  margin-bottom: 20px;
}

/* ==========================================================================
   Dark Theme Adaptations
   ========================================================================== */
[data-theme="dark"] .cart-drawer {
  background: #0f172a;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .cart-drawer-header,
[data-theme="dark"] .coupon-box,
[data-theme="dark"] .cart-drawer-footer {
  background: #0f172a;
  border-color: #1e293b;
}

[data-theme="dark"] .cart-drawer-title,
[data-theme="dark"] .cart-summary-val,
[data-theme="dark"] .cart-empty-title {
  color: #f8fafc;
}

[data-theme="dark"] .cart-drawer-close {
  border-color: #334155;
  color: #94a3b8;
}

[data-theme="dark"] .shipping-meter,
[data-theme="dark"] .gateway-selection {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .shipping-meter-text,
[data-theme="dark"] .cart-empty-desc,
[data-theme="dark"] .cart-summary-row {
  color: #94a3b8;
}

[data-theme="dark"] .shipping-meter-track {
  background: #334155;
}

[data-theme="dark"] .cart-item-card {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .cart-item-thumb {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .cart-item-thumb svg {
  color: #94a3b8;
}

[data-theme="dark"] .cart-item-title,
[data-theme="dark"] .cart-item-price {
  color: #f1f5f9;
}

[data-theme="dark"] .cart-qty-stepper {
  background: #0f172a;
  border-color: #334155;
}

[data-theme="dark"] .cart-qty-val {
  color: #f8fafc;
}

[data-theme="dark"] .coupon-input {
  background: #1e293b;
  border-color: #334155;
  color: #f8fafc;
}

[data-theme="dark"] .gateway-card {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .gateway-card.is-selected {
  background: #1e3a8a;
  border-color: #3b82f6;
}

[data-theme="dark"] .gateway-label {
  color: #f1f5f9;
}

[data-theme="dark"] .snapppay-ticker {
  background: #4c0519;
  border-color: #9f1239;
}

[data-theme="dark"] .snapppay-text {
  color: #fecdd3;
}

/* ==========================================================================
   Cart Add Notification Toast (Singleton & Anti-Spam Animation)
   ========================================================================== */
.cart-toast-notification {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 99999;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 16px;
  box-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.16), 0 4px 14px rgba(16, 185, 129, 0.12);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  direction: rtl;
  max-width: 480px;
  width: calc(100% - 32px);
  opacity: 0;
  pointer-events: none;
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 240ms ease;
}

.cart-toast-notification.is-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.cart-toast-notification.is-bumped {
  animation: toastBumpAnim 260ms ease;
}

@keyframes toastBumpAnim {
  0% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.04); }
  100% { transform: translateX(-50%) scale(1); }
}

.cart-toast-icon-wrap {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.15rem;
  font-weight: 900;
}

.cart-toast-content {
  flex: 1;
  min-width: 0;
}

.cart-toast-title {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--color-text-main, #0f172a);
  display: flex;
  align-items: center;
  gap: 6px;
}

.cart-toast-prod-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: #334155;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cart-toast-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cart-toast-view-btn {
  padding: 6px 14px;
  border-radius: 10px;
  background: #2563eb;
  color: #ffffff;
  font-family: inherit;
  font-size: 0.775rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background 150ms ease;
}

.cart-toast-view-btn:hover {
  background: #1d4ed8;
}

.cart-toast-close-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 1rem;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 150ms ease;
}

.cart-toast-close-btn:hover {
  color: #ef4444;
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .cart-toast-notification {
  background: rgba(15, 23, 42, 0.94);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 16px 40px -6px rgba(0, 0, 0, 0.55), 0 4px 14px rgba(16, 185, 129, 0.15);
}

[data-theme="dark"] .cart-toast-title {
  color: #f8fafc;
}

[data-theme="dark"] .cart-toast-prod-name {
  color: #cbd5e1;
}

[data-theme="dark"] .cart-toast-icon-wrap {
  background: rgba(6, 95, 70, 0.4);
  border-color: #059669;
  color: #34d399;
}

[data-theme="dark"] .cart-summary-val.is-discount {
  color: #fda4af;
}

[data-theme="dark"] .shipping-meter-text.is-qualified strong {
  color: #34d399;
}

[data-theme="dark"] .cart-item-delete,
[data-theme="dark"] .cart-toast-close-btn {
  color: #94a3b8;
}

[data-theme="dark"] .coupon-msg.is-success {
  background: rgba(6, 95, 70, 0.35);
  color: #6ee7b7;
}

[data-theme="dark"] .coupon-msg.is-error {
  background: rgba(153, 27, 27, 0.35);
  color: #fca5a5;
}

@media (max-width: 480px) {
  .cart-drawer-header,
  .shipping-meter,
  .cart-items-container,
  .coupon-box,
  .gateway-selection,
  .cart-drawer-footer {
    padding-inline: 14px;
  }
  .snapppay-ticker {
    margin: 10px 14px;
    padding: 10px 12px;
  }
  .cart-item-card {
    grid-template-columns: 64px 1fr;
    gap: 12px;
    padding: 12px;
  }
  .cart-item-thumb {
    width: 64px;
    height: 64px;
  }
}
