* {
  text-decoration: none !important;
}

html.loading,
body.loading {
  overflow: hidden !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  position: fixed !important;
  width: 100% !important;
}

.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #ffffff;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s, visibility 0.5s;
  overflow: hidden;
}

.loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.loader-circle {
  width: 60px;
  height: 60px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid #520721;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loader-logo {
  width: 80px;
  height: auto;
  animation: pulse 1.5s ease-in-out infinite;
}

.loader-text {
  color: #520721;
  font-size: 1.1rem;
  font-weight: 500;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
  }
}

.page-loader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.categories-container {
  max-width: 1400px;
  margin: 1rem auto;
  padding: 0 1rem;
}

.main-categories-wrapper {
  margin-bottom: 1.5rem;
}

.main-categories-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.5rem;
}

.main-category-box {
  background: linear-gradient(145deg, #ffffff, #f5f5f5);
  border-radius: 30px;
  padding: 1.2rem 1.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
  min-width: 180px;
  max-width: 250px;
  border: 1px solid #eee;
}

.category-content {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.category-icon {
  font-size: 1.2rem;
  color: #520721;
  transition: transform 0.3s ease;
}

.main-category-box:hover {
  transform: translateY(-2px);
  box-shadow: 7px 7px 20px #d1d1d1, -7px -7px 20px #ffffff;
}

.main-category-box:hover .category-icon {
  transform: rotate(-15deg);
}

.main-category-box.active {
  background: linear-gradient(145deg, #520721, #3d0519);
}

.main-category-box.active h3,
.main-category-box.active .category-icon {
  color: white;
}

.main-category-box h3 {
  margin: 0;
  color: #2c3e50;
  font-size: 1.1rem;
  font-weight: 600;
}

.sub-categories-wrapper {
  background-color: rgba(0, 0, 0, 0.02);

  border-radius: 20px;
  padding: 1.2rem;
  min-height: 100px;
}

.sub-categories-content {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 0.5rem;
  gap: 1rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.sub-categories-content::-webkit-scrollbar {
  display: none;
}

.sub-category-item {
  display: inline-flex;
  align-items: center;
  padding: 0.8rem 1.2rem;
  background: white;
  border-radius: 40px;
  color: #34495e;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  box-shadow: 3px 3px 7px #d1d1d1, -3px -3px 7px #ffffff;
  border: 1px solid #eee;
}

.sub-category-item:hover {
  background: #520721;
  color: white;
  transform: translateY(-2px);
}

.default-message {
  text-align: center;
  color: #520721;
  padding: 2rem;
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  border-radius: 12px;
  border: 1px dashed #520721;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0.5rem;
}

.default-message::before {
  content: "\f06a";
  font-family: "Font Awesome 5 Free";
  font-weight: 900;
  font-size: 1.2rem;
  color: #520721;
  opacity: 0.8;
}

.section-divider {
  margin: 2rem auto;
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, #520721, transparent);
  opacity: 0.2;
  max-width: 1400px;
}

.products-section {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 6px;
  padding: 1rem 0;
}

.product-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  border: 1px solid #ddd;
}

.product-image {
  position: relative;
  width: 100%;
  height: 0;
  padding-bottom: 100%; /* نسبة 1:1 */
  background: #f8f9fa;
  overflow: hidden;
}
.loading-spinner {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  z-index: 1;
}

.loading-spinner i {
  color: #520721;
  font-size: 1.5rem;
  animation: spin 1s infinite linear;
}

.product-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0; /* تبدأ الصورة مخفية */
  transition: opacity 0.3s ease;
}

.product-info {
  position: relative;
  background: white;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  padding: 1rem;
  min-height: 90px;
}

.category-label {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  padding: 0.3rem 0.8rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  backdrop-filter: blur(4px);
  z-index: 3;
  /* تعديل هنا */
}

.info-divider {
  margin: 0;
  border: none;
  height: 1px;
  background: linear-gradient(to right, transparent, #ddd, transparent);
  opacity: 0.7;
}

.product-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 90px;
}

.product-name {
  margin: 0;
  font-size: 1rem;
  color: #2c3e50;
  font-weight: 700;
  line-height: 1.4;
  height: 2.8em;
  max-width: 100%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  box-orient: vertical;
  text-align: start;
  unicode-bidi: plaintext;
  direction: unset;
  padding: 0 2px;
}

/* تعديل حجم الخط للشاشات الصغيرة */
@media (max-width: 480px) {
  .product-name {
    font-size: 0.9rem;
    height: 2.5em;
    -webkit-line-clamp: 2;
    line-clamp: 2;
  }
}

.sale-type {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  min-height: 30px;
}

.type-badge {
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 500;
}

.type-badge.full {
  background: #520721;
  color: white;
}

.type-badge.divisions {
  background: #f8f9fa;
  color: #520721;
  border: 1px solid #520721;
}

@media (max-width: 768px) {
  .categories-container {
    margin: 0.5rem auto;
  }

  .main-categories-grid {
    gap: 0.8rem;
    padding: 0.5rem;
  }

  .main-category-box {
    min-width: calc(50% - 0.8rem);
    padding: 1rem 1.2rem;
  }

  .category-content {
    gap: 0.5rem;
  }

  .main-category-box h3 {
    font-size: 1rem;
  }

  .sub-category-item {
    padding: 0.6rem 1rem;
    font-size: 0.9rem;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .main-categories-grid {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 0.5rem;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .main-category-box {
    min-width: 140px;
    max-width: none;
    flex: 0 0 auto;
    padding: 0.8rem 1rem;
  }

  .category-content {
    gap: 0.4rem;
  }

  .category-icon {
    font-size: 1rem;
  }

  .main-category-box h3 {
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
  }

  .product-image {
    padding-bottom: 100%;
  }

  .product-info {
    position: relative;
    /* لضمان عدم التداخل مع الصورة */
    background: white;
    z-index: 1;
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .product-info {
    padding: 0.8rem;
    gap: 0.6rem;
    min-height: 90px;
  }

  .product-name {
    font-size: 0.9rem;
    height: 44px;
  }

  .category-label {
    padding: 0.2rem 0.6rem;
    font-size: 9px;
  }

  .type-badge {
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
  }

  /* عند وجود قسمين فقط */
  .main-categories-grid:has(.main-category-box:nth-child(2):last-child) {
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: hidden;
  }

  .main-categories-grid:has(.main-category-box:nth-child(2):last-child)
    .main-category-box {
    flex: 0 0 calc(50% - 0.5rem);
    min-width: 0;
  }

  .main-categories-grid:has(.main-category-box:nth-child(2):last-child)
    .main-category-box
    h3 {
    font-size: 0.9rem;
    max-width: none;
  }
}

/* تعديل للأقسام الفرعية عندما لا يوجد أقسام رئيسية */
.categories-container:not(:has(.main-categories-wrapper))
  .sub-categories-wrapper {
  margin-top: 0;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background-color: #f8f9fa;
  /* لون خلفية للصور غير الموجودة */
}

.no-products-message {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem;
  background: linear-gradient(145deg, #ffffff, #f8f9fa);
  border-radius: 15px;
  color: #520721;
  font-size: 1.1rem;
  border: 2px dashed #52072150;
}

.no-products-message i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  opacity: 0.7;
}

.product-unavailable {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 4;
  color: #520721;
}

.product-unavailable i {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  opacity: 0.7;
}

.product-unavailable span {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  padding: 0.5rem;
}

.product-card.unavailable {
  opacity: 0.9;
}

.product-card.unavailable img {
  filter: grayscale(1);
}

.search-container {
  margin: 1.5rem 0;
}

.search-box {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-box input {
  width: 100%;
  padding: 1rem 3rem 1rem 1rem;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  font-size: 1rem;
  transition: all 0.3s ease;
  direction: rtl;
}

.search-box input:focus {
  outline: none;
  border-color: #520721;
  box-shadow: 0 4px 12px rgba(82, 7, 33, 0.1);
}

.search-box input::placeholder {
  color: #999;
}

.search-icon {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #520721;
  font-size: 1.2rem;
  opacity: 0.7;
}

.clear-search {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  z-index: 2;
}

.clear-search:hover {
  opacity: 1;
  color: #520721;
}

.search-suggestions {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(82, 7, 33, 0.07);
  border: 1px solid #eee;
  margin-top: 8px;
  z-index: 10;
  display: none;
  max-height: none;
  overflow-y: visible;
}

.search-suggestions.scrollable {
  max-height: 320px;
  /* تقريباً 4 عناصر */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #520721 #f8f9fa;
}

.search-suggestions.scrollable::-webkit-scrollbar {
  width: 7px;
  background: #f8f9fa;
}

.search-suggestions.scrollable::-webkit-scrollbar-thumb {
  background: #520721;
  border-radius: 8px;
}

.search-suggestion-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
  color: #2c3e50;
  font-size: 1rem;
  transition: background 0.2s;
  background: #fff;
}

.search-suggestion-img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #f8f9fa;
  border: 1px solid #eee;
  flex-shrink: 0;
}

.search-suggestion-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.search-suggestion-name {
  font-size: 1rem;
  font-weight: 500;
  color: #2c3e50;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}

.search-suggestion-sale {
  display: flex;
  gap: 0.4rem;
  margin-top: 2px;
}

.search-suggestion-type {
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  background: #f8f9fa;
  color: #520721;
  border: 1px solid #eee;
}

.search-suggestion-type.full {
  background: #520721;
  color: #fff;
  border: none;
}

@media (max-width: 768px) {
  .search-box input {
    padding: 0.8rem 2.5rem 0.8rem 0.8rem;
    font-size: 0.9rem;
  }

  .search-icon {
    font-size: 1rem;
  }
}

.search-suggestion-empty {
  padding: 1.5rem 1rem;
  color: #a94442;
  text-align: center;
  font-size: 1.05rem;
  background: linear-gradient(135deg, #fff, #f8d7da 60%);
  border-radius: 12px;
  border: 1px dashed #a94442;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.search-suggestion-empty i {
  font-size: 2rem;
  color: #a94442;
  opacity: 0.7;
  margin-bottom: 0.2rem;
}

/* تنسيق مؤشر التحميل */
.load-more-container {
  text-align: center;
  padding: 2rem 0;
  margin-top: 2rem;
}

.load-more-spinner {
  margin-bottom: 1rem;
}

.spinner-ring {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid #52072120;
  border-top: 4px solid #520721;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  display: block;
  color: #520721;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  font-weight: 500;
}

.load-more-info {
  display: inline-block;
  background: #52072108;
  color: #520721;
  padding: 0.5rem 1.5rem;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }

  100% {
    transform: rotate(360deg);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* عندما تكون الصورة محملة */
.product-image.loaded img {
  opacity: 1;
}

.product-image.loaded .loading-spinner {
  display: none;
}
