:root {
  --primary: #710000;
  --gold: #f0c28b;
  --white: #fff;
  --black: #222;
  --gray: #f7f7f7;
  --dark: #270001;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
}

body {
  font-family: "Cairo", "Segoe UI", Arial, sans-serif;
  direction: rtl;
  background: var(--gray);
  color: var(--black);
  margin: 0;
  padding: 0 3px;
  box-sizing: border-box;
}

/* الهيدر */
.main-header {
  background: var(--white);
  box-shadow: var(--shadow);
  padding: 10px 0;
  position: sticky;
  top: 0;
  z-index: 1000;
  width: 100%;
  border-bottom: 2px solid var(--gold);
  animation: slideDown 0.8s;
}
@keyframes slideDown {
  from {transform: translateY(-40px); opacity: 0;}
  to {transform: translateY(0); opacity: 1;}
}
.main-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  direction: rtl;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px;
}
.header-links {
  display: flex;
  gap: 12px;
  order: 1;
}
.header-links a {
  font-family: "Cairo", "Segoe UI", Arial, sans-serif;
  font-weight: bold;
  font-size: 17px;
  color: #710000;
  text-decoration: none;
  padding: 7px 14px;
  border-radius: 7px;
  transition: background 0.2s, color 0.2s;
}
.header-links a:hover {
  background: #71000010;
  color: #a90000;
}
.logo-area {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  order: 2;
}
.logo {
  height: 48px;
  width: auto;
  margin-left: 0;
  transition: transform 0.2s;
}
.logo:hover {
  transform: scale(1.07) rotate(-4deg);
}
.site-title {
  font-family: "Cairo", "Segoe UI", Arial, sans-serif;
  font-size: 21px;
  font-weight: bold;
  color: #710000;
  letter-spacing: 1px;
  white-space: nowrap;
  margin: 0 0 0 10px;
  position: relative;
  top: 5px;
  left: 10px;
}

@media (max-width: 600px) {
  .main-header .container {
    flex-direction: column;
    gap: 9px;
  }
  .logo-area {
    order: 1;
    justify-content: center;
    width: 100%;
    margin-bottom: 5px;
  }
  .site-title {
    font-size: 16px;
    top: -2px;
    left: 0;
  }
  .logo {
    height: 38px;
  }
  .header-links {
    order: 2;
    justify-content: center;
    width: 100%;
  }
}

/* المنتجات */
.products-grid {
  width: 100%;
  max-width: 1250px;
  margin: 40px auto 40px auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 32px;
}
@media (max-width: 900px) {
  .products-grid {
    grid-template-columns: repeat(2, 1fr);
    max-width: 99vw;
    gap: 18px;
    margin: 18px auto;
  }
}
@media (max-width: 600px) {
  .products-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 12px auto;
    max-width: 99vw;
  }
}

/* كل منتج */
.pr1, .pr2 {
  background: var(--white);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1.5px solid var(--gold);
  padding: 10px 5px 10px 5px;
  min-height: 450px;
  max-width: 100%;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s, box-shadow 0.3s;
  animation: productFadeIn 0.7s;
  cursor: pointer;
  box-sizing: border-box;
}
@keyframes productFadeIn {
  from {opacity: 0; transform: scale(0.85);}
  to {opacity: 1; transform: scale(1);}
}
.pr1:hover, .pr2:hover {
  box-shadow: 0 6px 28px rgba(0,0,0,0.13);
  transform: scale(1.04) rotate(-2deg);
  border-color: var(--primary);
}

/* صورة المنتج */
.ph1, .ph2 {
  width: 96%;
  max-width: 255px;
  height: 330px;
  object-fit: cover;
  border-radius: 13px;
  margin: 6px auto 6px auto;
  box-shadow: 0 2px 10px rgba(0,0,0,0.07);
  background: var(--gray);
  display: block;
  transition: box-shadow 0.2s, transform 0.2s;
}
.ph1:hover, .ph2:hover {
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  transform: scale(1.04);
}

/* نصوص المنتج */
.desc {
  font-size: 13.5px;
  color: #444;
  margin-bottom: 7px;
  margin-top: 4px;
  text-align: center;
  line-height: 1.7;
  font-family: inherit;
  font-weight: 500;
}
.n1, .n2 {
  font-size: 17px;
  font-weight: bold;
  margin: 2px 0 0px;
  color: var(--primary);
  letter-spacing: 1px;
  text-align: center;
}
.m1, .m2 {
  font-size: 15px;
  color: var(--gold);
  margin: 2px 0 5px;
  font-weight: 600;
  text-align: center;
}

/* زر view */
.view-btn {
  margin-top: 8px;
  padding: 7px 0;
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 18px;
  font-weight: bold;
  width: 100%;
  max-width: 180px;
  box-shadow: var(--shadow);
  transition: background 0.3s, color 0.3s, transform 0.2s;
  display: block;
}
.view-btn:hover {
  background: var(--gold);
  color: var(--primary);
  transform: scale(1.05);
}

/* استجابة للهواتف */
@media (max-width: 900px) {
  .pr1, .pr2 {
    min-height: 370px;
    padding: 7px 2px 7px 2px;
  }
  .ph1, .ph2 {
    width: 98%;
    max-width: 170px;
    height: 170px;
  }
}
@media (max-width: 600px) {
  .pr1, .pr2 {
    min-height: 430px;
    padding: 7px 1px 7px 1px;
  }
  .ph1, .ph2 {
    width: 97%;
    max-width: 100vw;
    height: 310px;
    margin: 4px auto 4px auto;
  }
  .desc {
    font-size: 12px;
    margin-bottom: 4px;
  }
  .main-header .container {
    padding: 0 6px;
  }
}

/* السلة العائمة */
.floating-cart {
  position: fixed;
  bottom: 48px;
  right: 20px;
  background: var(--primary);
  color: var(--gold);
  font-size: 22px;
  padding: 14px 15px;
  border-radius: 50%;
  box-shadow: var(--shadow);
  cursor: pointer;
  z-index: 9999;
  transition: background 0.3s, color 0.3s, transform 0.3s;
  border: 2px solid var(--gold);
  animation: popIn 0.5s;
}
@keyframes popIn {
  from {transform: scale(0.7);}
  to {transform: scale(1);}
}
.floating-cart:hover {
  background: var(--gold);
  color: var(--primary);
  transform: scale(1.08) rotate(-5deg);
}
.bags {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

/* خيارات المنتج داخل المودال */
.color-options, .size-options {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0 8px 0;
}
.color-btn, .size-btn {
  padding: 7px 14px;
  border: 1.2px solid var(--primary);
  border-radius: 6px;
  cursor: pointer;
  background: var(--white);
  font-size: 13.5px;
  font-weight: bold;
  color: var(--primary);
  transition: background 0.3s, color 0.3s, border-color 0.3s, transform 0.2s;
  margin: 3px 0;
  min-width: 48px;
}
.color-btn.selected,
.size-btn.selected {
  background: var(--primary);
  color: var(--gold);
  border-color: var(--gold);
  transform: scale(1.06);
}

/* زر إضافة للسلة */
.add-to-cart-btn {
  margin-top: 15px;
  padding: 10px 25px;
  background: var(--primary);
  color: var(--gold);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  font-size: 16px;
  font-weight: bold;
  box-shadow: var(--shadow);
  transition: background 0.3s, color 0.3s, transform 0.2s;
  animation: btnFade 0.7s;
  display: inline-block;
}
@keyframes btnFade {
  from {opacity: 0; transform: scale(0.95);}
  to {opacity: 1; transform: scale(1);}
}
.add-to-cart-btn:hover {
  background: linear-gradient(90deg, #a90000, #f0c28b 80%);
  color: #710000;
  box-shadow: 0 4px 25px rgba(113,0,0,0.15);
  transform: translateY(-2px) scale(1.03);
}

/* المودال */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.68);
  justify-content: center;
  align-items: center;
  z-index: 9999;
  animation: fadeInModal 0.5s;
}
@keyframes fadeInModal {
  from { opacity: 0;}
  to { opacity: 1;}
}
.modal-popup {
  background: var(--white);
  border-radius: 14px;
  width: 90vw;
  max-width: 420px;
  padding: 18px 12px 7px 12px;
  position: relative;
  text-align: center;
  box-shadow: var(--shadow);
  animation: scaleIn 0.5s;
  max-height: 85vh;
  overflow-y: auto;
}
@keyframes scaleIn {
  from {transform: scale(0.8); opacity: 0;}
  to {transform: scale(1); opacity: 1;}
}
.close-modal {
  position: absolute;
  top: 12px;
  left: 15px;
  font-size: 28px;
  cursor: pointer;
  color: var(--primary);
  transition: color 0.3s;
}
.close-modal:hover { color: var(--gold); }
.modal-image-container {
  margin-top: 8px;
  margin-bottom: 10px;
  text-align: center;
  position: relative;
}
.modal-image {
  width: 100%;
  max-height: 310px;
  object-fit: contain;
  border-radius: 9px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  background: var(--gray);
  transition: opacity 0.39s;
  opacity: 1;
}
.modal-image.fading {
  opacity: 0;
}
@keyframes imgFade { from{opacity:0;} to{opacity:1;} }
.arrow {
  position: absolute;
  bottom: 63%;
  left: 45%;
  transform: translateX(-50%);
  background: var(--primary);
  color: var(--gold);
  border: none;
  font-size: 22px;
  padding: 7px 3px;
  cursor: pointer;
  border-radius: 5px;
  user-select: none;
  transition: background 0.3s, color 0.3s;
  z-index: 2;
}
.left-arrow { left: 8%; width: 22px; }
.right-arrow { left: 92%; width: 22px; }
.arrow:hover {
  background: var(--gold);
  color: var(--primary);
}
/* الكمية في المودال */
#stockMsg {
  margin: 10px auto;
  font-size: 15px;
  color: #710000;
  text-align: center;
}

/* ===== Pagination Controls ===== */
.pagination-controls {
  text-align: center;
  margin: 35px auto 30px auto;
  direction: rtl;
  width: 100%;
}
.pagination-bar {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: #fff;
  border-radius: 44px;
  padding: 6px 12px 6px 12px;
  box-shadow: 0 2px 9px rgba(113,0,0,0.08);
  border: 1.2px solid var(--gold);
}
.pagination-btn,
.pagination-arrow {
  padding: 7px 15px;
  margin: 0 2.5px;
  border-radius: 7px;
  border: 1.2px solid var(--primary);
  background: var(--white);
  color: var(--primary);
  font-size: 16.5px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 1px;
  box-shadow: 0 1px 5px #7110 0px;
  transition: background .18s, color .18s, border-color .18s;
  outline: none;
  min-width: 38px;
}
.pagination-btn.active,
.pagination-btn:disabled {
  background: var(--primary);
  color: var(--gold);
  border-color: var(--gold);
  cursor: default;
  box-shadow: 0 1px 7px #71000022;
}
.pagination-arrow {
  background: var(--gold);
  color: var(--primary);
  border-color: var(--primary);
  min-width: 65px;
}
.pagination-arrow.disabled, .pagination-btn:disabled {
  background: #eee;
  color: #bbb;
  border-color: #eee;
  cursor: not-allowed;
}
.pagination-btn:hover:not(:disabled),
.pagination-arrow:hover:not(.disabled) {
  background: var(--primary);
  color: var(--gold);
  border-color: var(--gold);
}
.pagination-ellipsis {
  font-size: 21px;
  padding: 0 7px;
  color: #999;
  user-select: none;
}

@media (max-width: 600px) {
  .pagination-bar {
    padding: 4px 3px;
    gap: 1px;
    border-radius: 19px;
  }
  .pagination-btn, .pagination-arrow {
    padding: 6px 7px;
    font-size: 14px;
    min-width: 28px;
    margin: 0 1px;
  }
  .pagination-arrow {
    min-width: 40px;
  }
}

/* الفوتر */
.footer {
  background: var(--primary);
  color: var(--gold);
  padding: 32px 18px 16px 18px;
  font-family: 'Cairo', Arial, sans-serif;
  direction: rtl;
  border-top: 2px solid var(--gold);
  margin-top: 30px;
  animation: fadeInFooter 0.8s;
}
@keyframes fadeInFooter {
  from {opacity: 0;}
  to {opacity: 1;}
}
.footer-content {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 24px;
  max-width: 1200px;
  margin: auto;
}
.footer-section {
  flex: 1;
  min-width: 215px;
  margin-bottom: 12px;
}
.footer-section h3 {
  margin-bottom: 7px;
  font-size: 18px;
  color: var(--gold);
  font-weight: bold;
}
.footer-section a {
  color: var(--white);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-section a:hover {
  color: var(--gold);
  text-decoration: underline;
}
.footer-bottom {
  text-align: center;
  padding-top: 10px;
  font-size: 15px;
  color: var(--white);
  border-top: 1px solid var(--gold);
  margin-top: 18px;
}
@media (max-width: 750px) {
  .footer-content {
    flex-direction: column;
    gap: 10px;
  }
}

/* Toast Message */
#toast {
  visibility: hidden;
  min-width: 220px;
  background: var(--primary);
  color: var(--gold);
  text-align: center;
  border-radius: 5px;
  padding: 10px 0;
  position: fixed;
  bottom: 33px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 15px;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.5s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.17);
}

/* ===== الصور المصغرة صفوف أفقية في المودال ===== */
#modalThumbnails {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  margin: 14px auto 8px auto;
  width: 100%;
  max-width: 320px; /* أو حسب عرض المودال */
}

.thumbs-row {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 7px;
  width: 100%;
}

.thumb-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 5px;
  border: 2px solid #710000;
  cursor: pointer;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  display: block;
}
.thumb-img.selected {
  border-color: #f0c28b;
  box-shadow: 0 0 6px #b66;
  opacity: 1;
}
@media (max-width: 600px) {
  #modalThumbnails {
    max-width: 98vw;
    gap: 4px;
  }
  .thumbs-row {
    gap: 4px;
  }
  .thumb-img {
    width: 32px;
    height: 32px;
  }
}
/* Scrollbar */
::-webkit-scrollbar {
  width: 7px;
  background: var(--gold);
}
::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 5px;
}

/* تأثيرات المودال */
.fade-in {
  animation: fadeInModal 0.5s forwards;
}
.fade-out {
  animation: fadeOutModal 0.5s forwards;
}
@keyframes fadeOutModal {
  from { opacity: 1;}
  to { opacity: 0;}
}