/**
 * Mini Cart CSS for Mostafavi Theme
 * 
 * استایل‌های مربوط به مینی سبد خرید
 */

/* بخش کلی مینی سبد */
.mini-cart-container {
  position: relative;
  display: inline-block;
}

/* آیکون سبد خرید */
.mini-cart-icon-container {
  position: relative;
  display: inline-block;
  cursor: pointer;
}

.mini-cart-icon {
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

.mini-cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  background-color: #c91016;
  color: white;
  border-radius: 50%;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 4px;
  box-sizing: border-box;
}

/* استایل پاپ آپ مینی سبد */
.mini-cart-popup {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  width: 350px;
  background-color: white;
  border-radius: 10px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
  z-index: 9999;
  display: none;
  margin-top: 10px;
  animation: fadeInCart 0.3s ease;
  max-height: 80vh;
  overflow: hidden;
  direction: rtl;
}

/* بهبود رسپانسیو برای موبایل */
@media (max-width: 1650px) {
  .mini-cart-popup {
    position: fixed;
    width: 90vw;
    max-width: 350px;
    max-height: 85vh;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin-top: 0;
    z-index: 99999;
  }

  .mini-cart-content {
    max-height: 50vh;
  }

  .mini-cart-item {
    flex-wrap: wrap;
    padding: 10px 0;
  }

  .mini-cart-item-image {
    width: 50px;
    height: 50px;
  }

  .mini-cart-item-details {
    width: calc(100% - 110px);
  }

  .mini-cart-item-subtotal {
    margin-right: 0;
    margin-top: 5px;
    width: 100%;
    text-align: start;
  }

  .mini-cart-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .mini-cart-button {
    width: 100%;
  }
}

/* فلش بالای پاپ آپ */
.mini-cart-popup:before {
  content: "";
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 10px solid white;
}

@media (max-width: 1650px) {
  .mini-cart-popup:before {
    display: none;
  }
}

/* هدر مینی سبد */
.mini-cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
}

.mini-cart-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

.mini-cart-close {
  font-size: 22px;
  font-weight: 300;
  color: #999;
  text-decoration: none;
  cursor: pointer;
  line-height: 1;
}

.mini-cart-close:hover {
  color: #c91016;
}

/* محتوای اصلی مینی سبد */
.mini-cart-content {
  padding: 12px 16px;
  max-height: 350px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ddd ;
}

.mini-cart-content::-webkit-scrollbar {
  width: 6px;
}

.mini-cart-content::-webkit-scrollbar-track {
  background: #f5f5f5;
}

.mini-cart-content::-webkit-scrollbar-thumb {
  background-color: #ddd;
  border-radius: 6px;
}

/* لیست آیتم‌های سبد */
.mini-cart-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mini-cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #eee;
  position: relative;
}

.mini-cart-item:last-child {
  border-bottom: none;
}

/* تصویر محصول */
.mini-cart-item-image {
  width: 60px;
  height: 60px;
  overflow: hidden;
  border-radius: 6px;
  flex-shrink: 0;
}

.mini-cart-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* اطلاعات محصول */
.mini-cart-item-details {
  flex-grow: 1;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.mini-cart-item-name {
  margin-bottom: 5px;
  font-size: 14px;
  font-weight: 500;
}

.mini-cart-item-name a {
  color: #333;
  text-decoration: none;
}

.mini-cart-item-name a:hover {
  color: #c91016;
}

.mini-cart-item-price {
  font-size: 12px;
  color: #666;
  margin-bottom: 5px;
}

/* کنترل تعداد محصول */
.mini-cart-item-quantity {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mini-cart-decrease-qty,
.mini-cart-increase-qty {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid #ddd;
  background-color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.mini-cart-increase-qty:hover,
.mini-cart-decrease-qty:hover {
  background-color: #f5f5f5;
  border-color: #ccc;
}

/* استایل لودینگ برای دکمه کاهش */
.mini-cart-decrease-qty.loading {
  color: transparent;
  pointer-events: none;
}

.mini-cart-decrease-qty.loading:after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid #ddd;
  border-top-color: #c91016;
  animation: spin 0.8s linear infinite;
}

/* استایل لودینگ برای دکمه افزایش */
.mini-cart-increase-qty.loading {
  color: transparent;
  pointer-events: none;
}

.mini-cart-increase-qty.loading:after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid #ddd;
  border-top-color: #c91016;
  animation: spin 0.8s linear infinite;
}

.mini-cart-item-qty {
  font-size: 14px;
  font-weight: 500;
  min-width: 20px;
  text-align: center;
}

/* جمع کل محصول */
.mini-cart-item-subtotal {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  margin-right: 10px;
  white-space: nowrap;
}

/* دکمه حذف محصول */
.mini-cart-item-remove {
  margin-right: 5px;
  position: relative;
}

.mini-cart-remove-item {
  color: #999;
  font-size: 18px;
  text-decoration: none;
  transition: color 0.2s ease;
  display: block;
  width: 24px;
  height: 24px;
  text-align: center;
  line-height: 24px;
  position: relative;
}

.mini-cart-remove-item:hover {
  color: #c91016;
}

/* استایل لودینگ برای دکمه حذف */
.mini-cart-remove-item.loading {
  color: transparent;
  pointer-events: none;
}

.mini-cart-remove-item.loading:after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid #ddd;
  border-top-color: #c91016;
  animation: spin 0.8s linear infinite;
}

/* استایل برای آیتم در حال حذف */
.mini-cart-item.removing {
  opacity: 0.5;
  pointer-events: none;
}

/* سبد خالی */
.mini-cart-empty {
  padding: 30px 0;
  text-align: center;
  color: #666;
}

.mini-cart-empty p {
  margin: 0;
  font-size: 14px;
}

/* فوتر مینی سبد */
.mini-cart-footer {
  padding: 12px 16px;
  border-top: 1px solid #eee;
  background-color: #f9f9f9;
  border-radius: 0 0 10px 10px;
}

.mini-cart-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.mini-cart-total-label {
  font-size: 14px;
  color: #666;
}

.mini-cart-total-amount {
  font-size: 16px;
  font-weight: 600;
  color: #333;
}

/* دکمه‌های فوتر */
.mini-cart-buttons {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.mini-cart-button {
  padding: 8px 15px;
  border-radius: 5px;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
  transition: all 0.2s ease;
}

.view-cart-button {
  background-color: #f5f5f5;
  color: #333;
}

.view-cart-button:hover {
  background-color: #e0e0e0;
}

.checkout-button {
  background-color: #c91016;
  color: white;
}

.checkout-button:hover {
  background-color: #a7090e;
}

/* لودر */
.mini-cart-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  background-color: rgba(255, 255, 255, 0.8);
  align-items: center;
  z-index: 10;
  display: none;
}

.loader-spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #c91016;
  position: absolute;
  top: 50%;
  left: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

/* پیام‌های سیستم */
.mini-cart-message {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  display: none;
  max-width: 300px;
  line-height: 1.4;
  text-align: right;
  direction: rtl;
}

.mini-cart-message.success {
  background-color: #dff2e8;
  color: #1c9b47;
  border-right: 3px solid #1c9b47;
}

.mini-cart-message.error {
  background-color: #fae0e0;
  color: #c91016;
  border-right: 3px solid #c91016;
}

/* انیمیشن‌ها */
@keyframes fadeInCart {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* استایل‌های مربوط به دکمه افزودن به سبد در صفحه محصول */
.single_add_to_cart_button.loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.single_add_to_cart_button.loading:after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  margin-right: -8px;
  border-radius: 50%;
  border: 2px solid #fff;
  border-top-color: transparent;
  animation: spin 1s linear infinite;
}
