/* ==========================================================================
   NTech Computers — search page
   Scoped to `.search-page` so nothing here leaks into other pages.
   ========================================================================== */

.search-page {
  --rail-width: 268px;
  --toolbar-h: 68px;
}

/* -------------------------------- Hero ---------------------------------- */
.search-hero {
  position: relative;
  padding-block: 30px 26px;
  background:
    radial-gradient(900px 320px at 82% -30%, #e6efff 0%, rgba(230, 239, 255, 0) 70%),
    linear-gradient(180deg, #f6faff 0%, #ffffff 100%);
  border-bottom: 1px solid var(--line-2);
  overflow: hidden;
}
.search-hero::after {
  content: '';
  position: absolute;
  right: -80px;
  top: -120px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(47, 107, 243, .12), transparent 68%);
  pointer-events: none;
}

.search-hero__inner { position: relative; z-index: 1; }

.search-hero h1 {
  font-size: clamp(23px, 3.6vw, 33px);
  font-weight: 800;
  letter-spacing: -.03em;
  margin-top: 4px;
}
.search-hero p.lead {
  color: var(--muted);
  font-size: 14px;
  margin-top: 7px;
  max-width: 560px;
}

/* search field ---------------------------------------------------------- */
.search-hero__form {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin-top: 20px;
  max-width: 720px;
}

.search-hero__field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.search-hero__field > i {
  position: absolute;
  left: 17px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-2);
  font-size: 16px;
  pointer-events: none;
}
.search-hero__field input {
  width: 100%;
  height: 52px;
  padding: 0 44px 0 46px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-size: 14.5px;
  box-shadow: 0 2px 10px rgba(16, 24, 40, .04);
  transition: .2s ease;
}
.search-hero__field input::placeholder { color: var(--muted-2); }
.search-hero__field input:focus {
  outline: none;
  border-color: var(--blue-500);
  box-shadow: 0 0 0 4px rgba(47, 107, 243, .12);
}
.search-hero__clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  display: none;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: var(--canvas-2);
  color: var(--muted);
  font-size: 13px;
}
.search-hero__clear:hover { background: #fdecec; color: var(--red); }
.search-hero__field.has-value .search-hero__clear { display: grid; }

.search-hero__form .btn {
  flex: 0 0 auto;
  height: 52px;
  min-width: 112px;
  border-radius: 14px;
  font-size: 14px;
  padding-inline: 22px;
}

/* popular searches ------------------------------------------------------ */
.search-suggest {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.search-suggest__label { font-weight: 600; }
.search-suggest button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--ink-2);
  transition: .16s ease;
  min-height: 30px;
}
.search-suggest button:hover {
  border-color: var(--blue-200);
  color: var(--blue-600);
  background: var(--blue-50);
}

/* ------------------------------- Layout --------------------------------- */
.search-layout {
  display: grid;
  grid-template-columns: var(--rail-width) minmax(0, 1fr);
  gap: 26px;
  align-items: start;
  padding-block: 24px 60px;
}

.search-results { min-width: 0; }

/* ------------------------------- Sidebar -------------------------------- */
.search-filters {
  position: sticky;
  top: calc(var(--header-h) + 14px);
  max-height: calc(100vh - var(--header-h) - 34px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 2px;
  scrollbar-width: thin;
}
.search-filters::-webkit-scrollbar { width: 5px; }
.search-filters::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }

.search-filters__head { display: none; }
.search-filters__apply { display: none; }
.search-filters__footer { display: none; }

.filter-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.filter-card h2 {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.filter-card h2 .filter-reset {
  font-size: 10px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--blue-600);
  background: none;
  border: 0;
  font-weight: 600;
  display: none;
}
.filter-card h2 .filter-reset.is-on { display: inline; }

.filter-list li { border-bottom: 1px solid var(--line-2); }
.filter-list li:last-child { border-bottom: 0; }

.filter-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 8px 0;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--ink-2);
  text-align: left;
  transition: .15s ease;
  border-radius: 6px;
}
.filter-link span:first-child { display: inline-flex; align-items: center; gap: 8px; }
.filter-link i { color: var(--muted-2); font-size: 14px; }
.filter-link:hover { color: var(--blue-600); }
.filter-link.is-active { color: var(--blue-600); font-weight: 700; }
.filter-link.is-active i { color: var(--blue-500); }
.filter-count {
  font-size: 10.5px;
  color: var(--muted-2);
  background: var(--canvas-2);
  padding: 2px 7px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}

/* price + presets */
.price-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.price-presets button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 11.5px;
  color: var(--ink-2);
  min-height: 36px;
  transition: .15s ease;
}
.price-presets button:hover { border-color: var(--blue-200); color: var(--blue-600); }
.price-presets button.is-active {
  background: var(--blue-50);
  border-color: var(--blue-300, #a8c4ff);
  color: var(--blue-700);
  font-weight: 600;
}

/* ------------------------------ Toolbar --------------------------------- */
.results-toolbar {
  position: sticky;
  top: var(--header-h);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--line);
  border-radius: 14px;
  flex-wrap: wrap;
}

.results-toolbar__left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
}
.results-toolbar h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.results-count {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}
.results-toolbar__right { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* filters button (mobile only) */
.filter-toggle {
  display: none;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  position: relative;
}
.filter-toggle:hover { border-color: var(--blue-200); color: var(--blue-600); }
.filter-toggle__badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--blue-500);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}
.filter-toggle__badge[hidden] { display: none; }

/* sort + view */
.sort-select {
  height: 38px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 12.5px;
  color: var(--ink-2);
  appearance: none;
  cursor: pointer;
}
.sort-wrap { position: relative; display: inline-flex; align-items: center; }
.sort-wrap i {
  position: absolute;
  right: 11px;
  font-size: 10px;
  color: var(--muted-2);
  pointer-events: none;
}
.sort-select:focus { outline: none; border-color: var(--blue-200); box-shadow: 0 0 0 3px var(--blue-50); }

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.view-toggle button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  background: #fff;
  color: var(--muted);
  font-size: 15px;
  transition: .15s ease;
}
.view-toggle button.is-active { background: var(--blue-500); color: #fff; }
.view-toggle button:not(.is-active):hover { background: var(--blue-50); color: var(--blue-600); }

/* ------------------------------- Chips ---------------------------------- */
.active-filters {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  min-height: 0;
}
.active-filters:not(:empty) {
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--line);
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 11px;
  border: 1px solid var(--blue-100);
  border-radius: 999px;
  background: var(--blue-50);
  color: var(--blue-700);
  font-size: 12px;
  font-weight: 600;
  transition: .15s ease;
}
.filter-chip:hover { border-color: var(--blue-300, #a8c4ff); }
.filter-chip i { font-size: 11px; opacity: .7; }
.filter-chip--clear {
  background: #fff;
  border-color: var(--line);
  color: var(--muted);
}
.filter-chip--clear:hover { color: var(--red); border-color: #fbd5d5; background: #fff7f7; }

/* -------------------------------- Grid ---------------------------------- */
.search-page .results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

/* list mode */
.search-page .results-grid.is-list { grid-template-columns: 1fr; gap: 12px; }
.search-page .results-grid.is-list .product-card {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  align-items: stretch;
}
.search-page .results-grid.is-list .product-media { aspect-ratio: auto; min-height: 150px; }
.search-page .results-grid.is-list .product-body { padding: 16px 18px; justify-content: center; }
.search-page .results-grid.is-list .product-name { font-size: 15px; -webkit-line-clamp: 2; }

/* ------------------------------ Skeletons ------------------------------- */
.skeleton-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
}
.skeleton-media { aspect-ratio: 1/1; background: #eef2f8; }
.skeleton-body { padding: 14px 15px 16px; display: flex; flex-direction: column; gap: 9px; }
.skeleton-line { height: 11px; border-radius: 6px; background: #eef2f8; }
.skeleton-line.w60 { width: 60%; }
.skeleton-line.w40 { width: 40%; }
.skeleton-line.w80 { width: 80%; }
.skeleton-media,
.skeleton-line {
  background-image: linear-gradient(100deg, #eef2f8 30%, #f7f9fd 50%, #eef2f8 70%);
  background-size: 220% 100%;
  animation: skeletonShimmer 1.3s ease-in-out infinite;
}
@keyframes skeletonShimmer {
  from { background-position: 180% 0; }
  to { background-position: -40% 0; }
}

/* ------------------------------- Empty ---------------------------------- */
.search-page .empty-state {
  grid-column: 1 / -1;
  padding: 56px 22px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background:
    radial-gradient(400px 200px at 50% 0%, #f2f7ff, transparent 70%),
    #fbfcfe;
  text-align: center;
}
.search-page .empty-state h2 { font-size: 18px; margin-bottom: 6px; }
.search-page .empty-state p { font-size: 13px; color: var(--muted); max-width: 420px; margin: 0 auto 16px; }
.empty-suggest { display: flex; gap: 7px; justify-content: center; flex-wrap: wrap; margin-bottom: 16px; }
.empty-suggest button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 12px;
  color: var(--ink-2);
  min-height: 34px;
}
.empty-suggest button:hover { border-color: var(--blue-200); color: var(--blue-600); }

/* ------------------------------ Pagination ------------------------------ */
.search-page .pagination { margin-top: 26px; }
.search-page .page-btn {
  min-width: 38px;
  height: 38px;
  border-radius: 10px;
  font-weight: 600;
}
.search-page .page-btn.is-active { box-shadow: 0 6px 14px rgba(47, 107, 243, .28); }

.pagination-summary { text-align: center; font-size: 12px; color: var(--muted-2); margin-top: 10px; }

/* ------------------------------- Scrim ---------------------------------- */
.filter-scrim {
  position: fixed;
  inset: 0;
  z-index: 290;
  background: rgba(8, 14, 26, .48);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .24s ease;
}
.filter-scrim.is-open { opacity: 1; pointer-events: auto; }

/* ----------------------------- Breakpoints ------------------------------ */
@media (min-width: 1400px) {
  .search-page .results-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* 3 columns from 768px up; two only once it is a phone */
@media (max-width: 767px) {
  .search-page .results-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .search-layout { grid-template-columns: minmax(0, 1fr); padding-block: 18px 50px; }
  .filter-toggle { display: inline-flex; }

  /* sidebar becomes a drawer */
  .search-filters {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(88vw, 360px);
    max-height: none;
    z-index: 300;
    background: #fff;
    padding: 16px 16px 104px;
    transform: translateX(-102%);
    transition: transform .28s cubic-bezier(.2, .8, .2, 1);
    box-shadow: 24px 0 60px rgba(8, 14, 26, .22);
    overflow-y: auto;
  }
  .search-filters.is-open { transform: translateX(0); }

  .search-filters__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: -16px;
    background: #fff;
    padding-top: 6px;
    z-index: 2;
  }
  .search-filters__head h2 { font-size: 15px; }
  .search-filters__close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--muted);
  }
  /* fixed footer pinned to the drawer (the drawer is a transformed box,
     so position:fixed is relative to it rather than the viewport) */
  .search-filters__footer {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid var(--line);
    box-shadow: 0 -10px 26px rgba(16, 24, 40, .1);
    z-index: 3;
  }
  .search-filters__footer .search-filters__apply {
    display: flex;
    width: 100%;
    min-height: 46px;
    border-radius: 12px;
    font-size: 14px;
    margin: 0;
  }

  .results-toolbar { top: auto; position: static; }
}

@media (max-width: 640px) {
  .search-hero { padding-block: 22px 20px; }
  .search-hero__form { flex-wrap: wrap; }
  .search-hero__field { flex: 1 1 100%; }
  .search-hero__form .btn {
    flex: 1 1 100%;
    height: 46px;
    min-width: 0;
  }
  .search-hero__field input { height: 48px; font-size: 16px; }
  .search-suggest { display: none; }

  .results-toolbar {
    padding: 10px 12px;
    gap: 10px;
    display: flex;
    flex-wrap: wrap;
  }
  .filter-toggle { order: 1; flex: 0 0 auto; }
  .results-toolbar__right { order: 2; flex: 1 1 auto; justify-content: flex-end; gap: 8px; }
  .results-toolbar__left {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 2px;
  }
  .results-toolbar h2 { font-size: 15px; }
  .sort-wrap { flex: 1 1 auto; min-width: 0; }
  .sort-select { width: 100%; }

  .search-page .results-grid { gap: 12px; }
  .search-page .results-grid.is-list .product-card { grid-template-columns: 120px minmax(0, 1fr); }
  .search-page .results-grid.is-list .product-body { padding: 12px 14px; }
}

@media (max-width: 359px) {
  .search-page .results-grid { grid-template-columns: minmax(0, 1fr); }
}
