/* =========================================
   Variables & Base
   ========================================= */

/* تنظیمات پایه برای جلوگیری از ناترازی */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  overflow-x: hidden; /* جلوگیری از اسکرول افقی و ناترازی */
  width: 100%;
}

/* تنظیمات نگهدارنده اصلی برای ایجاد فاصله از لبه‌ها */
.shop-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 6%; /* ایجاد حاشیه امن ۶ درصدی از طرفین */
  direction: rtl;
}

/* فاصله‌گذاری بین بخش‌های مختلف فروشگاه */
.category-section {
  margin-bottom: 50px;
}

.category-title {
  margin-bottom: 30px;
  border-right: 5px solid var(--co1); /* خط تزئینی کنار عنوان */
  padding-right: 15px;
}

.category-title h2 {
  font-size: 1.6rem;
  line-height: 1.4;
  overflow-wrap: break-word; /* جلوگیری از بیرون‌زدگی متون بلند انگلیسی */
}

/* سیستم چیدمان کارتی حرفه‌ای */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 30px;
}

.product-card {
  background: #fff;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid #eee;
  transition: all 0.4s ease;
  position: relative;
  margin-bottom: 30px;
}

.product-card:hover {
  box-shadow: 0 15px 40px rgb(0 0 0 / 10%);
  transform: translateY(-8px);
}

/* نشان Accessory در بالای عکس */
.product-badge {
  position: absolute;
  top: 15px;
  right: 15px;
  padding: 5px 15px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: bold;
  z-index: 2;
  background-color: var(--co3);
  color: var(--co1); /* ترکیب مشکی و زرد */
}

.product-img {
  width: 100%;
  height: 220px;
  object-fit: cover;
  border-bottom: 1px solid #f5f5f5;
}

.quantity-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 15px 0;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 12px;
}

.qty-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.qty-controls button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid #ddd;
  background: #fff;
  cursor: pointer;
  font-weight: bold;
  transition: 0.2s;
}

.qty-controls button:hover {
  background-color: var(--co1);
  border-color: var(--co1);
}

.qty-controls input {
  width: 45px; /* کمی عریض‌تر برای اطمینان */
  height: 30px;
  text-align: center;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--co3);
  padding: 0;
  margin: 0;

  /* حذف فلش‌های بالا و پایین پیش‌فرض مرورگر */
  appearance: textfield;
}

/* برای مرورگرهای Chrome, Safari, Edge */
.qty-controls input::-webkit-outer-spin-button,
.qty-controls input::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}

.product-info {
  padding: 20px;
}

.product-price {
  display: block;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--co3);
  margin-bottom: 15px;
  text-align: left; /* برای نمایش بهتر تومانی */
}

.product-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* دکمه توضیحات */
.info-btn {
  background: #f0f0f0;
  border: 1px solid #ddd;
  color: #666;
  padding: 10px;
  border-radius: 12px;
  font-family: var(--font-body);
  cursor: pointer;
  transition: 0.3s;
}

.info-btn:hover {
  background: #e5e5e5;
  color: var(--co3);
}

/* دکمه افزودن به سبد خرید (تم زرد/مشکی) */
.shop-btn {
  width: 100%;
  background-color: var(--co1) !important;
  color: var(--co3) !important;
  border: none;
  font-weight: bold;
  padding: 12px !important;
  border-radius: 12px;
  transition: 0.3s;
}

.shop-btn:hover {
  background-color: var(--co3) !important;
  color: var(--co1) !important;
  transform: scale(1.02);
}

/* --- Floating Cart Stickiness --- */
.cart-floating {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--co3); /* رنگ تیره برند */
  padding: 12px 0;
  box-shadow: 0 -10px 30px rgb(0 0 0 / 30%);
  z-index: 2000; /* اطمینان از قرارگیری روی همه المان‌ها */
  transform: translateY(110%); /* کاملاً مخفی در حالت شروع */
  transition: transform 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  visibility: hidden; /* برای جلوگیری از کلیک تصادفی در حالت مخفی */
}

/* کلاس فعال‌ساز */
.cart-floating.active {
  transform: translateY(0);
  visibility: visible;
}

.cart-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-direction: row-reverse; /* برای چیدمان صحیح فارسی */
}

/* استایل دکمه حذف/ریست سبد */
.reset-cart-btn {
  background: transparent;
  border: 1px solid #555;
  color: #aaa;
  padding: 5px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  transition: 0.3s;
}

.reset-cart-btn:hover {
  border-color: #ff4d4d;
  color: #ff4d4d;
}

.cart-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

/* --- Pulse Button (ثبت سفارش) --- */
.pulse-button {
  background-color: #25d366 !important; /* سبز واتس‌اپ */
  color: #fff !important;
  border: none;
  padding: 12px 25px !important;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 50px;
  animation: whatsappPulse 2s infinite;
}

@keyframes whatsappPulse {
  0% {
    box-shadow: 0 0 0 0 rgb(37 211 102 / 70%);
  }

  70% {
    box-shadow: 0 0 0 15px rgb(37 211 102 / 0%);
  }

  100% {
    box-shadow: 0 0 0 0 rgb(37 211 102 / 0%);
  }
}

.whatsapp-icon {
  width: 24px;
  height: 24px;
  filter: brightness(0) invert(1);
}

/* --- Price Display --- */
.cart-total-info {
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.price-number {
  font-size: 1.8rem;
  color: var(--co1); /* طلایی/زرد برند */
}

/* --- Modal Product Gallery --- */
.product-gallery {
  margin: 20px 0;
  text-align: center;
}

.main-display-img {
  width: 100%;
  max-height: 350px;
  object-fit: contain;
  border-radius: 15px;
  background: #fdfdfd;
  transition: opacity 0.3s ease;
}

.thumb-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 15px;
}

.thumb-img {
  width: 70px;
  height: 70px;
  object-fit: cover;
  border-radius: 10px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: 0.3s;
}

.thumb-img:hover {
  transform: scale(1.1);
}

.thumb-img.active-thumb {
  border-color: var(--co1);
  box-shadow: 0 0 10px rgb(255 193 7 / 30%);
}

/* دکمه کپی لینک محصول */
.copy-link-btn {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: #f0f0f0;
  border: 1px dashed #ccc;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--font-body);
  transition: 0.3s;
}

.copy-link-btn:hover {
  background: #e0e0e0;
  border-color: var(--co3);
}

/* استایل مخصوص مودال اطلاعات محصول */
.modal-overlay {
  display: none; /* در حالت عادی مخفی */
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 80%);
  backdrop-filter: blur(5px);
  z-index: 2000;
  justify-content: center;
  align-items: center;
}

/* وقتی مودال باز می‌شود این کلاس به آن اضافه می‌شود */
.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #fff;
  width: 90%;
  max-width: 600px;
  padding: 30px;
  border-radius: 20px;
  position: relative;
  max-height: 90vh;
  overflow-y: auto;
}

.close-btn {
  position: absolute;
  top: 15px;
  left: 20px;
  font-size: 28px;
  cursor: pointer;
  color: #999;
}

@media (width <= 768px) {
  .shop-container {
    padding: 20px 5%; /* پدینگ متناسب با موبایل */
  }

  .category-title h2 {
    font-size: 1.3rem !important;
    overflow-wrap: break-word;
  }

  .product-grid {
    grid-template-columns: 1fr; /* در موبایل کارت‌ها تمام عرض شوند */
    gap: 20px;
  }

  .cart-wrapper {
    flex-direction: column-reverse;
    gap: 15px;
  }

  .price-number {
    font-size: 1.4rem;
  }

  .pulse-button {
    width: 100%;
    justify-content: center;
  }

  .main-display-img {
    max-height: 250px;
  }
}

@media (width <= 600px) {
  .category-title h2 {
    font-size: 1.4rem !important; /* جلوگیری از بزرگ شدن بیش از حد متن */
    word-break: break-word;
  }

  .product-card {
    margin: 10px 5% !important; /* تراز کردن کارت با هدر */
  }
}
