/* ==========================================================================
   12. البحث — طبقة بنتائج فورية
   ========================================================================== */

.ae-search {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--ae-4);
}

.ae-search[hidden] {
  display: none;
}

.ae-search__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(44, 26, 36, 0.55);
}

.ae-search__panel {
  position: relative;
  width: min(560px, 100%);
  margin-top: min(12vh, 90px);
  background: var(--ae-surface);
  border-radius: var(--ae-r-lg);
  box-shadow: var(--ae-shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(70vh, 560px);
}

@media (max-width: 575px) {
  .ae-search {
    padding: 0;
  }

  .ae-search__panel {
    margin-top: 0;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }
}

/* شريط الإدخال */
.ae-search__bar {
  display: flex;
  align-items: center;
  gap: var(--ae-2);
  padding: var(--ae-3) var(--ae-4);
  border-bottom: 1px solid var(--ae-line);
  background: var(--ae-surface);
}

.ae-search__icon {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--ae-mauve);
}

.ae-search__icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.ae-search__input {
  flex: 1 1 auto;
  min-height: 46px;
  border: 0 !important;
  background: none;
  font-family: var(--ae-font);
  font-size: var(--ae-fs-base); /* 16px يمنع التكبير على آيفون */
  color: var(--ae-ink);
  padding: 0;
  box-shadow: none !important;
}

.ae-search__input:focus {
  outline: none;
  box-shadow: none !important;
}

.ae-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.ae-search__close {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--ae-pink-050);
  color: var(--ae-plum);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ae-search__close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* النتائج */
.ae-search__results {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--ae-2);
  -webkit-overflow-scrolling: touch;
}

.ae-search__state {
  margin: 0;
  padding: var(--ae-6) var(--ae-4);
  text-align: center;
  font-size: var(--ae-fs-sm);
  color: var(--ae-ink-muted);
}

.ae-search__item {
  display: flex;
  align-items: center;
  gap: var(--ae-3);
  padding: var(--ae-2);
  border-radius: var(--ae-r);
  color: var(--ae-ink);
  transition: background var(--ae-t-fast);
}

.ae-search__item img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--ae-r-sm);
  flex: 0 0 auto;
  background: var(--ae-surface-2);
}

.ae-search__item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ae-search__item-body strong {
  font-size: var(--ae-fs-sm);
  font-weight: var(--ae-fw-semi);
  color: var(--ae-plum);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.ae-search__price {
  font-size: var(--ae-fs-sm);
  font-weight: var(--ae-fw-bold);
  color: var(--ae-plum-900);
  direction: ltr;
  text-align: start;
}

.ae-search__all {
  display: block;
  margin: var(--ae-2);
  padding: var(--ae-3);
  text-align: center;
  border-radius: var(--ae-r-pill);
  background: var(--ae-pink-100);
  color: var(--ae-plum);
  font-size: var(--ae-fs-sm);
  font-weight: var(--ae-fw-semi);
}

@media (hover: hover) and (pointer: fine) {
  .ae-search__item:hover { background: var(--ae-pink-050); }
  .ae-search__all:hover { background: var(--ae-pink-200); }
  .ae-search__close:hover { background: var(--ae-pink-200); }
}

/* ما نخلي الصفحة تتحرك ورا الطبقة */
body.ae-search-open {
  overflow: hidden;
}

/* زر البحث بالهيدر ياخذ نفس شكل باقي الأيقونات */
.site-tools > a.ae-search-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--ae-tap);
  height: var(--ae-tap);
  border-radius: 50%;
  background: var(--ae-surface);
  border: 1px solid var(--ae-line);
  color: var(--ae-plum);
}
