/* ==========================================================
   enhance.css — طبقة التجربة الاحترافية (مستوى SHEIN/Noon)
   drawer التصنيفات، skeleton، حركات، تناسق الصور، معرض swipe
   ========================================================== */

/* ---------- تناسق الصور القسري (كل صور المنتجات نفس الحجم مهما رفع المتجر) ---------- */
.card__img,
.pd__img,
.carousel-card__img {
  object-fit: cover !important;   /* قص ذكي بدل تمديد */
  object-position: center;
  background: var(--color-surface-2);
  width: 100%;
}

/* ---------- Skeleton Loading (هيكل رمادي متحرك وقت التحميل) ---------- */
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--color-surface) 25%, var(--color-surface-2) 50%, var(--color-surface) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  border-radius: var(--radius);
}
.skeleton-card { border-radius: var(--radius); overflow: hidden; }
.skeleton-card__img { aspect-ratio: 3/4; width: 100%; }
.skeleton-card__line { height: 12px; margin: 8px; border-radius: 6px; }
.skeleton-card__line--short { width: 50%; }

/* ---------- Category Drawer (قائمة تصنيفات جانبية متل SHEIN) ---------- */
.cat-drawer-btn {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--color-surface); font-size: 18px; flex-shrink: 0;
}
.drawer-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.cat-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61;
  width: 82%; max-width: 340px;
  background: var(--color-bg);
  transform: translateX(100%); transition: transform .32s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column;
  box-shadow: -8px 0 30px -10px rgba(0,0,0,.5);
}
.cat-drawer.open { transform: translateX(0); }
.cat-drawer__header {
  padding: 20px 18px 16px; border-bottom: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: space-between;
}
.cat-drawer__title { font-family: var(--font-display); font-size: 18px; font-weight: 700; }
.cat-drawer__body { flex: 1; overflow-y: auto; padding: 8px 0; }
.cat-drawer__item {
  padding: 15px 20px; font-size: 15px; font-weight: 500;
  border-right: 3px solid transparent; transition: background .15s;
  display: flex; align-items: center; gap: 12px;
}
.cat-drawer__item:active { background: var(--color-surface); }
.cat-drawer__item.active {
  border-right-color: var(--color-primary);
  background: var(--color-surface); color: var(--color-primary); font-weight: 700;
}
.cat-drawer__count { margin-right: auto; font-size: 12px; color: var(--color-muted); }

/* ---------- Product Image Gallery (سحب أفقي بين صور المنتج) ---------- */
.pd-gallery { position: relative; margin-bottom: 12px; }
.pd-gallery__track {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  scrollbar-width: none; border-radius: var(--radius); gap: 0;
}
.pd-gallery__track::-webkit-scrollbar { display: none; }
.pd-gallery__slide {
  flex: 0 0 100%; scroll-snap-align: center;
  aspect-ratio: 1; width: 100%;
}
.pd-gallery__slide img, .pd-gallery__slide video {
  width: 100%; height: 100%; object-fit: cover; border-radius: var(--radius);
}
.pd-gallery__dots {
  position: absolute; bottom: 10px; right: 50%; transform: translateX(50%);
  display: flex; gap: 6px; z-index: 2;
}
.pd-gallery__dots span {
  width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.5);
  transition: all .2s;
}
.pd-gallery__dots span.active { background: #fff; width: 18px; border-radius: 4px; }

/* ---------- Filter/Sort bar (فلترة وترتيب البضاعة) ---------- */
.filter-bar {
  display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto;
  scrollbar-width: none; position: sticky; top: 66px; z-index: 20;
  background: var(--color-bg);
}
.filter-bar::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0; padding: 8px 14px; border-radius: 999px;
  background: var(--color-surface); border: 1px solid var(--color-border);
  font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 5px;
}
.filter-chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ---------- Page transitions & entrance animations ---------- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.card { animation: fade-up .4s ease backwards; }
.card:nth-child(2) { animation-delay: .04s; }
.card:nth-child(3) { animation-delay: .08s; }
.card:nth-child(4) { animation-delay: .12s; }
.card:nth-child(5) { animation-delay: .16s; }
.card:nth-child(6) { animation-delay: .2s; }

.sheet { transition: transform .34s cubic-bezier(.4,0,.2,1); }

/* ---------- Add-to-cart fly animation ---------- */
@keyframes cart-bump {
  0%, 100% { transform: scale(1); }
  40% { transform: scale(1.3); }
}
.topbar__cart.bump { animation: cart-bump .4s ease; }

/* ---------- Wishlist page ---------- */
.wishlist-empty { text-align: center; padding: 60px 24px; color: var(--color-muted); }
.wishlist-empty__icon { font-size: 48px; margin-bottom: 12px; }

/* ---------- Typing indicator (الدردشة) ---------- */
.typing-indicator { display: flex; gap: 4px; padding: 12px 16px; align-self: flex-end; }
.typing-indicator span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--color-muted);
  animation: typing-bounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .2s; }
.typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ---------- Toast with sound-friendly slide ---------- */
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- Report button ---------- */
.report-link { font-size: 11.5px; color: var(--color-muted); text-decoration: underline; margin-top: 14px; display: inline-block; }

/* ---------- Image Zoom Overlay ---------- */
#imageZoomOverlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.92); display: none;
  align-items: center; justify-content: center; padding: 20px;
}
#imageZoomOverlay.open { display: flex; }
#imageZoomImg { max-width: 100%; max-height: 90vh; object-fit: contain; border-radius: 8px; }

/* ---------- Splash Screen (شاشة تحميل نظيفة محايدة) ---------- */
#appSplash {
  position: fixed; inset: 0; z-index: 200;
  background: #ffffff;
  display: flex; align-items: center; justify-content: center;
  transition: opacity .4s ease;
}
#appSplash.hidden-splash { opacity: 0; pointer-events: none; }
.splash-spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid #eee; border-top-color: #888;
  animation: splash-spin .8s linear infinite;
}
@keyframes splash-spin { to { transform: rotate(360deg); } }

/* ---------- Pull to Refresh ---------- */
#pullRefresh {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  height: 0; overflow: hidden; transition: height .2s;
  color: var(--color-primary); font-size: 13px;
}
#pullRefresh.active { height: 50px; }
#pullRefresh .spin { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--color-border); border-top-color: var(--color-primary); animation: splash-spin .8s linear infinite; }

/* ---------- Skeleton grid (وقت التحميل) ---------- */
.skeleton-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 0 16px 20px; }

/* ---------- Category Sections (عرض حسب التصنيف - سحب أفقي متل SHEIN) ---------- */
.cat-section { margin-bottom: 22px; }
.cat-section__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; margin-bottom: 12px;
}
.cat-section__title { font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--color-text); }
.cat-section__more { font-size: 12.5px; color: var(--color-primary); font-weight: 700; }
.cat-section__scroll {
  display: flex; gap: 12px; overflow-x: auto; padding: 0 16px 4px;
  scroll-snap-type: x proximity; scrollbar-width: none;
}
.cat-section__scroll::-webkit-scrollbar { display: none; }
.card--compact {
  flex: 0 0 46%; max-width: 46%; scroll-snap-align: start;
}
@media (min-width: 500px) { .card--compact { flex-basis: 30%; max-width: 30%; } }

/* ---------- Install button in header (أنيق - يظهر بس لما التثبيت متاح) ---------- */
.install-header-btn {
  display: flex; align-items: center; gap: 4px;
  background: var(--color-primary); color: #fff;
  padding: 7px 14px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; font-family: inherit;
  box-shadow: 0 3px 10px -3px var(--color-primary);
  animation: install-pulse 2s ease-in-out infinite;
}
@keyframes install-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ==========================================================
   اختيار السمات (متل SHEIN) — مقاسات وألوان مع حالة التوفر
   ========================================================== */
.variant-group__label { display: flex; align-items: center; gap: 8px; }
.variant-group__picked { font-weight: 400; color: var(--color-muted); font-size: 12px; }

.variant-chip.unavailable {
  opacity: .35; text-decoration: line-through; cursor: not-allowed;
  background: transparent;
}
.variant-chips--color { gap: 10px; }
.color-swatch {
  width: 34px; height: 34px; border-radius: 50%; padding: 3px;
  border: 2px solid transparent; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.color-swatch i { width: 100%; height: 100%; border-radius: 50%; display: block; border: 1px solid rgba(128,128,128,.35); }
.color-swatch.selected { border-color: var(--color-primary); transform: scale(1.05); }
.color-swatch.unavailable { opacity: .3; cursor: not-allowed; position: relative; }
.color-swatch.unavailable::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  width: 100%; height: 1.5px; background: var(--color-muted); transform: rotate(-45deg);
}

/* سطر حالة المخزون */
.stock-line { margin: 10px 0 2px; font-size: 12.5px; font-weight: 600; }
.stock-out { color: var(--color-danger); }
.stock-low { color: #E8622C; }
.stock-ok { color: #2E9E5B; }

/* زر معطّل */
.btn--disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.4); }

/* ---------- اسم البائع (بضاعة التجار تظهر باسمهم) ---------- */
.card__vendor { font-size: 10.5px; color: var(--color-muted); margin-top: 2px; }
.pd__vendor {
  font-size: 12.5px; color: var(--color-muted); margin: 6px 0 4px;
  padding: 6px 10px; background: var(--color-surface-2); border-radius: 8px; display: inline-block;
}
.pd__vendor strong { color: var(--color-text); }
