/* حالة المخزون بارزة */
.wcpe-stock {
  display: inline-flex;
  align-items: center;
  font-weight: bold;
  font-size: 13px;
  border-radius: 16px;
  padding: 3px 12px 3px 8px;
  margin-top: 6px;
  margin-bottom: 2px;
  box-shadow: 0 0 8px 0 rgba(22,163,74,0.10);
  background: rgba(22,163,74,0.08);
  gap: 6px;
}
.wcpe-stock.in-stock {
  color: #16a34a;
  background: rgba(22,163,74,0.08);
  box-shadow: 0 0 8px 0 rgba(22,163,74,0.10);
}
.wcpe-stock.out-of-stock {
  color: #dc2626;
  background: rgba(220,38,38,0.08);
  box-shadow: 0 0 8px 0 rgba(220,38,38,0.10);
}
.wcpe-stock .stock-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-left: 6px;
  margin-right: 2px;
  box-shadow: 0 0 6px 1px currentColor;
  background: currentColor;
  opacity: 0.85;
}
.wcpe-stock.in-stock .stock-dot {
  color: #16a34a;
  background: #16a34a;
}
.wcpe-stock.out-of-stock .stock-dot {
  color: #dc2626;
  background: #dc2626;
}
/* WC Product Explorer v4.0 — by YAHYA KHALID - مع تحسينات mobile-first */

/* Theme variables */
:root {
  --wcpe-text: var(--theme-palette-color-3);
  --wcpe-accent: var(--theme-palette-color-4);
  --wcpe-danger: var(--theme-palette-color-2);
  --wcpe-bg: var(--theme-palette-color-5, #ffffff);
  --wcpe-card: var(--theme-palette-color-6, #ffffff);
  --wcpe-border: var(--theme-palette-color-7);
  --wcpe-chip-bg: var(--theme-palette-color-8);
  --wcpe-chip-border: var(--theme-palette-color-7);
  --wcpe-btn-text: #ffffff;
  --wcpe-ok: #16a34a;
  --wcpe-buy-width: 220px;
  --wcpe-font: "Cairo", "Tajawal", "Noto Kufi Arabic", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Base */
.wcpe { 
  direction: rtl; 
  font-family: var(--wcpe-font); 
  color: var(--wcpe-text);
  background: var(--theme-palette-color-8);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}
.wcpe * { box-sizing: border-box; }
.wcpe-container { 
  width: 100%; 
  max-width: 100%;
  margin: 0; 
  padding: 12px; 
  background: var(--theme-palette-color-8); 
  overflow-x: hidden;
  position: relative;
}

/* Header - مبسط ومتجاوب */
.wcpe-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  gap: 10px; 
  flex-wrap: wrap; 
  min-width: 0;
  background: var(--wcpe-card);
  padding: 16px;
  border-radius: 12px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.wcpe-title { 
  margin: 0; 
  font-size: 22px; 
  font-weight: 800; 
  color: var(--wcpe-text); 
}

.wcpe-right-controls { 
  display: flex; 
  gap: 8px; 
  align-items: center; 
  flex-wrap: wrap; 
  min-width: 0; 
}

/* Search - محسن للموبايل */
.wcpe-search { 
  position: relative; /* إزالة sticky */
  background: var(--theme-palette-color-8);
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  margin-bottom: 16px;
  width: 100%;
  transition: all 0.3s ease;
  border: 1px solid rgba(255,255,255,0.1);
}

/* تحسين البحث عند التفاعل */
.wcpe-search:hover {
  box-shadow: 0 6px 16px rgba(0,0,0,0.2);
  transform: translateY(-1px);
}

/* تأكيد الـ sticky في جميع المتصفحات */
.wcpe-search {
  position: -webkit-sticky;
  position: sticky;
}

.wcpe-search .wcpe-input { 
  width: 100%; 
  border: 2px solid var(--wcpe-danger); 
  border-radius: 14px; 
  padding: 12px 44px 12px 14px; 
  background: var(--wcpe-card); 
  color: var(--wcpe-text); 
  font-weight: 700; 
  font-size: 16px;
  outline: none;
}

.wcpe-search-ico { 
  position: absolute; 
  right: 26px; 
  top: 50%; 
  transform: translateY(-50%); 
  width: 18px; 
  height: 18px; 
  pointer-events: none; 
  background: no-repeat center/contain url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23ff0000'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.471 6.471 0 0016 9.5 6.5 6.5 0 109.5 16a6.471 6.471 0 004.23-1.57l.27.28v.79l5 5 1.5-1.5-5-5zM9.5 14C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E");
}

/* Filters - التصنيفات أعلى، البراندات أسفل */
.wcpe-filters { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 12px; 
  min-width: 0; 
  margin-bottom: 16px;
  width: 100%;
}

.wcpe-filter-block { 
  position: relative; 
  background: var(--wcpe-card); 
  border: 3px solid var(--wcpe-border); 
  border-radius: 16px; 
  padding: 12px; 
  width: 100%; 
  overflow: hidden; 
}

.wcpe-filter-title { 
  font-weight: 800; 
  margin-bottom: 8px; 
  text-align: center; 
  color: var(--wcpe-text); 
  white-space: nowrap; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  padding-inline: 6px; 
}

/* Horizontal sliders (no visible scrollbar, draggable) */
.wcpe-cats, .wcpe-brands {
  display: flex; 
  gap: 8px; 
  align-items: center; 
  flex-wrap: nowrap;
  overflow-x: auto; 
  overflow-y: hidden; 
  padding: 0 6px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  scrollbar-width: none; 
  -ms-overflow-style: none;
  overscroll-behavior-inline: contain;
  touch-action: pan-x;
  max-width: 100%;
  margin: 0 -6px;
  position: relative;
  cursor: grab;
  user-select: none;
  scroll-behavior: smooth;
}

.wcpe-cats.dragging, .wcpe-brands.dragging { cursor: grabbing; }
.wcpe-cats::-webkit-scrollbar, .wcpe-brands::-webkit-scrollbar { display: none; }
.wcpe-chip, .wcpe-brand { scroll-snap-align: start; flex: 0 0 auto; }

/* Scroll arrows (desktop only) */
.wcpe-scroll-btn {
  position: absolute; 
  top: 50%; 
  transform: translateY(-50%);
  width: 28px; 
  height: 28px; 
  border-radius: 999px;
  border: 2px solid var(--wcpe-border); 
  background: var(--wcpe-card);
  display: none; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer;
  z-index: 10;
}

.wcpe-scroll-btn.left { left: 6px; }
.wcpe-scroll-btn.right { right: 6px; }
.wcpe-filter-block:hover .wcpe-scroll-btn { display: flex; }

.wcpe-scroll-btn::before {
  content: ""; 
  width: 14px; 
  height: 14px; 
  display: block; 
  background: no-repeat center/contain;
}

.wcpe-scroll-btn.left::before { 
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M15.41 7.41 14 6l-6 6 6 6 1.41-1.41L10.83 12z'/%3E%3C/svg%3E"); 
}

.wcpe-scroll-btn.right::before { 
  background-image: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 24 24%22 fill=%22%23666%22%3E%3Cpath d=%22M8.59 16.59 13.17 12 8.59 7.41 10 6l6 6-6 6z%22/%3E%3C/svg%3E'); 
}

@media(max-width:768px) { 
  .wcpe-scroll-btn { display: none !important; } 
}

/* Chips & brands */
.wcpe-chip { 
  border: 2px solid var(--wcpe-chip-border); 
  background: var(--wcpe-chip-bg); 
  color: var(--wcpe-text); 
  padding: 8px 12px; 
  border-radius: 999px; 
  cursor: pointer; 
  user-select: none; 
  font-weight: 700; 
}

.wcpe-chip.active { 
  border-color: var(--wcpe-accent); 
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--wcpe-accent) 12%, transparent); 
}

.wcpe-brand { 
  color: #fff; 
  border: none; 
  padding: 8px 12px; 
  border-radius: 999px; 
  cursor: pointer; 
  user-select: none; 
  font-weight: 700;
  white-space: nowrap; /* منع التفاف النص */
  min-width: fit-content; /* عرض مناسب للمحتوى */
  font-size: 14px;
  transition: all 0.3s ease;
}

.wcpe-brand.active { 
  outline: 2px solid rgba(255,255,255,.7);
  transform: scale(1.05); /* تأثير تكبير خفيف عند التحديد */
}

.wcpe-brand:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* Toolbar + toggles - أزرار محسنة */
.wcpe-toolbar { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin: 8px 0; 
  color: color-mix(in srgb, var(--wcpe-text) 60%, transparent);
  background: var(--wcpe-card);
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 16px;
  width: 100%;
}

.wcpe-view-toggle, .wcpe-mobile-toggle {
  display: flex;
  gap: 4px;
  background: var(--wcpe-chip-bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--wcpe-border);
}

.wcpe-view-toggle .btn, .wcpe-mobile-toggle .btn { 
  border: none; 
  background: transparent; 
  padding: 6px 10px; 
  border-radius: 6px; 
  cursor: pointer; 
  color: var(--wcpe-text); 
  font-weight: 700; 
  min-width: 44px; 
  text-align: center; 
  font-size: 12px;
  transition: all 0.2s ease;
}

.wcpe-view-toggle .btn.active, .wcpe-mobile-toggle .btn.active { 
  background: var(--wcpe-danger); 
  border-color: var(--wcpe-danger); 
  color: #fff; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.wcpe-view-toggle .btn:hover, .wcpe-mobile-toggle .btn:hover {
  background: var(--wcpe-card);
}

.wcpe-mobile-toggle { display: none; }
@media(max-width:768px) { .wcpe-mobile-toggle { display: flex; } }

/* Products: grid/list - محسن للموبايل */
.wcpe-products.grid { 
  display: grid; 
  grid-template-columns: repeat(2, 1fr); 
  gap: 10px;
  width: 100%;
}

@media(min-width: 768px) {
  .wcpe-products.grid { grid-template-columns: repeat(3, 1fr); }
}

@media(min-width: 1024px) { 
  .wcpe-products.grid { grid-template-columns: repeat(4, 1fr); } 
}

@media(min-width: 1200px) { 
  .wcpe-products.grid { grid-template-columns: repeat(5, 1fr); } 
}

@media(min-width: 1400px) { 
  .wcpe-products.grid { grid-template-columns: repeat(6, 1fr); } 
}

.wcpe-products.grid.mobile-one { 
  grid-template-columns: 1fr !important; 
}

.wcpe-products.list { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 10px;
  width: 100%;
}

/* Card - مع حدود البراند وتحسينات للموبايل */
.wcpe-card, .wcpe-row { 
  position: relative; 
  background: var(--wcpe-card); 
  color: var(--wcpe-text); 
}

.wcpe-card { 
  border: 3px solid var(--wcpe-border); 
  border-radius: 16px; 
  overflow: hidden; 
  display: flex; 
  flex-direction: column; 
}

.wcpe-card.branded { 
  border-color: var(--brand, var(--wcpe-border)) !important; 
}

.wcpe-card .img { 
  aspect-ratio: 1/1; 
  background: var(--wcpe-chip-bg); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer;
  transition: transform 0.3s ease;
}

.wcpe-card .img:hover {
  transform: scale(1.02);
}

.wcpe-card .img img { 
  width: 100%; 
  height: 100%; 
  object-fit: cover; 
  cursor: pointer;
}

.wcpe-card .body { 
  padding: 8px; 
  display: grid; 
  gap: 6px; 
  text-align: center; 
}

.wcpe-card .title { 
  color: var(--wcpe-accent); 
  font-weight: 800; 
  font-size: 13px; 
  line-height: 1.2; 
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.4em;
  margin-bottom: 4px;
  cursor: pointer;
  transition: color 0.3s ease;
}

.wcpe-card .title:hover {
  color: var(--wcpe-danger);
}

.wcpe-card .price { 
  font-weight: 900; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  gap: 4px; 
  font-size: 13px;
}

.wcpe-card .price .current { 
  color: var(--wcpe-accent); 
  font-weight: 900; 
}

.wcpe-card .price .regular.strike { 
  text-decoration: line-through; 
  opacity: .7; 
  font-weight: 700; 
  font-size: 11px;
}

.wcpe-card .sale-badge { 
  display: inline-block; 
  font-size: 9px; 
  padding: 2px 4px; 
  border-radius: 6px; 
  background: var(--wcpe-danger); 
  color: #fff; 
  font-weight: 800; 
}

.wcpe-card .buy { 
  display: flex; 
  gap: 4px; 
  align-items: center; 
  justify-content: center; 
  flex-direction: column; 
}

.wcpe-card .qty { 
  display: flex; 
  align-items: center; 
  border: 2px solid var(--wcpe-danger); 
  border-radius: 8px; 
  overflow: hidden; 
  background: var(--wcpe-card); 
  width: 140px;
}

.wcpe-card .qty button { 
  width: 32px; 
  height: 32px; 
  border: none; 
  background: transparent; 
  color: var(--wcpe-danger); 
  cursor: pointer; 
  font-weight: 800; 
  font-size: 16px; 
}

.wcpe-card .qty input { 
  width: 100%; 
  height: 32px; 
  border: none; 
  outline: none; 
  background: transparent; 
  text-align: center; 
  color: var(--wcpe-text); 
  font-weight: 800; 
  font-size: 12px;
}

.wcpe-card .buy .btn, .wcpe-card .buy a.btn { 
  border: 2px solid var(--wcpe-danger); 
  background: var(--wcpe-danger); 
  color: #fff; 
  padding: 8px 12px; 
  border-radius: 8px; 
  text-align: center; 
  text-decoration: none; 
  cursor: pointer; 
  font-weight: 800; 
  width: 140px;
  font-size: 11px;
}

/* Brand corner - شعار البراند في الزاوية */
.wcpe-card .brand-corner, .wcpe-row .brand-corner {
  position: absolute; 
  top: -3px; 
  left: -3px; 
  padding: 4px 8px;
  background: var(--brand, var(--wcpe-accent)); 
  color: #fff; 
  font-weight: 800; 
  font-size: 11px;
  border-bottom-right-radius: 10px; 
  border-top-left-radius: 10px;
  border: 3px solid var(--brand, var(--wcpe-accent)); 
  border-top: 0; 
  border-left: 0; 
  pointer-events: none;
}

/* Row (desktop style preserved on mobile) */
.wcpe-row { 
  border: 3px solid var(--wcpe-border); 
  border-radius: 12px; 
  padding: 10px; 
  display: grid; 
  grid-template-columns: 72px 1fr auto; 
  gap: 10px; 
  align-items: center; 
}

.wcpe-row.branded { 
  border-color: var(--brand, var(--wcpe-border)) !important; 
}

.wcpe-row img { 
  width: 72px; 
  height: 72px; 
  object-fit: cover; 
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.3s ease;
}

.wcpe-row img:hover {
  transform: scale(1.05);
}

.wcpe-row .row-meta { 
  display: grid; 
  gap: 6px; 
  min-width: 0; 
}

.wcpe-row .row-title { 
  color: var(--wcpe-accent); 
  font-weight: 800; 
  line-height: 1.35; 
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 2.7em;
  cursor: pointer;
  transition: color 0.3s ease;
}

.wcpe-row .row-title:hover {
  color: var(--wcpe-danger);
}

.wcpe-row .row-actions { 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  justify-self: end; 
  flex-direction: column; 
}

.wcpe-row .qty { 
  display: flex; 
  align-items: center; 
  border: 2px solid var(--wcpe-danger); 
  border-radius: 10px; 
  overflow: hidden; 
  background: var(--wcpe-card); 
}

.wcpe-row .qty button { 
  width: 40px; 
  height: 40px; 
  border: none; 
  background: transparent; 
  color: var(--wcpe-danger); 
  cursor: pointer; 
  font-weight: 800; 
  font-size: 18px; 
}

.wcpe-row .qty input { 
  width: 72px; 
  height: 40px; 
  border: none; 
  outline: none; 
  background: transparent; 
  text-align: center; 
  color: var(--wcpe-text); 
  font-weight: 800; 
}

/* Mobile adjustments - تحسينات شاملة للموبايل */
@media(max-width:768px) {
  :root { --wcpe-buy-width: 140px; }
  
  .wcpe-container {
    padding: 8px;
    max-width: 100%;
    position: relative;
  }
  
  .wcpe-search {
    position: relative !important; /* إزالة sticky في الموبايل */
    margin: 0 0 12px 0 !important;
    padding: 10px !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
    background-color: var(--theme-palette-color-8) !important;
    width: 100% !important;
  }
  
  .wcpe-header {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 12px;
  }
  
  .wcpe-title {
    font-size: 18px;
  }
  
  .wcpe-filters {
    gap: 8px;
  }
  
  .wcpe-filter-block {
    padding: 8px;
  }
  
  .wcpe-filter-title {
    font-size: 12px;
    margin-bottom: 6px;
  }
  
  .wcpe-chip, .wcpe-brand {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  .wcpe-products.grid {
    gap: 8px;
  }
  
  .wcpe-card .body {
    padding: 6px;
    gap: 4px;
  }
  
  .wcpe-card .title {
    font-size: 12px;
    line-height: 1.3;
    max-height: 2.6em;
  }
  
  .wcpe-card .price {
    font-size: 12px;
  }
  
  .wcpe-card .qty {
    width: 120px;
  }
  
  .wcpe-card .qty button { 
    width: 28px;
    height: 28px; 
    font-size: 14px;
  }
  
  .wcpe-card .qty input { 
    height: 28px; 
    font-size: 11px;
  }
  
  .wcpe-card .buy .btn, .wcpe-card .buy a.btn { 
    padding: 6px 8px; 
    font-size: 10px;
    width: 120px;
  }
  
  .wcpe-row .row-actions .btn { 
    padding: 8px 10px; 
    font-size: 12px; 
  }
  
  .wcpe-row .qty button { height: 32px; }
  .wcpe-row .qty input { height: 32px; }
  
  /* List view title full lines on mobile */
  .wcpe-row .row-title { 
    display: block; 
    max-height: none;
    overflow: visible; 
    text-overflow: initial;
    white-space: normal; 
  }
}

/* Loader */
.wcpe-sentinel { height: 1px; }
.wcpe-loadmore { 
  display: flex; 
  justify-content: center; 
  margin: 12px 0; 
}

.wcpe-loadmore .btn { 
  border: 2px solid var(--wcpe-border); 
  padding: 10px 12px; 
  border-radius: 10px; 
  background: var(--wcpe-card); 
  color: var(--wcpe-text); 
  cursor: pointer; 
  font-weight: 800; 
}

/* Toast */
.wcpe-toast { 
  position: fixed; 
  bottom: 16px; 
  left: 50%; 
  transform: translateX(-50%); 
  background: rgba(17,24,39,.95); 
  color: #fff; 
  padding: 10px 14px; 
  border-radius: 10px; 
  z-index: 9999; 
  font-weight: 700; 
}

/* إخفاء في صفحات معينة */
.woocommerce-cart .wcpe,
.woocommerce-checkout .wcpe,
.woocommerce-account .wcpe {
  display: none !important;
}
