/* ═══════════════════════════════
   SEARCH POPUP — تصميم عصري وأنيق
═══════════════════════════════ */

.search-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background-color: rgba(0, 0, 0, 0.4); /* لون أخف قليلاً */
  backdrop-filter: blur(8px); /* تأثير الزجاج العصري */
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 8vh; /* نسبة مئوية لتجاوب أفضل مع الشاشات */
  padding-left: 16px;
  padding-right: 16px;
}

.search-popup-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.search-popup {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 20px; /* حواف دائرية ناعمة */
  width: 100%;
  max-width: 560px;
  overflow: hidden;
  /* ظل متعدد الطبقات لمظهر أكثر واقعية */
  box-shadow: 0 24px 48px -12px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.06);
  transform: translateY(-20px) scale(0.98);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.4s ease;
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}

.search-popup-overlay.active .search-popup {
  transform: translateY(0) scale(1);
}

/* شريط البحث العلوي */
.search-popup-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  background-color: var(--color-bg-secondary);
}

.search-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: var(--color-block);
  border-radius: 12px;
  padding: 0 14px;
  height: 46px; /* زيادة بسيطة في الارتفاع لراحة العين */
  min-width: 0;
  border: 1px solid transparent;
  transition: all 0.25s ease;
}

/* تأثير التحديد (Focus) العصري */
.search-input-wrap:focus-within {
  border-color: var(--color-primary);
  background-color: var(--color-bg-secondary);
  box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb, 0, 0, 0), 0.08); /* هالة خفيفة */
}

.search-input-wrap > svg {
  width: 18px;
  height: 18px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
  transition: stroke 0.2s ease;
}

.search-input-wrap:focus-within > svg {
  stroke: var(--color-primary);
}

.search-input-wrap input[type="search"] {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--color-text);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  padding: 0;
  width: 100%;
  box-shadow: none;
  direction: rtl;
  -webkit-appearance: none;
}

.search-input-wrap input[type="search"]::placeholder {
  color: var(--color-text-muted);
  font-weight: 500;
}

.search-input-wrap input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.search-cancel-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.search-cancel-btn:hover {
  color: var(--color-heading);
  background-color: var(--color-block);
}

/* جسم البحث */
.search-popup-body {
  overflow-y: auto;
  flex: 1;
  overscroll-behavior: contain;
  padding-bottom: 8px;
}

/* شريط التمرير الأنيق (Scrollbar) */
.search-popup-body::-webkit-scrollbar {
  width: 6px;
}
.search-popup-body::-webkit-scrollbar-track {
  background: transparent;
}
.search-popup-body::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 10px;
}
.search-popup-body::-webkit-scrollbar-thumb:hover {
  background-color: var(--color-text-muted);
}

/* الحالة الفارغة (mascot) */
.search-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 20px;
}

.search-mascot {
  width: 120px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-mascot-svg path{
  width: 100%;
  height: 100%;
  fill: var(--color-primary); /* غيّر اللون حسب ثيمك */
	transition: fill 0.3s ease;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.2));
  animation: float 3s ease-in-out infinite;
  transform-origin: center;
}

/* حركة خفيفة */
.search-mascot-svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.15));
  transform-origin: center;
  animation: mascotFloat 4s ease-in-out infinite;
}

/* حركة طفو ناعمة */
@keyframes mascotFloat {
  0%, 100% {
    transform: translateY(0) scale(1);
  }
  50% {
    transform: translateY(-6px) scale(1.03);
  }
}

/* تفاعل hover أقوى */
.search-mascot:hover .search-mascot-svg {
  animation: mascotPop 0.5s ease forwards;
}

@keyframes mascotPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.12) rotate(-2deg); }
  100% { transform: scale(1.05); }
}

/* تأثير عند hover */
.search-mascot:hover .search-mascot-svg {
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.08) rotate(-2deg); }
  100% { transform: scale(1); }
}

.search-empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-heading);
  margin: 0;
}

.search-empty-subtitle {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin: 0;
  text-align: center;
  line-height: 1.5;
}

/* تحميل */
.search-loading {
  display: none;
  justify-content: center;
  padding: 40px;
}

.search-loading.active { display: flex; }

.search-spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* لا توجد نتائج */
.search-no-results {
  text-align: center;
  color: var(--color-text-muted);
  padding: 40px 20px;
  font-size: 0.9rem;
  display: none;
}

.search-no-results.show { display: block; }

/* قائمة النتائج */
.search-results-list {
  display: none;
  flex-direction: column;
  padding: 8px; /* مساحة صغيرة حول النتائج */
}

.search-results-list.has-results { display: flex; }

.search-results-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 12px;
  margin-bottom: 4px;
}

/* كارد نتيجة بحث واحدة */
.search-result-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  margin-bottom: 4px;
  text-decoration: none;
  color: var(--color-text);
  border-radius: 12px; /* حواف دائرية لكل نتيجة */
  transition: all 0.2s ease;
  background-color: transparent;
}

.search-result-item:hover {
  background-color: var(--color-block);
  transform: translateX(-4px); /* حركة خفيفة لليسار (RTL) عند التمرير */
}

.search-result-item:visited { color: var(--color-text); }

/* صورة المنتج */
.search-result-thumb,
.search-result-thumb-ph {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  flex-shrink: 0;
}

.search-result-thumb {
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.search-result-thumb-ph {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-result-thumb-ph svg {
  width: 20px;
  height: 20px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 1.5;
}

/* معلومات المنتج */
.search-result-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-result-name {
  font-weight: 600;
  color: var(--color-heading);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  transition: color 0.2s ease;
}

.search-result-item:hover .search-result-name {
  color: var(--color-primary); /* تغيير لون النص عند التمرير */
}

/* سهم للتنقل */
.search-result-arrow {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
  transform: rotate(180deg);
  transition: stroke 0.2s ease, transform 0.2s ease;
}

.search-result-item:hover .search-result-arrow {
  stroke: var(--color-primary);
  transform: rotate(180deg) translateX(-4px); /* حركة السهم مع التمرير */
}

/* زر عرض كل النتائج */
.search-view-all {
  display: none; /* يتم تغييره عبر الجافاسكربت إلى block أو flex */
  text-align: center;
  padding: 14px 16px;
  margin: 0 8px 8px;
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 12px;
  background-color: var(--color-block);
  transition: all 0.2s ease;
}

.search-view-all:hover {
  filter: brightness(0.95);
  transform: translateY(-2px);
}