/**
 * AL Search — RTL results overlay.
 * Sits on top of the existing Woodmart search bar; does not restyle the bar.
 * Animates only opacity/transform (compositor-friendly).
 */

.als-results {
  --als-surface: #ffffff;
  --als-text: #1a1a1a;
  --als-muted: #6b7280;
  --als-line: #ececec;
  /* AUDIOLINE ORANGE — bind to the theme's own primary so it always matches. */
  --als-accent: var(--wd-primary-color, #f47521);
  --als-accent-hover: var(--wd-link-color, #f4853a);
  --als-accent-ink: #ffffff;
  --als-radius: 12px;
  --als-shadow: 0 12px 32px rgba(0, 0, 0, 0.14);
  --als-row-gap: 2px;

  position: absolute;
  inset-inline-start: 0;
  inset-inline-end: 0;
  top: calc(100% + 6px);
  z-index: 100000;

  direction: rtl;
  text-align: right;
  background: var(--als-surface);
  color: var(--als-text);
  border: 1px solid var(--als-line);
  border-radius: var(--als-radius);
  box-shadow: var(--als-shadow);
  overflow: hidden;

  max-height: min(70vh, 560px);
  overflow-y: auto;
  overscroll-behavior: contain;

  transform-origin: top center;
  animation: als-pop 140ms cubic-bezier(0.16, 1, 0.3, 1);
}

.als-results[hidden] { display: none; }

@keyframes als-pop {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.als-list { display: flex; flex-direction: column; gap: var(--als-row-gap); padding: 6px; }

.als-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: 10px;
  transition: background-color 150ms ease;
}

.als-card:hover,
.als-card.als-active { background: #f6f7f9; }

.als-card-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.als-thumb {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  background: #f2f2f2;
  display: grid;
  place-items: center;
}
.als-thumb img { width: 72px; height: 72px; object-fit: contain; display: block; }

.als-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.als-title {
  font-size: 1rem;
  line-height: 1.4;
  font-weight: 600;
  color: var(--als-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.als-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.als-price { font-size: 1rem; font-weight: 700; color: var(--als-accent); }
.als-price del { color: var(--als-muted); font-weight: 400; margin-inline-start: 4px; }
.als-price ins { text-decoration: none; }
.als-rating { font-size: 0.78rem; color: #f5a623; }

.als-badges { display: flex; gap: 6px; margin-top: 1px; }
.als-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  line-height: 1.6;
}
.als-badge-sale { background: var(--als-accent); color: var(--als-accent-ink); }
.als-badge-oos { background: #eceef1; color: var(--als-muted); }

/* Button rules use !important to beat theme/Elementor <button> styles bleeding in. */
.als-results .als-atc {
  flex: 0 0 auto;
  border: 2px solid transparent !important;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.2;
  padding: 10px 16px !important;
  border-radius: 999px !important;             /* fully rounded corners */
  background: var(--als-accent) !important;     /* AUDIOLINE ORANGE */
  color: var(--als-accent-ink) !important;
  box-shadow: none !important;
  transition: transform 120ms ease, opacity 150ms ease, background-color 150ms ease, color 150ms ease;
  white-space: nowrap;
}
.als-results .als-atc:hover { background: var(--als-accent-hover) !important; transform: translateY(-1px); }
.als-results .als-atc:active { transform: translateY(0); }

/* Secondary state (out of stock -> view, or configurable -> choose options):
   on-brand orange outline instead of the old dark button. */
.als-results .als-atc.als-atc-opts {
  background: transparent !important;
  color: var(--als-accent) !important;
  border-color: var(--als-accent) !important;
}
.als-results .als-atc.als-atc-opts:hover {
  background: var(--als-accent) !important;
  color: var(--als-accent-ink) !important;
}

.als-results .als-atc.als-loading { opacity: 0.6; pointer-events: none; }
.als-results .als-atc.als-added {
  background: #1a8917 !important;
  border-color: #1a8917 !important;
  color: #fff !important;
}

.als-all {
  display: block;
  text-align: center;
  padding: 12px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--als-text);
  text-decoration: none;
  border-top: 1px solid var(--als-line);
  background: #fbfbfc;
  position: sticky;
  bottom: 0;
}
.als-all:hover { color: var(--als-accent); }

.als-empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--als-muted);
  font-size: 0.9rem;
}

/* Pre-panel: recent searches (history) + suggestions, shown before typing. */
.als-prepanel { padding: 12px 14px; }
.als-section + .als-section { margin-top: 14px; }
.als-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.als-section-title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--als-muted);
  text-transform: uppercase;
}
.als-clear-history {
  border: 0;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--als-accent);
  padding: 2px 4px;
}
.als-clear-history:hover { text-decoration: underline; }

.als-chips { display: flex; flex-wrap: wrap; gap: 8px; }
/* !important so theme/Elementor <button> styles can't square the chips. */
.als-results .als-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--als-line) !important;
  background: #f6f7f9 !important;
  color: var(--als-text) !important;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.3;
  padding: 8px 14px !important;
  border-radius: 999px !important;   /* fully rounded, matches the buttons */
  box-shadow: none !important;
  transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.als-results .als-chip:hover {
  background: var(--als-accent) !important;
  border-color: var(--als-accent) !important;
  color: var(--als-accent-ink) !important;
}
.als-chip-ico { font-size: 0.9em; opacity: 0.6; }
.als-results .als-chip:hover .als-chip-ico { opacity: 1; }

/* Defensive: hide the theme's own AJAX results if it is still active. */
.als-results:not([hidden]) ~ .wd-dropdown-results,
.wd-search-form .als-results:not([hidden]) ~ .autocomplete-suggestions {
  display: none !important;
}

/* Mobile full-screen search: keep Woodmart's panel as the container, but
   suppress Woodmart's own suggestions / history / AJAX results so only our
   overlay shows (otherwise the theme's "popular searches" stack under ours). */
[class*="wd-search-full-screen"] .wd-search-suggestions,
[class*="wd-search-full-screen"] .wd-search-history,
[class*="wd-search-full-screen"] .wd-search-requests,
[class*="wd-search-full-screen"] .wd-dropdown-results,
[class*="wd-search-full-screen"] .wd-search-results {
  display: none !important;
}

/* Our overlay when it renders inside the full-screen panel: flow in-panel. */
.als-results.als-inpanel {
  position: static;
  margin: 16px auto 0;
  max-width: 640px;
  max-height: none;
  box-shadow: none;
  animation: none;
}

/* ---- Mobile: comfortable sizes + big tap targets ---- */
@media (max-width: 600px) {
  .als-results { --als-radius: 14px; max-height: min(80vh, 640px); }

  .als-card {
    flex-wrap: wrap;
    align-items: center;
    row-gap: 10px;
    padding: 12px;
  }
  .als-card-link { flex: 1 1 auto; gap: 14px; }
  .als-thumb, .als-thumb img { width: 64px; height: 64px; }
  .als-title { font-size: 0.95rem; }
  .als-price { font-size: 1rem; }

  /* Full-width, thumb-friendly action button under each result. */
  .als-results .als-atc {
    flex: 1 1 100%;
    order: 3;
    padding: 13px 16px !important;
    font-size: 0.92rem;
    text-align: center;
  }

  .als-prepanel { padding: 14px; }
  .als-chips { gap: 10px; }
  .als-results .als-chip { padding: 11px 16px !important; font-size: 0.94rem; }
  .als-all { padding: 16px; font-size: 0.95rem; }
}
