/* ======================
   Products Page Styles
   ====================== */
.products-header {
  text-align: center;
  margin-bottom: 40px;
}

/* Search Bar */
.search-bar input {
  width: 100%;
  padding: 14px 24px;
  border: 2px solid var(--border-color);
  border-radius: 50px;
  outline: none;
  font-family: var(--font-main);
  font-size: 1rem;
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease;
}
.search-bar input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(137, 59, 143, 0.12);
}

.products-layout {
  display: flex;
  gap: 30px;
  align-items: flex-start;
}

/* ===== Filters Sidebar ===== */
.filters-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
  position: sticky;
  top: 90px;
}

.filters-sidebar h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-color);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid rgba(137, 59, 143, 0.15);
}

/* Hidden radio buttons — we style labels as pills */
.filter-group {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.filter-group label {
  display: flex;
  align-items: center;
  gap: 0;
  cursor: pointer;
  padding: 0;
}

/* Hide raw radio */
.filter-group input[type='radio'] {
  display: none;
}

/* Pill chip style */
.filter-group label span.pill {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid var(--border-color);
  color: var(--text-color);
  background: #fff;
  cursor: pointer;
  transition: all 0.22s ease;
  width: 100%;
  text-align: center;
  user-select: none;
}

.filter-group input[type='radio']:checked + span.pill {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: #fff;
  box-shadow: 0 2px 10px rgba(137, 59, 143, 0.3);
}

.filter-group label:hover span.pill {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.filter-group input[type='radio']:checked + span.pill:hover {
  color: #fff;
}

/* Price sort pills */
.filter-group.price-pills {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-group.price-pills label span.pill {
  padding: 6px 14px;
  font-size: 0.82rem;
}

/* ===== Products Grid ===== */
.products-grid {
  flex-grow: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center; /* الكروت في النص */
  gap: 20px;
  width: 100%;
}

/* ===== Product Card ===== */
.product-card {
  border: 1px solid #eadde7;
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
  box-shadow: 0 7px 20px rgba(72, 35, 62, 0.08);

  /* ===== التعديلات ===== */
  width: 210px; /* عرض ثابت */
  flex-shrink: 0; /* ميقلصش أبداً */
  height: 415px;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 13px 30px rgba(72, 35, 62, 0.14);
}

.product-card .quick-view-trigger {
  overflow: hidden;
  border-radius: 16px 16px 0 0;
  background: #fff;
  border-bottom: 1px solid #eee3eb;
  flex-shrink: 0;
}

.product-card-image {
  position: relative;
  height: 220px;
  padding: 13px 13px 11px;
  background: #fff;
  box-shadow: none;
}

.product-card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: 9px;
  box-shadow: none;
}

.product-image-count {
  position: absolute;
  bottom: 18px;
  left: 18px;
  min-width: 28px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(72, 35, 62, 0.76);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}

/* ===== Card Body ===== */
.product-card-body {
  padding: 15px 16px 16px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  text-align: center;
  min-height: 0;
  background: #fafafa;
  border-top: 1px solid #eee;
  overflow: hidden;
  box-sizing: border-box;
  justify-content: space-between; /* يوزع المحتوى: الأسماء فوق، السعر والزر تحت */
}

/* ===== Product Names ===== */
.product-card-names {
  width: 100%;
  margin: 0 0 6px;
  overflow: hidden;
  flex-shrink: 1;
  min-height: 0;
}

.product-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
  cursor: pointer;
  line-height: 1.4;
  width: 100%;

  /* ========== التعديل المهم ========== */
  display: -webkit-box;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

.product-card-title:hover {
  color: var(--primary-color);
}

.product-card-title-ar {
  width: 100%;
  margin: 2px 0 0;
  color: var(--text-light);
  font-size: 0.88rem;
  line-height: 1.5;

  /* ========== التعديل المهم ========== */
  display: -webkit-box;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  word-break: break-word;
}

/* ===== Price & Button ===== */
.product-card-price {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 10px;
  flex-shrink: 0;
}

.product-card .add-to-cart-btn {
  width: 100%;
  border-radius: 50px;
  font-size: 0.95rem;
  padding: 10px;
  margin: 0;
  flex-shrink: 0;
}

/* ===== Pagination ===== */
.pagination {
  margin-top: 40px;
  text-align: center;
  width: 100%;
}

.page-link {
  display: inline-block;
  padding: 9px 18px;
  margin: 0 4px;
  border: 2px solid var(--border-color);
  border-radius: 50px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.page-link:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.page-link.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 2px 10px rgba(137, 59, 143, 0.3);
}

/* ===== Product card Swiper overrides ===== */
.product-card-swiper {
  width: 100%;
  height: 220px;
  background: #faf5f5;
  border-radius: 12px 12px 0 0;
  cursor: pointer;
}

.product-card-swiper .swiper-slide img {
  width: 100%;
  height: 220px;
  object-fit: contain;
  background: #faf5f5;
  transition: transform 0.35s ease;
}

.product-card:hover .product-card-swiper .swiper-slide-active img {
  transform: scale(1.04);
}

.product-card-swiper .swiper-button-next,
.product-card-swiper .swiper-button-prev {
  color: var(--primary-color);
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  opacity: 0;
  transition: opacity 0.3s;
}

.product-card-swiper .swiper-button-next::after,
.product-card-swiper .swiper-button-prev::after {
  font-size: 12px;
  font-weight: 900;
}

.product-card:hover .product-card-swiper .swiper-button-next,
.product-card:hover .product-card-swiper .swiper-button-prev {
  opacity: 1;
}

.product-card-swiper .swiper-pagination-bullet-active {
  background: var(--primary-color);
}

/* ===== Responsive ===== */
@media (hover: none) {
  .product-card-swiper .swiper-button-next,
  .product-card-swiper .swiper-button-prev {
    opacity: 1;
  }
}

@media (max-width: 768px) {
  .products-layout {
    flex-direction: column;
  }
  .filters-sidebar {
    width: 100%;
    position: static;
  }
  .filter-group {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .filter-group label span.pill {
    width: auto;
  }

  .products-grid {
    gap: 14px;
    justify-content: center;
  }

  .product-card {
    width: 200px; /* ثابت */
    flex-shrink: 0;
    height: 360px;
    border-radius: 13px;
  }

  .product-card .quick-view-trigger {
    border-radius: 13px 13px 0 0;
  }

  .product-card-image {
    height: 170px;
    padding: 10px;
  }

  .product-card-body {
    padding: 12px 10px 14px;
  }

  .product-card-title {
    font-size: 0.9rem;
    line-clamp: 2;
  }

  .product-card-title-ar {
    font-size: 0.8rem;
    line-clamp: 1;
  }

  .product-card-price {
    font-size: 1rem;
    margin-bottom: 8px;
  }

  .product-card .add-to-cart-btn {
    padding: 9px;
    font-size: 0.85rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* 3 كروت ثابتين في كل صف */
    gap: 16px;
  }

  .product-card {
    width: auto;
    flex-shrink: 0;
    height: 400px;
  }

  .product-card-image {
    height: 200px;
  }
}

/* موبايل عادي: كارتين */
@media (max-width: 480px) {
  .products-grid {
    gap: 12px;
    justify-content: center;
  }

  .product-card {
    width: calc(50% - 6px); /* كارتين ثابتين */
    flex-shrink: 0;
    height: 340px;
    border-radius: 12px;
  }

  .product-card .quick-view-trigger {
    border-radius: 12px 12px 0 0;
  }

  .product-card-image {
    height: 160px;
    padding: 8px;
  }

  .product-card-body {
    padding: 10px 9px 12px;
  }

  .product-card-title {
    font-size: 0.85rem;
    line-clamp: 2;
  }

  .product-card-title-ar {
    margin-top: 1px;
    font-size: 0.74rem;
    line-clamp: 1;
  }

  .product-card-price {
    margin-bottom: 7px;
    font-size: 0.95rem;
  }

  .product-card .add-to-cart-btn {
    padding: 8px 4px;
    font-size: 0.78rem;
  }

  .product-image-count {
    bottom: 13px;
    left: 13px;
    min-width: 24px;
    padding: 2px 6px;
    font-size: 0.72rem;
  }
}
