/**
 * BAZAAR — Professional Cart Drawer & Add-to-Cart UX
 */

/* ── Drawer overlay ── */
.cart-drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(4, 6, 14, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s;
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
}
.cart-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.cart-drawer {
  width: min(420px, 100vw);
  max-width: 100%;
  height: 100%;
  background: var(--card-bg, #141625);
  border-left: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  box-shadow: -12px 0 48px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}
.cart-drawer-overlay.active .cart-drawer {
  transform: translateX(0);
}

.cart-drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(212, 160, 23, 0.06) 0%, transparent 100%);
}
.cart-drawer-title-wrap h2 {
  font-size: 20px;
  font-weight: 900;
  color: var(--gold, #d4a017);
  margin: 0;
  line-height: 1.2;
}
.cart-drawer-sub {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
}
.cart-drawer-close {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--subtle);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.cart-drawer-close:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger, #ef4444);
  border-color: rgba(239, 68, 68, 0.3);
}

/* شريط الشحن المجاني */
.cart-shipping-progress {
  flex-shrink: 0;
  padding: 0 20px 14px;
}
.cart-shipping-progress-inner {
  background: var(--subtle);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}
.cart-shipping-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.cart-shipping-progress-label .highlight {
  color: var(--gold);
}
.cart-shipping-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
}
.cart-shipping-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #b8861a, #d4a017);
  border-radius: 6px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  min-width: 4%;
}
.cart-shipping-progress.done .cart-shipping-progress-label {
  color: var(--success, #10b981);
}

.cart-drawer-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 16px 16px;
  -webkit-overflow-scrolling: touch;
}

.cart-drawer-footer {
  flex-shrink: 0;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, rgba(8, 10, 18, 0.95) 0%, transparent 100%);
  display: none;
  flex-direction: column;
  gap: 10px;
}
.cart-drawer-footer.visible {
  display: flex;
}

.cart-drawer-footer .btn-checkout-main {
  width: 100%;
  padding: 14px 20px;
  font-size: 16px;
  font-weight: 800;
  border-radius: 14px;
  background: linear-gradient(135deg, #b8861a 0%, #d4a017 50%, #e8c04a 100%);
  color: #080a12;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(212, 160, 23, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.cart-drawer-footer .btn-checkout-main:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(212, 160, 23, 0.45);
}
.cart-drawer-footer .btn-continue-shop {
  width: 100%;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  font-family: inherit;
}
.cart-drawer-footer .btn-continue-shop:hover {
  color: var(--gold);
}

/* ── بطاقة منتج في السلة ── */
.cart-product-card {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 16px;
  transition: border-color 0.25s, box-shadow 0.25s;
  animation: cartItemIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.cart-product-card.is-new {
  border-color: rgba(212, 160, 23, 0.45);
  box-shadow: 0 0 0 1px rgba(212, 160, 23, 0.2), 0 8px 24px rgba(0, 0, 0, 0.2);
}
@keyframes cartItemIn {
  from {
    opacity: 0;
    transform: translateX(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
.cart-product-thumb {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  object-fit: cover;
  background: var(--bg);
}
.cart-product-thumb-emoji {
  width: 72px;
  height: 72px;
  border-radius: 12px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}
.cart-product-details {
  min-width: 0;
  text-align: right;
}
.cart-product-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cart-product-price-line {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.cart-product-price-line strong {
  color: var(--gold-dark, #b8861a);
}
.cart-qty-pill {
  display: inline-flex;
  align-items: center;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.cart-qty-pill .qty-btn {
  width: 34px;
  height: 34px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.cart-qty-pill .qty-btn:hover {
  background: var(--gold);
  color: #080a12;
}
.cart-qty-pill .qty-value {
  min-width: 32px;
  text-align: center;
  font-weight: 800;
  font-size: 14px;
}
.cart-product-aside {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.cart-product-line-total {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold);
  white-space: nowrap;
}
.cart-product-remove {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}
.cart-product-remove:hover {
  background: rgba(239, 68, 68, 0.22);
}

/* كوبون */
.cart-coupon-section {
  margin: 14px 0;
  padding: 14px;
  background: rgba(212, 160, 23, 0.04);
  border: 1px dashed rgba(212, 160, 23, 0.25);
  border-radius: 14px;
}
.cart-coupon-section label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.coupon-box {
  display: flex;
  gap: 8px;
}
.coupon-box .checkout-input {
  flex: 1;
  margin: 0;
}

/* ملخص */
.cart-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 12px 0;
}
.cart-summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 6px 0;
  color: var(--text-muted);
}
.cart-summary-row.discount span:last-child {
  color: var(--success, #10b981);
  font-weight: 700;
}
.cart-summary-total {
  display: flex;
  justify-content: space-between;
  font-size: 18px;
  font-weight: 900;
  color: var(--gold);
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}
.shipping-hint {
  font-size: 11px;
  color: var(--gold);
  text-align: center;
  padding-top: 8px;
  font-weight: 600;
}
.cart-clear-btn {
  width: 100%;
  margin-top: 4px;
  padding: 10px;
  font-size: 12px;
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
}
.cart-clear-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* حالة فارغة */
.cart-empty-state {
  text-align: center;
  padding: 48px 24px;
}
.cart-empty-visual {
  width: 100px;
  height: 100px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(212, 160, 23, 0.12), rgba(99, 102, 241, 0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  animation: cartEmptyFloat 3s ease-in-out infinite;
}
@keyframes cartEmptyFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.cart-empty-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 8px;
}
.cart-empty-desc {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ── إشعار «تمت الإضافة» ── */
.cart-add-toast {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9500;
  width: min(380px, calc(100vw - 32px));
  background: var(--card-bg);
  border: 1px solid rgba(212, 160, 23, 0.35);
  border-radius: 18px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.04);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: center;
  transform: translateY(120%) scale(0.92);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s, visibility 0.35s;
  pointer-events: none;
}
.cart-add-toast.visible {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.cart-add-toast-thumb {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--subtle);
}
.cart-add-toast-thumb-emoji {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: var(--subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.cart-add-toast-content {
  flex: 1;
  min-width: 0;
  text-align: right;
}
.cart-add-toast-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 800;
  color: var(--success, #10b981);
  background: rgba(16, 185, 129, 0.12);
  padding: 4px 10px;
  border-radius: 20px;
  margin-bottom: 6px;
}
.cart-add-toast-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 4px;
}
.cart-add-toast-price {
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
}
.cart-add-toast-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}
.cart-add-toast-actions button {
  font-size: 12px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}
.cart-add-toast-view {
  background: var(--gold);
  color: #080a12;
}
.cart-add-toast-dismiss {
  background: var(--subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* نبض أيقونة السلة */
.header-btn.cart-pulse {
  animation: cartBtnPulse 0.6s ease;
}
@keyframes cartBtnPulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.15); box-shadow: 0 0 20px rgba(212, 160, 23, 0.6); }
  100% { transform: scale(1); }
}
.cart-count.bump {
  animation: cartCountBump 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes cartCountBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.35); }
  100% { transform: scale(1); }
}

/* جسيم طيران للسلة */
.cart-fly-dot {
  position: fixed;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
  z-index: 9998;
  pointer-events: none;
  transition: left 0.65s cubic-bezier(0.4, 0, 0.2, 1), top 0.65s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s 0.5s, transform 0.65s;
}

@media (max-width: 480px) {
  .cart-drawer {
    width: 100%;
  }
  .cart-add-toast {
    left: 16px;
    right: 16px;
    width: auto;
    bottom: 16px;
  }
  .cart-product-card {
    grid-template-columns: 60px 1fr;
    grid-template-rows: auto auto;
  }
  .cart-product-aside {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
  }
}

/* ═══════════════════════════════════════════════════
   فاتورة A6 — Invoice Receipt
   ═══════════════════════════════════════════════════ */
.invoice-a6 {
  width: 100%;
  max-width: 380px;
  margin: 12px auto 0;
  background: #fff;
  color: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35), 0 0 0 1px rgba(0,0,0,0.08);
  font-family: 'Segoe UI', 'Noto Sans Arabic', sans-serif;
  direction: rtl;
}

/* رأس الفاتورة */
.inv-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  padding: 20px 16px 16px;
  text-align: center;
  position: relative;
}
.inv-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #d4a017, #f0c040, #d4a017);
}
.inv-logo {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  object-fit: contain;
  border: 2px solid rgba(212,160,23,0.4);
  background: rgba(255,255,255,0.05);
  display: block;
  margin: 0 auto 8px;
}
.inv-logo-emoji {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 8px;
}
.inv-store-name {
  font-size: 18px;
  font-weight: 900;
  color: #f0c040;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.inv-label {
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* خطوط فاصلة */
.inv-divider {
  height: 1px;
  background: #e5e5e5;
  margin: 0;
}
.inv-divider-dashed {
  background: none;
  border-top: 1.5px dashed #ccc;
  height: 0;
  margin: 2px 0;
}

/* شبكة معلومات الطلب */
.inv-meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 10px 14px;
  background: #f8f7f4;
}
.inv-meta-grid > div {
  display: flex;
  flex-direction: column;
  padding: 5px 6px;
  border-left: 1px solid #e8e8e8;
}
.inv-meta-grid > div:last-child,
.inv-meta-grid > div:nth-child(2) {
  border-left: none;
}
.inv-meta-label {
  font-size: 9px;
  color: #888;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.inv-meta-val {
  font-size: 11px;
  font-weight: 800;
  color: #1a1a1a;
  word-break: break-all;
}

/* بيانات العميل */
.inv-customer {
  padding: 10px 14px;
  background: #fff;
}
.inv-customer-title {
  font-size: 9px;
  font-weight: 800;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.inv-customer-row {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12px;
  color: #222;
  font-weight: 600;
  margin-bottom: 3px;
  line-height: 1.4;
}
.inv-customer-row span:first-child {
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* رأس جدول المنتجات */
.inv-products-header {
  display: grid;
  grid-template-columns: 1fr auto 90px;
  padding: 6px 14px;
  background: #1a1a2e;
  color: #f0c040;
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: right;
}
.inv-products-header span:last-child {
  text-align: left;
}

/* صف منتج */
.inv-product-row {
  display: grid;
  grid-template-columns: 36px 1fr 80px;
  gap: 8px;
  align-items: center;
  padding: 7px 14px;
  border-bottom: 1px solid #f0f0f0;
  background: #fff;
}
.inv-product-row:last-of-type {
  border-bottom: none;
}
.inv-product-img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  overflow: hidden;
  background: #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}
.inv-product-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.inv-product-info {
  min-width: 0;
}
.inv-product-name {
  font-size: 11px;
  font-weight: 800;
  color: #1a1a1a;
  line-height: 1.3;
  margin-bottom: 2px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.inv-product-meta {
  font-size: 10px;
  color: #888;
  font-weight: 600;
}
.inv-product-total {
  font-size: 12px;
  font-weight: 900;
  color: #1a1a2e;
  text-align: left;
  white-space: nowrap;
}

/* ملخص المبالغ */
.inv-totals {
  padding: 8px 14px;
  background: #fafafa;
}
.inv-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #555;
  font-weight: 600;
  padding: 3px 0;
}
.inv-total-row.inv-discount span:last-child {
  color: #10b981;
  font-weight: 800;
}
.inv-total-grand {
  display: flex;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 900;
  color: #1a1a2e;
  padding: 8px 0 4px;
  margin-top: 6px;
  border-top: 2px solid #1a1a2e;
}

/* تذييل الفاتورة */
.inv-footer-note {
  text-align: center;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: #555;
  background: #f8f7f4;
  line-height: 1.6;
}
.inv-footer-note small {
  font-size: 10px;
  color: #999;
  font-weight: 500;
}
