/* ==========================================================================
   Cognitive Pharmacy - Shopping Cart (client-side, localStorage based)
   ========================================================================== */

body.cp-cart-open {
  overflow: hidden;
}

.cp-cart-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 18, 14, 0.55);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

.cp-cart-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.cp-cart-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: 400px;
  max-width: 92vw;
  background: #fff;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.32s ease;
  box-shadow: -10px 0 30px rgba(0, 0, 0, 0.18);
}

.cp-cart-drawer.is-open {
  transform: translateX(0);
}

.cp-cart-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.cp-cart-drawer__title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.cp-cart-drawer__close {
  background: none;
  border: none;
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  color: #444;
  padding: 4px 8px;
}

.cp-cart-drawer__items {
  flex: 1;
  overflow-y: auto;
  padding: 10px 20px;
}

.cp-cart-empty-msg {
  text-align: center;
  opacity: 0.6;
  padding: 60px 10px;
  font-size: 14px;
}

.cp-cart-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid #f0f0f0;
}

.cp-cart-item__img {
  width: 56px;
  height: 78px;
  object-fit: cover;
  border-radius: 6px;
  background: #efeae0;
  flex-shrink: 0;
}

.cp-cart-item__info {
  flex: 1;
  min-width: 0;
}

.cp-cart-item__title {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.cp-cart-item__price {
  font-size: 13px;
  opacity: 0.7;
}

.cp-cart-item__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cp-cart-item__qty {
  display: flex;
  align-items: center;
  gap: 8px;
}

button.cp-cart-drawer__close {
  padding: 5px 10px 2px 10px;
  font-size: 25px !important;
  display: flex;
  align-content: center;
  justify-content: center;
  align-items: center;
  color: var(--e-global-color-text, black);
  background: var(--e-global-color-3bca2e6, #fff);
}

button.cp-cart-drawer__close:hover {
  color: var(--e-global-color-3bca2e6, black);
  background: var(--e-global-color-8b7f6e7, #fff);
}

button.cp-cart-checkout-whatsapp {
  font-size: 18px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: "Tajawal" !important;
  background-color: #25d366 !important;
  color: var(--e-global-color-1070a7b) !important;
}

button.cp-cart-checkout-whatsapp:hover {
  background-color: var(--e-global-color-3bca2e6) !important;
  color: var(--e-global-color-8b7f6e7) !important;
}

.cp-cart-item__qty button {
  width: 24px;
  height: 24px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1;
  font-size: 14px;
}

.cp-cart-item__qty span {
  min-width: 18px;
  text-align: center;
  font-size: 16px;
}

.cp-cart-item__qty > button {
  padding: 0;
  font-size: 18px !important;
  width: 25px !important;
  height: 25px !important;
  display: flex;
  justify-content: center;
  align-items: center;
}

.cp-cart-item__qty > button:hover {
  background: var(--e-global-color-primary);
  color: var(--e-global-color-3bca2e6);
}

.cp-cart-item__remove {
  padding: 5px 13px;
  font-size: 14px;
  font-family: "Tajawal";
  text-decoration: none;
  color: var(--e-global-color-text, black);
  background: var(--e-global-color-3bca2e6, #fff);
}

button.cp-cart-item__remove:hover {
  background: var(--e-global-color-8b7f6e7);
  color: var(--e-global-color-3bca2e6);
}

.cp-cart-drawer__footer {
  flex-shrink: 0;
  padding: 16px 20px 20px;
  border-top: 1px solid #eee;
}

.cp-cart-drawer__total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  margin-bottom: 14px;
}

.cp-cart-checkout-whatsapp {
  width: 100%;
  background: #25d366;
  color: #fff;
  border: none;
  padding: 13px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.cp-cart-checkout-whatsapp:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* زر/أيقونة السلة (سواء العائم أو ويدجت الهيدر) */
.cp-cart-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  background: transparent;
}

.cp-cart-trigger--floating {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background-color: var(--e-global-color-text, #000);
  color: var(--e-global-color-3bca2e6, #fff);
  font-size: 20px;
  z-index: 99990;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.25);
  transition: transform 0.2s ease;
}

.cp-cart-trigger--floating:hover {
  transform: translateY(-2px);
}

.cp-cart-count {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  background: #e63946;
  color: #fff;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

.cp-cart-count[data-empty="1"] {
  display: none;
}

.cp-cart-toast {
  position: fixed;
  bottom: 90px;
  right: 24px;
  background: #1f1f1f;
  color: #fff;
  padding: 11px 20px;
  border-radius: 6px;
  font-size: 14px;
  z-index: 99991;
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.25s ease,
    transform 0.25s ease;
  pointer-events: none;
  max-width: 80vw;
}

.cp-cart-toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 480px) {
  .cp-cart-trigger--floating {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .cp-cart-toast {
    right: 16px;
    bottom: 78px;
  }
}
