/* =====================================================================
   Product List Page (`.pl-page`) - chatshop-alpha
   ---------------------------------------------------------------------
   Refactor of the legacy Bootstrap-based product list page. The desktop
   product card strictly follows DESIGN_SPEC §6.4. Mobile (<=991px): 2-col
   grid, borderless white card matching .product-card (shared standard), 11px radius,
   soft ambient shadow, --o-* tokens only.

   Tokens: --o-* from base-tokens.css (global, single source).
   Container geometry matches the site baseline (.ac-layout /
   .home-page__inner) per DESIGN_SPEC §2-9.
   ZERO Bootstrap classes. ZERO legacy class names (§2-11).
   ===================================================================== */

/* ---------- page root + container geometry (§2-8 / §2-9) ---------- */
.pl-page {
  background: var(--o-bg);                 /* §2-8 page background */
  font-family: var(--o-font-body);
  color: var(--o-ink);
  min-height: 100vh;
}
.pl-page__inner {
  box-sizing: content-box;                /* §2-9 / §6.15: match .ac-layout, keep padding outside max-width so breadcrumb aligns across pages (no jump) */
  margin: 0 auto;
  padding: 36px 10px 48px;                /* §2-9 baseline padding */
  max-width: 1180px;                      /* >=1200 */
}
@media (min-width: 1300px) { .pl-page__inner { max-width: 1280px; } }
@media (min-width: 1400px) { .pl-page__inner { max-width: 1380px; } }

/* ---------- list head row: search chip (left) + toolbar (right) ---------- */
.pl-list-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}
/* ---------- toolbar (category + sort) ---------- */
.pl-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 0;
  /* 固定在 pl-list-head 右侧：无论左侧搜索条件(chip)是否存在，
     都靠 auto margin 推到最右，避免 space-between 在单子项时退到左侧。 */
  margin-left: auto;
}
.pl-toolbar__group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pl-field {
  font-size: 13px;
  color: var(--o-ink-2);
  white-space: nowrap;
}
.pl-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--o-line);
  border-radius: var(--o-radius-sm);
  background: var(--o-card)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2357606a' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  padding: 0 36px 0 12px;
  height: 44px;                           /* §2 touch target */
  min-width: 200px;
  font: 400 14px var(--o-font-body);
  color: var(--o-ink);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.pl-select:hover { border-color: var(--o-ink-3); }
.pl-select:focus {
  outline: none;
  border-color: var(--o-accent);
  box-shadow: 0 0 0 3px var(--o-accent-soft);
}

/* ---------- product grid ---------- */
.pl-page .product-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* mobile (<768): 1 col; minmax(0,*) prevents content min-width blowing out tracks */
  gap: 12px;
}
@media (min-width: 768px) {               /* tablet: 2 col, matches legacy col-md-6 */
  .pl-page .product-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
}
@media (min-width: 992px) {               /* desktop focus: 4 col */
  .pl-page .product-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* =====================================================================
   PAGER (desktop only, per §6.6) - wrapped in .cr-desktop-only
   ===================================================================== */
.pl-pager {
  display: flex;
  justify-content: center;
  margin-top: 32px;
}
.pl-pager-list {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.pl-pager-list li { list-style: none; }
.pl-pager-list a,
.pl-pager-list span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 10px;
  border-radius: var(--o-radius-sm);
  border: 1px solid var(--o-line);
  background: var(--o-card);
  color: var(--o-ink);
  font-size: 14px;
  text-decoration: none;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.pl-pager-list a:hover {
  border-color: var(--o-accent);
  color: var(--o-accent);
}
.pl-pager-list li.active a {
  background: var(--o-accent);
  border-color: var(--o-accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(1, 103, 243, .25);
}
.pl-pager-list .pagination--ellipsis {
  border: none;
  background: transparent;
  color: var(--o-ink-3);
  cursor: default;
  font-size: 14px;
  letter-spacing: .05em;
}
.pl-pager-list .pagination--ellipsis:hover { color: var(--o-ink-3); }

/* =====================================================================
   EMPTY STATE
   ===================================================================== */
.pl-empty {
  display: flex;
  justify-content: center;
  padding: 60px 0;
}
.pl-empty__content h3 {
  font: 600 18px var(--o-font-display);
  color: var(--o-ink-2);
  margin: 0;
}

/* =====================================================================
   SEARCH CONDITION CHIP (active filter)
   Desktop: top-left of the product list (above the right-aligned toolbar).
   Mobile: between breadcrumb and filter bar.
   Shared visual language with the card family: white --o-card, soft
   shadow, 44px touch target, --o-* tokens only. ZERO Bootstrap.
   ===================================================================== */
.pl-search-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 6px 0 14px;
  background: var(--o-card);
  border: none;
  border-radius: 999px;
  font: 500 13px var(--o-font-display);
  color: var(--o-ink-2);
  box-shadow: var(--o-shadow);
}
.pl-search-chip__label {
  color: var(--o-ink-3);
  white-space: nowrap;
  line-height: 1;
}
.pl-search-chip__value {
  color: var(--o-ink-2);
  font-weight: 600;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
}
.pl-search-chip__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: center;
  width: 30px;
  height: 30px;
  margin-left: 2px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--o-ink-3);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.pl-search-chip__clear:hover {
  background: var(--o-accent-soft);
  color: var(--o-accent);
}
.pl-search-chip__clear:active {
  transform: scale(.92);
}
.pl-search-chip__clear:focus-visible {
  outline: 2px solid var(--o-accent);
  outline-offset: 1px;
}
.pl-search-chip__clear svg {
  width: 16px;
  height: 16px;
}

/* desktop: left side of the list head row, inline with the right-aligned
   toolbar. Hidden on mobile via .cr-desktop-only. */
.pl-search-chip.pl-search-chip--desktop {
  display: inline-flex;
  margin-bottom: 0;
  flex: 0 0 auto;
}

/* mobile: between breadcrumb and filter bar. Hidden by default (no keyword)
   via the [hidden] attribute; toggled by renderSearchChips(). Hidden on
   desktop via .cr-mobile-only.
   NOTE: .cr-mobile-only sets display:block !important on small screens, which
   would break the inline-flex layout. The double-class + !important below
   restores flex for the chip itself, while [hidden] still wins when hidden. */
@media (max-width: 991px) {
  /* On mobile, .cr-mobile-only forces display:block !important, which would
     break the inline-flex layout. Re-assert flex for the chip only within the
     mobile breakpoint; on desktop .cr-mobile-only hides it (display:none !important). */
  .pl-search-chip.pl-search-chip--mobile {
    display: inline-flex !important;
  }
}
.pl-search-chip--mobile[hidden] {
  display: none !important;
}
.pl-search-chip--mobile {
  margin-bottom: 12px;
}

/* =====================================================================
   MOBILE-ONLY HELPERS (moved from the legacy inline <style> block)
   The filter drawer visuals live in mobile.css (.cr-*). These are the
   load-more / spinner / desktop-only toggles that were previously inline.
   ===================================================================== */
.cr-desktop-only { display: block; }
@media (max-width: 991px) {
  .cr-desktop-only { display: none !important; }
}

.cr-load-more {
  text-align: center;
  padding: 20px 0;
}
.cr-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--o-ink-3);
  font-size: 14px;
}
.cr-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--o-line);
  border-top-color: var(--o-accent);
  border-radius: 50%;
  animation: cr-spin 0.7s linear infinite;
}
@keyframes cr-spin {
  to { transform: rotate(360deg); }
}
.cr-no-more {
  color: var(--o-ink-3);
  font-size: 13px;
  padding: 8px 0;
}

/* =====================================================================
   MOBILE (<=991px) - ��6.4 compliant product card
   2-col grid, white card matching the shared .product-card standard (mobile: borderless),
   --o-* tokens only.
   ===================================================================== */
@media (max-width: 991px) {
  /* §2-9 / §6.15: mobile side padding 14px to match .ac-layout baseline so
     breadcrumb aligns across pages (was 4px legacy gutter -> caused 10px jump) */
  .pl-page__inner {
    padding: 12px 12px 20px;
  }

  /* product grid: legacy forced 2 columns. Cards use the shared .product-card
     default (white card: 1px --o-line border + soft shadow on desktop,
     borderless on mobile), so a uniform 8px gap owns the vertical rhythm
     instead of the old .single-product margin-top. */
  .pl-page .product-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  /* filter / sort bar: desktop-only. On mobile, filtering & sorting are
     handled by the .cr-filter-drawer (.cr-mobile-only), so hide the
     desktop .pl-toolbar to avoid a duplicate control on small screens.
     Also hide the desktop list-head wrapper: its only children (chip +
     toolbar) are both hidden on mobile, so the empty wrapper would leave
     a stray gap. The mobile search chip lives between breadcrumb and the
     filter bar, outside this wrapper. */
  .pl-toolbar { display: none; }
  .pl-list-head { display: none; }

}

/* =====================================================================
   REDUCED MOTION
   ===================================================================== */
@media (prefers-reduced-motion: reduce) {
  .product-card:hover .product-card__img img { transform: none; }
  .cr-spinner { animation: none; }
}
