/* PanelShop — Header mini cart */

.panelshop-mini-cart {
  --ps-mini-cart-width: 380px;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  max-width: none;
  flex: 0 0 auto;
  align-self: center;
  direction: rtl;
  z-index: 100;
  vertical-align: middle;
  line-height: 0;
}

.panelshop-mini-cart *,
.panelshop-mini-cart *::before,
.panelshop-mini-cart *::after {
  box-sizing: border-box;
}

/* Trigger — فقط اندازه آیکون */
.ps-mini-cart-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  padding: 0;
  margin: 0;
  border: none;
  border-radius: var(--ps-radius, 12px);
  background: transparent;
  color: var(--ps-surface-700, #334155);
  cursor: pointer;
  line-height: 0;
  transition: background 0.2s ease, color 0.2s ease;
}

.ps-mini-cart-trigger:hover,
.panelshop-mini-cart.is-open .ps-mini-cart-trigger {
  background: var(--ps-surface-100, #f1f5f9);
  color: var(--ps-primary-600, #2563eb);
}

.ps-mini-cart-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
  width: 24px;
  height: 24px;
  max-width: 24px;
  max-height: 24px;
  flex-shrink: 0;
  overflow: hidden;
}

.ps-mini-cart-icon svg,
.ps-mini-cart-icon-img {
  display: block;
  width: 24px;
  height: 24px;
  max-width: 24px;
  max-height: 24px;
  object-fit: contain;
}

.ps-mini-cart-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 10px;
  font-weight: var(--ps-fw-heading);
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, var(--ps-primary-500, #3b82f6), var(--ps-primary-700, #1d4ed8));
  border: 2px solid #fff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  pointer-events: none;
}

.ps-mini-cart-badge.ps-badge-pulse {
  animation: psMiniCartBadgePulse 0.45s ease;
}

@keyframes psMiniCartBadgePulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Dropdown — خارج از جریان چیدمان هدر */
.ps-mini-cart-dropdown {
  position: absolute;
  top: calc(100% + 10px);
  width: var(--ps-mini-cart-width);
  max-width: min(var(--ps-mini-cart-width), calc(100vw - 24px));
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px) scale(0.98);
  transform-origin: top center;
  transition:
    opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    visibility 0.28s;
  pointer-events: none;
  z-index: 10001;
  line-height: 1.6;
}

.ps-mini-cart-dropdown[hidden] {
  display: block !important;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.panelshop-mini-cart[data-position="right"] .ps-mini-cart-dropdown {
  left: 0;
}

.panelshop-mini-cart[data-position="left"] .ps-mini-cart-dropdown {
  right: 0;
}

.panelshop-mini-cart.is-open .ps-mini-cart-dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.ps-mini-cart-dropdown::before {
  content: '';
  position: absolute;
  top: -14px;
  left: 0;
  right: 0;
  height: 14px;
}

.ps-mini-cart-panel {
  background: #fff;
  border: 1px solid var(--ps-surface-200, #e2e8f0);
  border-radius: var(--ps-radius-lg, 16px);
  box-shadow:
    0 4px 6px -1px rgba(15, 23, 42, 0.06),
    0 20px 40px -8px rgba(15, 23, 42, 0.14);
  overflow: hidden;
}

.ps-mini-cart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ps-surface-100, #f1f5f9);
  background: linear-gradient(180deg, #fff 0%, var(--ps-surface-50, #f8fafc) 100%);
}

.ps-mini-cart-header-text strong {
  display: block;
  font-size: 15px;
  font-weight: var(--ps-fw-heading);
  color: var(--ps-surface-800, #1e293b);
}

.ps-mini-cart-count-label {
  display: block;
  font-size: 12px;
  color: var(--ps-surface-400, #94a3b8);
  margin-top: 2px;
  min-height: 18px;
}

.ps-mini-cart-close {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--ps-surface-500, #64748b);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.ps-mini-cart-close:hover {
  background: var(--ps-surface-100, #f1f5f9);
  color: var(--ps-surface-800, #1e293b);
}

.ps-mini-cart-body {
  max-height: 340px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.ps-mini-cart-body::-webkit-scrollbar {
  width: 5px;
}

.ps-mini-cart-body::-webkit-scrollbar-thumb {
  background: var(--ps-surface-300, #cbd5e1);
  border-radius: 999px;
}

.ps-mini-cart-items {
  padding: 4px 0;
}

.ps-mini-cart-loading,
.ps-mini-cart-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 16px;
  font-size: 13px;
  color: var(--ps-surface-400, #94a3b8);
  text-align: center;
}

.ps-mini-cart-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--ps-surface-200, #e2e8f0);
  border-top-color: var(--ps-primary-500, #3b82f6);
  border-radius: 50%;
  animation: psMiniCartSpin 0.7s linear infinite;
}

@keyframes psMiniCartSpin {
  to { transform: rotate(360deg); }
}

.ps-mini-cart-empty {
  display: none;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px 32px;
  gap: 12px;
}

.ps-mini-cart-empty.ps-is-visible,
.ps-mini-cart-empty:not([hidden]) {
  display: flex;
}

.ps-mini-cart-footer {
  display: none;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--ps-surface-100, #f1f5f9);
  background: var(--ps-surface-50, #f8fafc);
}

.ps-mini-cart-footer.ps-is-visible,
.ps-mini-cart-footer:not([hidden]) {
  display: block;
}

.ps-mini-cart-empty-icon {
  color: var(--ps-surface-300, #cbd5e1);
  margin-bottom: 4px;
}

.ps-mini-cart-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--ps-surface-500, #64748b);
}

.ps-mini-cart-continue {
  margin-top: 4px;
  font-size: 13px;
}

.ps-mini-cart-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px 12px;
  align-items: start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--ps-surface-100, #f1f5f9);
  transition: background 0.15s ease;
}

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

.ps-mini-cart-item:hover {
  background: var(--ps-surface-50, #f8fafc);
}

.ps-mini-cart-item-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--ps-surface-100, #f1f5f9);
  background: var(--ps-surface-50, #f8fafc);
}

.ps-mini-cart-item-info {
  min-width: 0;
}

.ps-mini-cart-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ps-surface-800, #1e293b);
  line-height: 1.45;
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.ps-mini-cart-item-variant {
  display: block;
  font-size: 11px;
  color: var(--ps-surface-400, #94a3b8);
  margin-bottom: 2px;
}

.ps-mini-cart-item-unit {
  font-size: 11px;
  color: var(--ps-surface-400, #94a3b8);
}

.ps-mini-cart-item-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.ps-mini-qty-pill {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 2px;
  background: var(--ps-surface-100, #f1f5f9);
  border-radius: 999px;
}

.ps-mini-qty-pill .ps-qty-btn {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 999px;
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  color: var(--ps-surface-600, #475569);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.ps-mini-qty-pill .ps-qty-btn:hover {
  background: var(--ps-primary-100, #dbeafe);
  color: var(--ps-primary-700, #1d4ed8);
}

.ps-mini-qty-pill span {
  min-width: 24px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ps-surface-800, #1e293b);
}

.ps-mini-cart-item-total {
  font-size: 13px;
  font-weight: var(--ps-fw-heading);
  color: var(--ps-primary-600, #2563eb);
  white-space: nowrap;
}

.ps-mini-cart-total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  font-size: 14px;
  color: var(--ps-surface-600, #475569);
}

.ps-mini-cart-total-row strong {
  font-size: 17px;
  font-weight: var(--ps-fw-heading);
  color: var(--ps-surface-900, #0f172a);
}

.ps-mini-cart-checkout {
  font-weight: 700;
}

.ps-mini-cart-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
}

.ps-mini-cart-backdrop:not([hidden]) {
  display: block;
}

.panelshop-mini-cart.is-busy {
  pointer-events: none;
  opacity: 0.85;
}

@media (max-width: 768px) {
  .ps-mini-cart-close {
    display: inline-flex;
  }

  body.ps-mini-cart-open .panelshop-mini-cart {
    z-index: 100000;
  }

  body.ps-mini-cart-open .ps-mobile-purchase-bar {
    display: none !important;
  }

  body.ps-mini-cart-open.ps-has-mobile-purchase {
    padding-bottom: 0 !important;
  }

  .ps-mini-cart-dropdown {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0 !important;
    right: 0 !important;
    width: 100%;
    max-width: 100%;
    transform: translateY(100%);
    transform-origin: bottom center;
    border-radius: 0;
    z-index: 10002;
  }

  .panelshop-mini-cart.is-open .ps-mini-cart-dropdown {
    transform: translateY(0);
  }

  .ps-mini-cart-dropdown::before {
    display: none;
  }

  .ps-mini-cart-panel {
    border-radius: var(--ps-radius-xl, 20px) var(--ps-radius-xl, 20px) 0 0;
    max-height: min(85vh, 640px);
    display: flex;
    flex-direction: column;
  }

  .ps-mini-cart-body {
    flex: 1;
    max-height: none;
  }

  .ps-mini-cart-backdrop:not([hidden]) {
    display: block;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    animation: psMiniCartFadeIn 0.25s ease;
    z-index: 10001;
  }

  body.ps-has-mobile-purchase.ps-mini-cart-open .ps-mini-cart-foot {
    padding-bottom: calc(16px + 72px + env(safe-area-inset-bottom, 0px));
  }

  body.ps-mini-cart-open {
    overflow: hidden;
  }
}

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

.elementor-widget-panelshop_mini_cart,
.elementor-widget-panelshop_mini_cart .elementor-widget-container,
.elementor-widget-panelshop_mini_cart .panelshop-elementor-inner,
.elementor-widget-panelshop_mini_cart .panelshop-mini-cart {
  width: auto !important;
  max-width: none !important;
  flex: 0 0 auto !important;
  min-width: 0;
  min-height: 0 !important;
  overflow: visible !important;
}

.elementor-widget-panelshop_mini_cart .panelshop-elementor-widget {
  width: auto;
  display: inline-flex;
}
