:root {
  --primary-color: #caaa3f;
  --secondary-color: #48133f;
}

[data-theme="dark"] {
  --bg-color: #1a1a1a;
  --text-color: #ffffff;
  --header-bg: #2d2d2d;
  --primary-color: #caaa3f;
  --border-color: #3d3d3d;
  --alert-bg: #2d2d2d;
  --alert-border: #3d3d3d;
  --alert-text: #caaa3f;
  --discount-price-color: #888888;
}

[data-theme="light"] {
  --bg-color: #ffffff;
  --text-color: #333333;
  --header-bg: #ffffff;
  --primary-color: #48133f;
  --border-color: #eaeaea;
  --alert-bg: #fff8e6;
  --alert-border: #caaa3f;
  --alert-text: #48133f;
  --discount-price-color: #6c757d;
}

* {
  font-family: "Tajawal", sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: all 0.3s ease;
}

.categories-wrapper {
  padding: 30px 0;
  overflow-x: hidden;
}

.section-title {
  color: var(--primary-color);
  font-size: 2rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 40px;
}

.categories-grid {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 10px 5px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.categories-grid::-webkit-scrollbar {
  display: none;
}

.category-card {
  flex: 0 0 200px;
  background: var(--header-bg);
  border-radius: 12px;
  padding: 20px 15px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  text-decoration: none;
  border: 1px solid var(--border-color);
}

.category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  border-color: var(--primary-color);
}

.category-icon {
  font-size: 2rem;
  color: var(--primary-color);
  margin-bottom: 12px;
}

.category-name {
  color: var(--primary-color);
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.category-type {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 15px;
  font-size: 0.8rem;
  margin-top: 8px;
  color: white;
}

.category-type.wholesale {
  background-color: #e74c3c;
}

.category-type.retail {
  background-color: #2ecc71;
}

.search-wrapper {
  margin-top: 20px;
  padding: 20px 0;
}

.search-container {
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 15px 60px;
  border-radius: 30px;
  border: 2px solid var(--border-color);
  background: var(--header-bg);
  color: var(--text-color);
  font-size: 1.1rem;
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 5px rgba(202, 170, 63, 0.1);
}

.search-input::placeholder {
  color: #999;
}

.search-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--primary-color);
  font-size: 1.3rem;
  pointer-events: none;
}

.clear-search {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0;
  transition: all 0.3s ease;
}

.clear-search:hover {
  color: var(--primary-color);
}

.clear-search.visible {
  opacity: 1;
}

.subcategories-wrapper {
  display: none;
  padding: 15px 0;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.02);
}

.subcategories-grid {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 5px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.subcategories-grid::-webkit-scrollbar {
  display: none;
}

.subcategory-card {
  flex: 0 0 auto;
  padding: 8px 15px;
  color: var(--text-color);
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 20px;
  background: var(--header-bg);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
  white-space: nowrap;
}

.subcategory-card:hover {
  color: var(--primary-color);
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
  padding: 20px 0;
}

.product-card {
  position: relative;
  background: var(--header-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.product-image {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #f8f9fa;
  padding: 0;
}

.product-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 0.8rem;
  backdrop-filter: blur(5px);
  z-index: 1;
}

.product-info {
  padding: 15px;
  flex-grow: 0;
}

.product-name {
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  direction: ltr;
  text-align: center;
  unicode-bidi: plaintext;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--text-color);
}

.product-price {
  color: var(--primary-color);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
}

.product-price .old-price {
  color: var(--discount-price-color);
  text-decoration: line-through;
  margin-inline-end: 0.5rem;
  margin-right: 4px;
}

.alert-custom {
  background-color: var(--alert-bg);
  border-color: var(--alert-border);
  color: var(--alert-text);
}

.alert-custom i {
  color: var(--primary-color);
}

.cart-icon-wrapper {
  position: relative;
  padding: 10px;
  cursor: pointer;
  background: var(--bg-color);
  border-radius: 12px;
  border: 1.5px solid var(--border-color);
  transition: all 0.3s ease;
}

.cart-icon-wrapper:hover {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.cart-icon {
  font-size: 22px;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 5px;
}

.cart-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--primary-color);
  color: #fff;
  border-radius: 50%;
  min-width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  padding: 0 6px;
  border: 2px solid var(--bg-color);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-unavailable-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  backdrop-filter: blur(2px);
}

.product-unavailable-text {
  background: var(--primary-color);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 600;
  transform: rotate(-5deg);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.suggestions-container {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  left: 0;
  background: var(--header-bg);
  border: 1px solid var(--border-color);
  border-radius: 15px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  display: none;
  max-height: 400px;
  overflow-y: auto;
  padding: 12px;
}

.suggestion-item {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 15px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.01);
  border: 1px solid var(--border-color);
}

.suggestion-item:last-child {
  margin-bottom: 0;
}

.suggestion-item:hover {
  background: rgba(0, 0, 0, 0.03);
  transform: translateX(-3px);
}

.suggestion-image {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border-color);
  padding: 3px;
  background: white;
}

.suggestion-details {
  flex: 1;
}

.suggestion-name {
  color: var(--text-color);
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 5px;
  direction: ltr;
  text-align: right;
}

.suggestion-price {
  color: var(--primary-color);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 5px;
}

.suggestion-price .old-price {
  color: var(--discount-price-color);
  text-decoration: line-through;
  font-size: 0.85rem;
  opacity: 0.8;
}

.suggestion-price .new-price {
  color: #e74c3c;
  font-weight: 700;
}

/* تحسين سكرول المقترحات */
.suggestions-container::-webkit-scrollbar {
  width: 5px;
}

.suggestions-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
}

.suggestions-container::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

/* تنسيق رسالة عدم وجود نتائج */
.no-results-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
  text-align: center;
}

.no-results-item i {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 15px;
  opacity: 0.8;
}

.no-results-item .message {
  color: var(--text-color);
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 5px;
}

.no-results-item .sub-message {
  color: var(--discount-price-color);
  font-size: 0.9rem;
}

/* إضافة ستايلات شاشة التحميل */
.loader-wrapper {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-color);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  transition: opacity 0.5s ease-out;
}

.loader-wrapper.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loader-text {
  color: var(--primary-color);
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 20px;
}

.loader-bar {
  width: 200px;
  height: 4px;
  background: rgba(202, 170, 63, 0.2);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.loader-bar::after {
  content: "";
  position: absolute;
  width: 40%;
  height: 100%;
  background: var(--primary-color);
  border-radius: 4px;
  left: -40%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    left: -40%;
  }

  50% {
    left: 100%;
  }

  100% {
    left: -40%;
  }
}

/* إضافة ستايل لمنع السكرول */
body.no-scroll {
  overflow: hidden;
}

/* تنسيق السكرول للصفحة بالكامل */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-color);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
  border: 2px solid var(--bg-color);
}

@media (max-width: 768px) {
  .offers-slider {
    margin: 10px 0 20px;
  }

  .suggestions-container {
    max-height: 300px;
  }

  .suggestion-image {
    width: 50px;
    height: 50px;
  }

  .suggestion-name {
    font-size: 0.9rem;
  }

  .suggestion-price {
    font-size: 0.85rem;
  }

  /* تنسيق السكرول في الموبايل */
  ::-webkit-scrollbar {
    width: 5px;
    height: 5px;
  }
}

@media (max-width: 470px) {
  .product-info {
    padding: 6px;
  }

  .cart-icon {
    font-size: 20px;
  }

  .cart-count {
    min-width: 18px;
    height: 18px;
    font-size: 11px;
  }

  .categories-grid {
    justify-content: flex-start;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  }

  .product-price {
    font-size: 11px;
  }

  .product-badge {
    font-size: 10px;
    padding: 3px 10px;
  }

  .search-input {
    padding: 8px 50px;
    font-size: 15px;
  }

  .search-icon {
    font-size: 15px;
  }
}

@media (max-width: 370px) {
  .product-price {
    font-size: 10px;
  }
}

.stores-section {
  background: var(--bg-color);
  padding: 20px 0;
  overflow: hidden;
}

.stores-wrapper {
  position: relative;
  padding: 10px 5px;
  margin: 0 -5px;
}

.stores-grid {
  display: flex;
  gap: 15px;
  overflow-x: auto;
  padding: 10px 5px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  margin: 0 auto;
  position: relative;
}

/* تحسين مظهر شريط التمرير */
.stores-grid::-webkit-scrollbar {
  height: 6px;
  background: transparent;
}

.stores-grid::-webkit-scrollbar-track {
  background: rgba(202, 170, 63, 0.1);
  border-radius: 10px;
  margin: 0 50px;
}

.stores-grid::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
  border: 2px solid var(--bg-color);
  transition: all 0.3s ease;
}

.stores-grid::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

/* تعديل ظهور السكرول في فايرفوكس */
@supports (scrollbar-color: auto) {
  .stores-grid {
    scrollbar-color: var(--primary-color) rgba(202, 170, 63, 0.1);
    scrollbar-width: thin;
  }
}

/* تحسين السكرول للشاشات الصغيرة */
@media (max-width: 480px) {
  .stores-grid::-webkit-scrollbar {
    height: 4px;
  }

  .stores-grid::-webkit-scrollbar-track {
    margin: 0 20px;
  }
}

.store-card {
  flex: 0 0 300px;
  background: var(--header-bg);
  border-radius: 15px;
  padding: 25px 20px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.store-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.store-icon {
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 15px;
  text-align: center;
}

.store-name {
  color: var(--text-color);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 15px;
}

.store-details {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.store-address,
.store-phone {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-color);
  font-size: 0.9rem;
  margin: 0;
  text-decoration: none;
}

.store-phone:hover {
  color: var(--primary-color);
}

.store-details i {
  color: var(--primary-color);
  font-size: 1rem;
}

@media (max-width: 1200px) {
  .store-card {
    flex: 0 0 280px;
    padding: 20px 15px;
  }
}

@media (max-width: 991px) {
  .store-card {
    flex: 0 0 260px;
  }

  .store-name {
    font-size: 1.1rem;
  }

  .store-icon {
    font-size: 2.2rem;
  }
}

@media (max-width: 768px) {
  .stores-section {
    padding: 15px 0;
  }

  .store-card {
    flex: 0 0 240px;
    padding: 15px 12px;
  }

  .store-icon {
    font-size: 2rem;
    margin-bottom: 12px;
  }

  .store-name {
    font-size: 1rem;
    margin-bottom: 12px;
  }

  .store-details {
    gap: 8px;
  }

  .store-address,
  .store-phone {
    font-size: 0.85rem;
  }

  .store-details i {
    font-size: 0.9rem;
  }

  .section-title {
    font-size: 1.5rem;
    margin-bottom: 20px;
  }
}

@media (max-width: 480px) {
  .store-card {
    flex: 0 0 200px;
    padding: 12px 10px;
  }

  .store-icon {
    font-size: 1.8rem;
    margin-bottom: 10px;
  }

  .store-name {
    font-size: 0.9rem;
    margin-bottom: 10px;
  }

  .store-details {
    gap: 6px;
  }

  .store-address,
  .store-phone {
    font-size: 0.8rem;
  }

  .stores-grid::-webkit-scrollbar {
    height: 4px;
  }
}

@media (max-width: 360px) {
  .store-card {
    flex: 0 0 180px;
  }
}
