/* side cart */

/* =========================================
   Cart Drawer
========================================= */

.cart-drawer-overlay {
  position: fixed;
  inset: 0;

  z-index: 9998;

  background: rgba(0, 0, 0, 0.45);

  opacity: 0;
  visibility: hidden;

  transition:
    opacity 0.35s ease,
    visibility 0.35s ease;
}

.cart-drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}


/* =========================================
   Drawer
========================================= */

.cart-drawer {
  position: fixed;

  top: 0;

  /*
    الاتجاه الافتراضي LTR
    السلة تظهر من اليمين
  */
  inset-inline-end: 0;
  inset-inline-start: auto;

  z-index: 9999;

  width: min(440px, 100%);
  height: 100dvh;

  display: flex;
  flex-direction: column;

  background: var(--background, #fff);
  color: var(--foreground, #111);

  box-shadow:
    -12px 0 40px rgba(0, 0, 0, 0.12);

  transform: translateX(100%);

  visibility: hidden;

  transition:
    transform 0.45s cubic-bezier(.16, 1, .3, 1),
    visibility 0.45s ease;
}


/* =========================================
   LTR
   English → Drawer from Right
========================================= */

[dir="ltr"] .cart-drawer {
  inset-inline-end: 0;
  inset-inline-start: auto;

  transform: translateX(100%);

  box-shadow:
    -12px 0 40px rgba(0, 0, 0, 0.12);
}

[dir="ltr"] .cart-drawer.active {
  transform: translateX(0);
}


/* =========================================
   RTL
   Arabic → Drawer from Left
========================================= */

[dir="rtl"] .cart-drawer {
 

  transform: translateX(-100%);

  box-shadow:
    12px 0 40px rgba(0, 0, 0, 0.12);
}

[dir="rtl"] .cart-drawer.active {
  transform: translateX(0);
}


/* =========================================
   Active
========================================= */

.cart-drawer.active {
  visibility: visible;
}


/* =========================================
   Header
========================================= */

.cart-drawer__header {
  position: relative;

  flex-shrink: 0;

  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: 76px;

  padding: 0 22px;

  border-bottom: 1px solid
    var(--border-light, #eee);
}

.cart-drawer__heading {
  display: flex;
  align-items: center;

  gap: 10px;
}

.cart-drawer__heading h2 {
  margin: 0;

  font-size: 18px;
  font-weight: 700;
}

.cart-drawer__count {
  min-width: 24px;
  height: 24px;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0 6px;

  border-radius: 50%;

  background: var(--primary-color, #111);
  color: #fff;

  font-size: 11px;
  font-weight: 700;
}

.cart-drawer__close {
  width: 38px;
  height: 38px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 0;
  border-radius: 50%;

  background: transparent;
  color: inherit;

  cursor: pointer;

  transition:
    background .25s ease,
    color .25s ease,
    transform .25s ease;
}

.cart-drawer__close:hover {
  background: rgba(0, 0, 0, .06);

  color: var(--primary-color, #111);

  transform: rotate(90deg);
}


/* =========================================
   Body
========================================= */

.cart-drawer__body {
  position: relative;

  flex: 1;

  min-height: 0;

  overflow-y: auto;

  padding: 18px;
}

.cart-drawer__body::-webkit-scrollbar {
  width: 5px;
}

.cart-drawer__body::-webkit-scrollbar-thumb {
  border-radius: 10px;

  background: rgba(0, 0, 0, .15);
}


/* =========================================
   Items
========================================= */

.cart-drawer__items {
  display: flex;
  flex-direction: column;

  gap: 12px;
}


/* =========================================
   Product
========================================= */

.cart-drawer__item {
  position: relative;

  display: flex;

  gap: 12px;

  padding: 12px;

  border: 1px solid
    var(--border-light, #eee);

  border-radius: 14px;

  background: var(--background, #fff);

  transition:
    opacity .25s ease,
    box-shadow .25s ease;
}

.cart-drawer__item:hover {
  box-shadow:
    0 6px 20px rgba(0, 0, 0, .06);
}

.cart-drawer__item.is-loading {
  opacity: .5;
  pointer-events: none;
}


/* =========================================
   Image
========================================= */

.cart-drawer__image {
  flex: 0 0 82px;

  width: 82px;
  height: 82px;

  overflow: hidden;

  border-radius: 10px;

  background: #f5f5f5;
}

.cart-drawer__image img {
  width: 100%;
  height: 100%;

  display: block;

  object-fit: cover;
}


/* =========================================
   Info
========================================= */

.cart-drawer__info {
  min-width: 0;

  flex: 1;

  display: flex;
  flex-direction: column;

  justify-content: space-between;

  gap: 10px;

  /*
    بدل padding-right
    عشان يشتغل RTL / LTR
  */
  padding-inline-end: 26px;
}

.cart-drawer__name {
  display: -webkit-box;

  overflow: hidden;

  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;

  font-size: 14px;
  line-height: 1.5;

  font-weight: 600;
}

.cart-drawer__price {
  margin-top: 5px;

  font-size: 14px;

  font-weight: 700;

  color: var(--primary-color, #111);
}


/* =========================================
   Remove
========================================= */

.cart-drawer__remove {
  position: absolute;

  top: 10px;

  /*
    بدل left
    يتحرك تلقائيًا حسب الاتجاه
  */
  inset-inline-end: 10px;

  width: 30px;
  height: 30px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: 0;

  background: transparent;

  color: #999;

  cursor: pointer;

  transition:
    color .2s ease,
    transform .2s ease;
}

.cart-drawer__remove:hover {
  color: #dc2626;

  transform: scale(1.1);
}


/* =========================================
   Quantity
========================================= */

.cart-drawer__quantity {
  display: inline-flex;
  align-items: center;

  width: fit-content;

  height: 32px;

  overflow: hidden;

  border: 1px solid
    var(--border-light, #ddd);

  border-radius: 8px;
}

.cart-drawer__quantity button {
  width: 32px;
  height: 32px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;

  border: 0;

  background: transparent;
  color: inherit;

  cursor: pointer;
}

.cart-drawer__quantity button:hover {
  background: rgba(0, 0, 0, .05);
}

.cart-drawer__quantity button:disabled {
  opacity: .3;

  cursor: not-allowed;
}

.cart-drawer__quantity span {
  min-width: 36px;
  height: 32px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-inline:
    1px solid var(--border-light, #ddd);

  font-size: 13px;

  font-weight: 600;
}


/* =========================================
   Empty
========================================= */

.cart-drawer__empty {
  min-height: 360px;

  display: flex;
  flex-direction: column;

  align-items: center;
  justify-content: center;

  text-align: center;

  padding: 30px;
}

.cart-drawer__empty-icon {
  width: 70px;
  height: 70px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin-bottom: 16px;

  border-radius: 50%;

  background: rgba(0, 0, 0, .04);

  font-size: 28px;

  opacity: .5;
}

.cart-drawer__empty h3 {
  margin: 0 0 8px;

  font-size: 17px;
}

.cart-drawer__empty p {
  max-width: 260px;

  margin: 0;

  font-size: 13px;

  line-height: 1.7;

  opacity: .6;
}


/* =========================================
   Loading
========================================= */

.cart-drawer__loading {
  position: absolute;

  inset: 0;

  z-index: 5;

  display: flex;

  align-items: center;
  justify-content: center;

  background: rgba(255, 255, 255, .6);
}

.cart-drawer__spinner {
  width: 30px;
  height: 30px;

  border: 3px solid #ddd;

  border-top-color:
    var(--primary-color, #111);

  border-radius: 50%;

  animation:
    cart-drawer-spin .7s linear infinite;
}

@keyframes cart-drawer-spin {
  to {
    transform: rotate(360deg);
  }
}


/* =========================================
   Footer
========================================= */

.cart-drawer__footer {
  flex-shrink: 0;

  padding: 18px;

  border-top: 1px solid
    var(--border-light, #eee);

  background: var(--background, #fff);
}


/* =========================================
   Summary
========================================= */

.cart-drawer__summary {
  display: flex;
  flex-direction: column;

  gap: 10px;

  margin-bottom: 18px;
}

.cart-drawer__summary-row {
  display: flex;

  align-items: center;
  justify-content: space-between;

  font-size: 14px;

  opacity: .75;
}

.cart-drawer__summary-row strong {
  font-weight: 600;
}

.cart-drawer__summary-row--total {
  padding-top: 12px;

  border-top: 1px solid
    var(--border-light, #eee);

  font-size: 17px;

  font-weight: 700;

  opacity: 1;
}

.cart-drawer__summary-row--total strong {
  font-size: 18px;
}


/* =========================================
   Coupon
========================================= */

.cart-drawer__coupon {
  margin-bottom: 18px;
}

.cart-drawer__coupon label {
  display: block;

  margin-bottom: 7px;

  font-size: 13px;

  font-weight: 600;
}

.cart-drawer__coupon-box {
  display: flex;

  gap: 8px;
}

.cart-drawer__coupon-box input {
  min-width: 0;

  flex: 1;

  height: 42px;

  padding: 0 12px;

  border: 1px solid
    var(--border-light, #ddd);

  border-radius: 9px;

  background: transparent;
  color: inherit;

  outline: none;

  font-size: 13px;
}

.cart-drawer__coupon-box input:focus {
  border-color:
    var(--primary-color, #111);
}

.cart-drawer__coupon-box button {
  flex-shrink: 0;

  height: 42px;

  padding: 0 16px;

  border: 0;

  border-radius: 9px;

  background: var(--primary-color, #111);
  color: #fff;

  cursor: pointer;

  font-size: 13px;
  font-weight: 600;
}

.cart-drawer__coupon-box button:disabled {
  opacity: .5;

  cursor: not-allowed;
}

.cart-drawer__coupon-msg {
  min-height: 16px;

  margin-top: 6px;

  font-size: 11px;
}

.cart-drawer__coupon-msg.success {
  color: #16a34a;
}

.cart-drawer__coupon-msg.error {
  color: #dc2626;
}


/* =========================================
   Actions
========================================= */

.cart-drawer__actions {
  display: grid;

  grid-template-columns: 1fr 1fr;

  gap: 8px;
}

.cart-drawer__actions a {
  height: 48px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;

  text-decoration: none;

  font-size: 13px;

  font-weight: 600;

  transition:
    opacity .2s ease,
    transform .2s ease;
}

.cart-drawer__actions a:hover {
  opacity: .9;

  transform: translateY(-1px);
}

.cart-drawer__cart-btn {
  background: transparent;

  border: 1px solid
    var(--border-light, #ddd);

  color: inherit;
}

.cart-drawer__checkout-btn {
  background:
    var(--primary-color, #111);

  color: #fff;
}


/* =========================================
   RTL adjustments
========================================= */

[dir="rtl"] .cart-drawer {
  direction: rtl;
}

[dir="rtl"] .cart-drawer__info {
  padding-inline-end: 26px;
}


/* =========================================
   LTR adjustments
========================================= */

[dir="ltr"] .cart-drawer {
  direction: ltr;
}

[dir="ltr"] .cart-drawer__info {
  padding-inline-end: 26px;
}


/* =========================================
   Mobile
========================================= */

@media (max-width: 480px) {

  .cart-drawer {
    width: 100%;
  }

  .cart-drawer__body {
    padding: 14px;
  }

  .cart-drawer__footer {
    padding: 14px;
  }

  .cart-drawer__image {
    flex-basis: 72px;

    width: 72px;
    height: 72px;
  }

}