/* ويب: 3 أعمدة — الصور يمين الناظر (مصغرات | صورة رئيسية)، التفاصيل والأزرار يسار */
.single-product {
  display: grid;
  grid-template-columns: 80px 1fr 1fr;
  grid-template-rows: auto;
  grid-template-areas: "thumbnails mainimg details";
  align-items: start;
  justify-content: flex-start;
  justify-items: stretch;
  margin: 0 auto 2rem;
  max-width: 1200px;
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  direction: rtl;
}

@media (min-width: 821px) {
  .single-product {
    min-width: 800px;
  }
}

.single-product .thumbnails {
  grid-area: thumbnails;
  grid-column: 1;
  min-height: 0;
  direction: rtl;
}

.single-product .single-product-main-img {
  grid-area: mainimg;
  grid-column: 2;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  direction: rtl;
}

.single-product .details {
  grid-area: details;
  grid-column: 3;
  min-width: 0;
  width: 100%;
  direction: rtl;
}

.single-product-main-img img,
.single-product .single-product-main-img img {
  width: 100%;
  max-width: 500px;
  min-width: 200px;
  height: auto;
  border-radius: 16px;
  margin: 0 auto;
  display: block;
  object-fit: cover;
  visibility: visible;
  background-color: #f5f5f5;
}

.thumbnails {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
}

.thumbnails img {
  max-width: 100px;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  object-fit: cover;
  cursor: pointer;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
}

.thumbnails img:hover,
.thumbnails img.active {
  border-color: var(--y-main, #4a7c59);
  transform: scale(1.02);
}

.details {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
  overflow: visible;
}

.details h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 0.25rem;
  line-height: 1.3;
  color: var(--y-color-text-dark, #1a1a1a);
}

.details h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.4;
}

.details .code {
  font-size: 1rem;
  color: var(--y-color-cherry-red);
  font-weight: 600;
  margin: 0;
}

.actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  margin-top: 20px;
  width: 40%;
}

.actions button,
.actions .btn-primary {
  font-size: 1.2rem;
  width: 100%;
  background-color: var(--y-main);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 700;
  font-family: var(--y-font-family, inherit);
}
.actions button:hover,
.actions .btn-primary:hover {
  opacity: 0.9;
}
.actions .qnt {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 1px solid var(--y-main);
  padding: 0 15px;
  border-radius: 12px;
  width: 100%;
  box-sizing: border-box;
}
.actions .qnt .quantity-input {
  width: 3rem;
  text-align: center;
  border: none;
  font-size: 1.1rem;
  font-weight: 600;
  -moz-appearance: textfield;
}
.actions .qnt .quantity-input::-webkit-outer-spin-button,
.actions .qnt .quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.actions .qnt button {
  padding: 5px 12px;
  border: 0;
  background-color: transparent;
  cursor: pointer;
  width: auto;
  flex-shrink: 0;
  color: inherit;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
/* تابلت: عمودان — يسار: صورة ثم مصغرات | يمين: تفاصيل */
@media (max-width: 820px) {
  .single-product {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: 1.25rem;
    padding: 1.25rem 1rem;
    margin: 0 auto 1.5rem;
  }

  .single-product-main-img {
    grid-column: 1;
    grid-row: 1;
  }

  .single-product-main-img img {
    max-width: 100%;
    border-radius: 12px;
  }

  .thumbnails {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    justify-content: start;
    gap: 0.5rem;
    margin-top: 0;
  }

  .thumbnails img {
    width: 100%;
    max-width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 10px;
  }

  .details {
    grid-column: 2;
    grid-row: 1 / -1;
    align-self: start;
    gap: 0.75rem;
  }

  .details h3 {
    font-size: 1.35rem;
    margin-bottom: 0.25rem;
  }

  .details h2 {
    font-size: 1.4rem;
    margin: 0;
  }

  .details .code {
    font-size: 1rem;
  }

  .actions {
    width: 100%;
    margin-top: 0.5rem;
    gap: 0.75rem;
  }

  .actions button,
  .actions .btn-primary {
    font-size: 1rem;
    padding: 0.7rem 1rem;
    min-height: 44px;
  }

  .actions .qnt {
    padding: 0.5rem 1rem;
    min-height: 44px;
  }

  .actions .qnt .quantity-input {
    font-size: 1rem;
  }

  .actions .qnt button {
    font-size: 1.15rem;
  }
}

/* جوال: عمود بصفوف — الصف الأول للصور، الصف الثاني للتفاصيل + هوامش جانبية */
@media (max-width: 480px) {
  .single-product {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "mainimg"
      "thumbnails"
      "details";
    gap: 1rem;
    padding: 1rem 0;
    margin: 0 auto 1.5rem;
  }

  /* الصف الأول: الصورة الرئيسية — عرض كامل وتمتد بالطول */
  .single-product .single-product-main-img {
    grid-area: mainimg;
    grid-column: 1;
    grid-row: 1;
    order: unset;
    width: 100%;
    max-width: 100%;
    min-height: 280px;
    display: flex;
    align-items: stretch;
    justify-content: center;
  }

  .single-product-main-img img {
    width: 100%;
    max-width: 100%;
    height: auto;
    min-height: 280px;
    object-fit: cover;
    border-radius: 12px;
    display: block;
  }

  /* الصف الثاني: المصغرات — عرض كامل */
  .single-product .thumbnails {
    grid-area: thumbnails;
    grid-column: 1;
    grid-row: 2;
    order: unset;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0;
  }

  /* الصف الثالث: التفاصيل — تحته بعرض كامل */
  .single-product .details {
    grid-area: details;
    grid-column: 1;
    grid-row: 3;
    order: unset;
    width: 100%;
    max-width: 100%;
    gap: 0.75rem;
  }

  .thumbnails img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 10px;
  }

  .details h3 {
    font-size: 1.2rem;
    margin-bottom: 0.15rem;
  }

  .details h2 {
    font-size: 1.25rem;
  }

  .details .code {
    font-size: 0.95rem;
  }

  .actions {
    width: 100%;
    gap: 0.65rem;
    margin-top: 0.25rem;
  }

  .actions button,
  .actions .btn-primary {
    font-size: 0.95rem;
    padding: 0.65rem 0.75rem;
    min-height: 44px;
    border-radius: 10px;
  }

  .actions .qnt {
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
  }
}
