/* ── Global search overlay ─────────────────────────────────────────────────────────────────
   Brand tokens only (see mawasem.css :root). Laid out with logical properties so RTL and LTR
   both read correctly. Desktop: panel anchored under the header. Mobile: full-screen takeover. */

.mw-search[hidden] { display: none }

.mw-search {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.mw-search__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 42, 27, .45);
  animation: mwSearchFade .15s ease-out;
}

.mw-search__panel {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  margin-inline: auto;
  max-width: 720px;
  background: var(--mw-white);
  border-radius: 0 0 var(--mw-radius) var(--mw-radius);
  box-shadow: 0 12px 40px rgba(39, 70, 81, .18);
  display: flex;
  flex-direction: column;
  max-height: 86vh;
  animation: mwSearchIn .18s ease-out;
}

@keyframes mwSearchFade { from { opacity: 0 } to { opacity: 1 } }
@keyframes mwSearchIn   { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }

@media (prefers-reduced-motion: reduce) {
  .mw-search__backdrop, .mw-search__panel { animation: none }
}

.mw-search__sronly {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ── Search bar ── */
.mw-search__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-block-end: 1.5px solid var(--mw-border);
  flex-shrink: 0;
}
.mw-search__bar > i { color: var(--mw-text-mute); font-size: .95rem; flex-shrink: 0 }

.mw-search__input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: 'Cairo', sans-serif;
  font-size: .95rem;
  font-weight: 600;
  color: var(--mw-text);
  min-width: 0;
}
.mw-search__input::placeholder { color: var(--mw-text-mute); font-weight: 500 }
.mw-search__input::-webkit-search-cancel-button { display: none }

.mw-search__close {
  flex-shrink: 0;
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--mw-border);
  border-radius: 50%;
  background: var(--mw-white);
  color: var(--mw-text-sec);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.mw-search__close:hover { border-color: var(--mw-accent); color: var(--mw-accent) }

/* ── Body ── */
.mw-search__body { overflow-y: auto; padding: 8px 0 12px }

.mw-search__block { padding: 10px 16px }
.mw-search__blockhead {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .76rem; font-weight: 800; color: var(--mw-primary);
  margin-block-end: 8px;
}
.mw-search__clear {
  border: none; background: none; cursor: pointer; padding: 0;
  font-family: 'Cairo', sans-serif; font-size: .72rem; font-weight: 700;
  color: var(--mw-text-mute);
}
.mw-search__clear:hover { color: var(--mw-accent) }

/* Recent searches */
.mw-search__recents { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px }
.mw-search__recent {
  display: flex; align-items: center; gap: 8px;
  border-radius: 10px;
  transition: background .15s;
}
.mw-search__recent:hover { background: var(--mw-bg) }
.mw-search__recentgo {
  flex: 1; text-align: start;
  display: flex; align-items: center; gap: 8px;
  border: none; background: none; cursor: pointer;
  padding: 9px 10px;
  font-family: 'Cairo', sans-serif; font-size: .84rem; font-weight: 600;
  color: var(--mw-text);
}
.mw-search__recentgo i { color: var(--mw-text-mute); font-size: .75rem }
.mw-search__recentdel {
  border: none; background: none; cursor: pointer;
  padding: 8px 10px; color: var(--mw-text-mute); font-size: .75rem;
}
.mw-search__recentdel:hover { color: var(--mw-accent) }

/* Occasion chips */
.mw-search__chips { display: flex; flex-wrap: wrap; gap: 8px }
.mw-search__chip {
  display: inline-flex; align-items: center;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: .76rem; font-weight: 700;
  background: var(--mw-white);
  color: var(--mw-text-sec);
  border: 1.5px solid var(--mw-border);
  text-decoration: none;
  transition: .2s;
}
.mw-search__chip:hover { background: var(--mw-primary); color: #fff; border-color: var(--mw-primary) }

/* ── Results ── */
.mw-search__results { padding: 6px 8px }
.mw-search__row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--mw-text);
  transition: background .12s;
}
.mw-search__row:hover,
.mw-search__row.is-active { background: var(--mw-bg) }

.mw-search__thumb {
  width: 48px; height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: var(--mw-bg);
  flex-shrink: 0;
}
.mw-search__meta { min-width: 0; display: flex; flex-direction: column; gap: 2px }
.mw-search__name {
  font-size: .84rem; font-weight: 700; color: var(--mw-text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mw-search__price { font-size: .8rem; font-weight: 800; color: var(--mw-accent) }

.mw-search__state { padding: 22px 16px; text-align: center; color: var(--mw-text-mute); font-size: .84rem }
.mw-search__nores { margin-block-end: 12px }
.mw-search__state .mw-search__chips { justify-content: center }

.mw-search__all {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin: 6px 16px 0;
  padding: 11px 14px;
  border-radius: 12px;
  background: var(--mw-btn-bg);
  color: var(--mw-btn-text);
  font-size: .84rem; font-weight: 800;
  text-decoration: none;
}
.mw-search__all:hover { filter: brightness(.97) }
/* The arrow points "forward"; under LTR that is the other way round. */
[dir="ltr"] .mw-search__all i { transform: scaleX(-1) }

/* ── Mobile: full-screen takeover ── */
@media (max-width: 640px) {
  .mw-search__panel {
    inset: 0;
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 0;
  }
  .mw-search__body { flex: 1 }
}
