/* Shopaccino TypesenseSearch: dropdown + results page. Every rule is scoped to tsx-* classes.
   Colours follow the theme where Bootstrap 5 variables exist; override the --tsx-* variables to restyle. */
:root {
  --tsx-accent: var(--bs-primary, #111827);
  --tsx-text: #1f2937;
  --tsx-muted: #6b7280;
  --tsx-line: #e5e7eb;
  --tsx-soft: #f3f4f6;
  --tsx-hover: #f5f6f8;
  --tsx-mark: #fff1b8;
  --tsx-sale: #c0392b;
  --tsx-radius: 10px;
  --tsx-shadow: 0 18px 48px rgba(15, 23, 42, .18), 0 2px 6px rgba(15, 23, 42, .08);
}

/* ---------- dropdown panel ---------- */
.tsx-panel {
  position: fixed; z-index: 1060; box-sizing: border-box; overflow-y: auto; overscroll-behavior: contain;
  background: #fff; color: var(--tsx-text); border: 1px solid var(--tsx-line); border-radius: var(--tsx-radius);
  box-shadow: var(--tsx-shadow); font-size: 14px; line-height: 1.4; text-align: left; padding: 6px 0 0;
  -webkit-font-smoothing: antialiased;
}
.tsx-panel[hidden] { display: none !important; }
.tsx-panel *, .tsx-results * { box-sizing: border-box; }
.tsx-panel.tsx-panel-mobile { border-radius: 0; border-left: 0; border-right: 0; box-shadow: 0 12px 24px rgba(15, 23, 42, .15); }
.tsx-panel::before {   /* thin loading bar */
  content: ""; position: sticky; top: -6px; display: block; height: 2px; margin: -6px 0 4px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--tsx-accent), transparent); background-size: 40% 100%;
  background-repeat: no-repeat; opacity: 0; transition: opacity .15s;
}
.tsx-panel.tsx-loading::before { opacity: 1; animation: tsx-bar 1s linear infinite; }
@keyframes tsx-bar { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.tsx-cols { display: block; }
.tsx-panel-two .tsx-cols { display: grid; grid-template-columns: minmax(220px, 38%) 1fr; }
.tsx-panel-two .tsx-col-side { border-right: 1px solid var(--tsx-line); }
.tsx-panel-mobile .tsx-cols { display: block; }
.tsx-panel-mobile .tsx-col-side { border-right: 0; }

.tsx-section { padding: 6px 0 8px; }
.tsx-section + .tsx-section { border-top: 1px solid var(--tsx-soft); }
.tsx-section-head { display: flex; justify-content: space-between; align-items: center; padding: 6px 16px 4px; }
.tsx-section-title { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--tsx-muted); }

.tsx-panel button, .tsx-results button { font: inherit; color: inherit; }
.tsx-panel a, .tsx-panel a:hover, .tsx-results a, .tsx-results a:hover { color: inherit; text-decoration: none; }
.tsx-link { background: none; border: 0; padding: 0; color: var(--tsx-accent) !important; cursor: pointer; font-size: 13px; text-decoration: underline; text-underline-offset: 2px; }

.tsx-ico { width: 16px; height: 16px; flex: 0 0 16px; fill: currentColor; color: var(--tsx-muted); }
.tsx-ico-end { margin-left: auto; opacity: 0; transform: translateX(-4px); transition: .12s; }
.tsx-item.tsx-active .tsx-ico-end, .tsx-row:hover .tsx-ico-end { opacity: 1; transform: none; }

/* chips: recent + trending */
.tsx-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 16px; }
.tsx-chips-center { justify-content: center; }
.tsx-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 6px 12px; cursor: pointer;
  background: #fff; border: 1px solid var(--tsx-line); border-radius: 999px; font-size: 13px; line-height: 1.2; white-space: nowrap;
}
.tsx-chip span { overflow: hidden; text-overflow: ellipsis; }
.tsx-chip:hover, .tsx-chip.tsx-active { background: var(--tsx-hover); border-color: #cbd5e1; }
.tsx-chip-on { background: var(--tsx-soft); border-color: transparent; font-weight: 600; }
.tsx-chip-on .tsx-x { margin-left: 4px; font-size: 15px; line-height: 1; color: var(--tsx-muted); }
.tsx-chip:disabled { cursor: default; }

/* rows: suggestions, categories, brands, products */
.tsx-row {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 7px 16px; cursor: pointer;
  background: none; border: 0; text-align: left; min-height: 40px;
}
.tsx-row:hover, .tsx-item.tsx-active { background: var(--tsx-hover); }
.tsx-row-text .tsx-row-name { flex: 1; }
.tsx-row-body { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.tsx-row-name { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tsx-row-meta { font-size: 12px; color: var(--tsx-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsx-sku { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.tsx-row-count { font-size: 12px; color: var(--tsx-muted); background: var(--tsx-soft); border-radius: 999px; padding: 1px 8px; }
.tsx-mark { background: var(--tsx-mark); color: inherit; padding: 0; border-radius: 2px; font-weight: 600; }
.tsx-price { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px; font-size: 13px; }
.tsx-price b { font-weight: 700; }
.tsx-mrp { color: var(--tsx-muted); font-size: 12px; }
.tsx-off { color: var(--tsx-sale); font-size: 12px; font-weight: 600; }
.tsx-badge-muted { font-size: 11px; color: var(--tsx-muted); background: var(--tsx-soft); border-radius: 4px; padding: 2px 6px; white-space: nowrap; }
.tsx-price-chip { margin: 6px 16px 2px; display: inline-block; font-size: 12px; font-weight: 600; background: var(--tsx-soft); border-radius: 999px; padding: 4px 10px; }

/* thumbnails */
.tsx-thumb { position: relative; display: inline-flex; align-items: center; justify-content: center; overflow: hidden; flex: 0 0 auto; background: var(--tsx-soft); color: #fff; font-weight: 700; }
.tsx-thumb img { width: 100%; height: 100%; object-fit: cover; max-width: none; display: block; }
.tsx-thumb-ph { background: hsl(var(--tsx-h, 210), 45%, 62%); }
.tsx-row-img { width: 44px; height: 44px; border-radius: 8px; font-size: 13px; }
.tsx-row-img-sq { width: 36px; height: 36px; border-radius: 6px; }
.tsx-circles { display: flex; gap: 12px; padding: 6px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.tsx-circles::-webkit-scrollbar { display: none; }
.tsx-circle { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 76px; flex: 0 0 76px; padding: 4px 0; border-radius: 8px; text-align: center; }
.tsx-circle:hover { background: var(--tsx-hover); }
.tsx-circle-img { width: 60px; height: 60px; border-radius: 50%; font-size: 16px; }
.tsx-circle-name { font-size: 12px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* product rail in the empty box */
.tsx-rail { display: grid; grid-auto-flow: column; grid-auto-columns: 132px; gap: 12px; padding: 4px 16px 8px; overflow-x: auto; scrollbar-width: thin; }

/* empty state + "view all" */
.tsx-empty { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px; text-align: center; color: var(--tsx-muted); }
.tsx-empty strong { color: var(--tsx-text); font-size: 15px; }
.tsx-empty .tsx-section { width: 100%; border: 0; }
.tsx-empty .tsx-chips { justify-content: center; }
.tsx-dym { font-size: 14px; color: var(--tsx-text); }
.tsx-dym .tsx-link { font-size: 14px; font-weight: 600; }
.tsx-all {
  position: sticky; bottom: 0; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  padding: 12px 16px; border: 0; border-top: 1px solid var(--tsx-line); background: #fff; cursor: pointer; font-weight: 600;
}
.tsx-all .tsx-ico { color: inherit; }
.tsx-all:hover, .tsx-all.tsx-active { background: var(--tsx-hover); }

/* ---------- product card (rail + results grid) ---------- */
.tsx-card { display: flex; flex-direction: column; gap: 8px; min-width: 0; border-radius: var(--tsx-radius); }
.tsx-card-compact { padding: 4px; }
.tsx-card-compact:hover, .tsx-card-compact.tsx-active { background: var(--tsx-hover); }
.tsx-card-media { position: relative; display: block; border-radius: 8px; overflow: hidden; background: var(--tsx-soft); }
.tsx-card-img { width: 100%; aspect-ratio: 1 / 1; height: auto; font-size: 22px; display: flex; }
.tsx-card:hover .tsx-card-img img { transform: scale(1.03); }
.tsx-card-img img { transition: transform .25s; }
.tsx-ribbon { position: absolute; top: 8px; left: 8px; background: var(--tsx-sale); color: #fff; font-size: 11px; font-weight: 700; border-radius: 4px; padding: 2px 6px; }
.tsx-card-badge { position: absolute; top: 8px; right: 8px; background: #fff; color: var(--tsx-text); font-size: 11px; font-weight: 600; border-radius: 4px; padding: 2px 6px; }
.tsx-card-oos { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.88); color: var(--tsx-text); font-size: 12px; font-weight: 600; text-align: center; padding: 4px; }
.tsx-card-body { display: flex; flex-direction: column; gap: 3px; padding: 0 2px; }
.tsx-card-brand { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--tsx-muted); }
.tsx-card-name { font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tsx-card-compact .tsx-card-name { font-size: 12.5px; }
.tsx-card-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 14px; }
.tsx-card-compact .tsx-card-price { font-size: 12.5px; }
.tsx-card-compact .tsx-off { display: none; }
.tsx-card-rating { font-size: 12px; color: var(--tsx-muted); }

/* ---------- results page ---------- */
.tsx-results { color: var(--tsx-text); font-size: 14px; }
.tsx-res-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.tsx-res-title h1 { font-size: 24px; line-height: 1.25; margin: 0 0 2px; word-break: break-word; }
.tsx-res-count { color: var(--tsx-muted); font-size: 13px; }
.tsx-res-tools { display: flex; gap: 8px; align-items: center; }
.tsx-sort, .tsx-filter-btn {
  height: 38px; border: 1px solid var(--tsx-line); border-radius: 8px; background: #fff; padding: 0 12px; font-size: 14px; color: var(--tsx-text);
}
.tsx-filter-btn { display: none; cursor: pointer; }
.tsx-notice { background: #fff8e1; border: 1px solid #fde68a; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.tsx-active { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.tsx-res-layout { display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start; }
.tsx-results-loading .tsx-res-main { opacity: .45; transition: opacity .15s; pointer-events: none; }

.tsx-res-layout-full { grid-template-columns: 1fr; }
.tsx-side { position: sticky; top: var(--tsx-sticky-top, 16px); max-height: calc(100vh - var(--tsx-sticky-top, 16px) - 16px); overflow-y: auto; padding-right: 4px; }
.tsx-side-head { display: none; }
.tsx-facet { border-top: 1px solid var(--tsx-line); padding: 10px 0; }
.tsx-facet summary { cursor: pointer; font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; list-style: none; display: flex; justify-content: space-between; }
.tsx-facet summary::-webkit-details-marker { display: none; }
.tsx-facet summary::after { content: "−"; color: var(--tsx-muted); }
.tsx-facet:not([open]) summary::after { content: "+"; }
.tsx-facet-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.tsx-check { display: flex !important; align-items: center; gap: 8px; padding: 4px 0; margin: 0 !important; cursor: pointer; font-weight: 400 !important; font-size: 14px; }
.tsx-check input { width: 16px; height: 16px; margin: 0 !important; accent-color: var(--tsx-accent); flex: 0 0 auto; position: static !important; opacity: 1 !important; }
.tsx-check-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tsx-check-count { color: var(--tsx-muted); font-size: 12px; }
.tsx-stock { padding: 0 0 10px; }
.tsx-more { margin-top: 6px; font-size: 13px; }
.tsx-price-form { display: flex; align-items: center; gap: 6px; margin-top: 8px; }
.tsx-price-form input { width: 0; flex: 1; height: 36px; border: 1px solid var(--tsx-line); border-radius: 6px; padding: 0 8px; font-size: 13px; }
.tsx-btn { height: 36px; padding: 0 14px; border: 0; border-radius: 6px; background: var(--tsx-accent); color: #fff !important; font-weight: 600; cursor: pointer; }
.tsx-empty .tsx-btn { margin-top: 8px; }

.tsx-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 24px 18px; }
.tsx-empty-lg { padding: 48px 16px; font-size: 15px; }
.tsx-empty-lg strong { font-size: 18px; }
.tsx-empty-lg .tsx-section-title { margin-top: 18px; }

.tsx-pager { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 6px; margin: 32px 0 8px; }
.tsx-page { min-width: 38px; height: 38px; padding: 0 10px; border: 1px solid var(--tsx-line); border-radius: 8px; background: #fff; cursor: pointer; }
.tsx-page:disabled { opacity: .4; cursor: default; }
.tsx-page-on { background: var(--tsx-accent); border-color: var(--tsx-accent); color: #fff !important; font-weight: 700; }
.tsx-gap { color: var(--tsx-muted); padding: 0 2px; }

/* loading skeleton (server-rendered before the first response) */
.tsx-skeleton-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 24px 18px; }
.tsx-skeleton-card span, .tsx-skeleton-card i { display: block; border-radius: 8px; background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 50%, #eef0f3 75%); background-size: 200% 100%; animation: tsx-shimmer 1.2s infinite; }
.tsx-skeleton-card span { aspect-ratio: 1 / 1; }
.tsx-skeleton-card i { height: 12px; margin-top: 10px; width: 80%; }
.tsx-skeleton-card i + i { width: 45%; }
@keyframes tsx-shimmer { to { background-position: -200% 0; } }

/* ---------- small screens: filters become a drawer ---------- */
@media (max-width: 991.98px) {
  .tsx-res-layout { grid-template-columns: 1fr; }
  .tsx-filter-btn { display: inline-block; }
  .tsx-side {
    position: fixed; inset: 0 auto 0 0; top: 0; z-index: 1065; width: min(86vw, 340px); max-height: none; height: 100%;
    background: #fff; padding: 0 16px 24px; transform: translateX(-102%); transition: transform .2s; box-shadow: var(--tsx-shadow);
  }
  .tsx-filters-open .tsx-side { transform: none; }
  .tsx-filters-open::after { content: ""; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 1064; }
  .tsx-side-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; background: #fff; padding: 14px 0 10px; z-index: 1; }
  .tsx-side-close { border: 0; background: none; font-size: 26px; line-height: 1; cursor: pointer; padding: 0 4px; }
}
@media (max-width: 575.98px) {
  .tsx-grid, .tsx-skeleton-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 12px; }
  .tsx-res-title h1 { font-size: 19px; }
  .tsx-res-tools { width: 100%; }
  .tsx-sort { flex: 1; }
  .tsx-row { padding: 9px 14px; }
  .tsx-panel { font-size: 15px; }
}
@media (prefers-reduced-motion: reduce) {
  .tsx-panel.tsx-loading::before, .tsx-skeleton-card span, .tsx-skeleton-card i { animation: none; }
  .tsx-side, .tsx-card-img img { transition: none; }
}
