/* =========================================================================
   KNIGHT — products listing (PLP). Sidebar filters + grid, faithful to the
   Claude Design "Knight" catalog. Preserves the global products.js DOM
   contract (filter IDs, grid, sort, pagination); grid uses the shared k-card.
   ========================================================================= */

/* PAGE HEADER */
.k-plp-head { border-bottom: 1px solid var(--k-line); padding: 24px 0 30px; }
.k-plp-head__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-top: 18px; }
.k-plp-head__count { font-family: var(--k-font-body); font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--k-muted); white-space: nowrap; }
/* Breadcrumb — uppercase, spaced, "/" separators (matches the design) */
.k-plp-breadcrumb .breadcrumb {
  font-family: var(--k-font-body);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 12px;
}
.k-plp-breadcrumb a { color: var(--k-muted); text-decoration: none; }
.k-plp-breadcrumb a:hover { color: var(--k-accent); }
.k-plp-breadcrumb .breadcrumb-item.active { color: var(--k-ink); }
.k-plp-breadcrumb .breadcrumb-item + .breadcrumb-item { padding-left: 8px; }
.k-plp-breadcrumb .breadcrumb-item + .breadcrumb-item::before { content: "/"; color: var(--k-muted-2); padding-right: 8px; }
.k-plp-title {
  font-family: var(--k-font-display);
  font-weight: 900;
  font-size: clamp(38px, 5vw, 68px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  margin: 0;
}
/* Reserve a line so the subtitle's appearance (when a category is chosen)
   doesn't shift the layout. */
.k-plp-subtitle { font-family: var(--k-font-body); font-size: 16px; line-height: 1.5; color: var(--k-muted); max-width: 520px; margin: 14px 0 0; min-height: 24px; }

/* LAYOUT */
.k-plp {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
  padding: 34px 0 72px;
}

/* SIDEBAR */
.k-plp__sidebar { position: sticky; top: 96px; transition: top 0.32s cubic-bezier(0.4, 0, 0.2, 1); }
/* When the header hides on scroll, the sticky sidebar rides up with it. */
body.is-header-hidden .k-plp__sidebar { top: 24px; }
.k-plp__filters-toggle { display: none; }
.k-plp__filters { display: flex; flex-direction: column; gap: 30px; }

/* Filters header + clear all */
.k-filter-head { display: flex; align-items: center; justify-content: space-between; }
.k-filter-head__title { font-family: var(--k-font-display); font-weight: 800; font-size: 18px; letter-spacing: -0.01em; }
.k-filter-head__clear {
  font-family: var(--k-font-body); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  background: none; border: none; cursor: pointer; color: var(--k-muted); padding: 0;
}
.k-filter-head__clear:hover { color: var(--k-accent); }

.k-filter-group { display: flex; flex-direction: column; }
/* Group title = collapsible toggle: uppercase + chevron + bottom hairline */
.k-filter-group__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-family: var(--k-font-body);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--k-muted-2);
  margin-bottom: 14px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--k-line);
}
.k-filter-group__title i { font-size: 12px; transition: transform 0.2s ease; }
.k-filter-group.is-collapsed .k-filter-group__title { margin-bottom: 0; }
.k-filter-group.is-collapsed .k-filter-group__title i { transform: rotate(-90deg); }
.k-filter-group.is-collapsed .k-filter-group__body { display: none; }
.k-filter-group__body { display: block; }

/* No scrollbar on the category/brand lists — list them all */
.k-filter-list { display: flex; flex-direction: column; gap: 2px; }

/* Checkbox rows (categories, availability, brands) — 16px rounded box + ✓ */
.k-filter-list .products-filter-category-item,
.k-filter-check,
#filter-brands-list .form-check {
  display: flex;
  align-items: center;
  gap: 11px;
  font-family: var(--k-font-body);
  font-size: 14px;
  color: var(--k-ink);
  text-decoration: none;
  padding: 7px 0;
  margin: 0;
  cursor: pointer;
}
.k-filter-list .products-filter-category-item:hover,
#filter-brands-list .form-check:hover,
.k-filter-check:hover { opacity: 0.7; }

/* The box itself (shared look) — transparent fill + border, accent when checked */
.k-filter-list .products-filter-category-item::before,
.k-filter-check__box,
.k-plp__filters .form-check-label::before {
  content: "";
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  /* outline matches the filter-name text colour */
  border: 1px solid var(--k-ink);
  border-radius: 4px;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  line-height: 1;
  color: #fff;
}
/* Checked states */
.k-filter-list .products-filter-category-item.is-active::before { content: "✓"; background: var(--k-accent); border-color: var(--k-accent); }
.k-filter-list .products-filter-category-item.is-active { font-weight: 700; }

/* Native checkboxes — hide default, drive the box */
.k-filter-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.k-filter-check input:checked + .k-filter-check__box { background: var(--k-accent); border-color: var(--k-accent); }
.k-filter-check input:checked + .k-filter-check__box::after { content: "✓"; }

/* All Bootstrap .form-check rows in the sidebar (brands + attributes) */
.k-plp__filters .form-check { display: flex; align-items: center; gap: 11px; padding: 7px 0; margin: 0; min-height: 0; cursor: pointer; }
.k-plp__filters .form-check-input { position: absolute; opacity: 0; width: 0; height: 0; }
.k-plp__filters .form-check-label { display: flex; align-items: center; gap: 11px; font-family: var(--k-font-body); font-size: 14px; color: var(--k-ink); cursor: pointer; }
.k-plp__filters .form-check:hover { opacity: 0.7; }
.k-plp__filters .form-check-input:checked ~ .form-check-label::before { content: "✓"; background: var(--k-accent); border-color: var(--k-accent); }

/* Attribute filter blocks (products.js renders .products-filter-block cards) —
   styled exactly like the Knight collapsible filter groups. */
#filter-attributes-primary { display: flex; flex-direction: column; gap: 30px; }
#filter-attributes-primary:empty { display: none; }
.k-plp__filters .products-filter-block { display: flex; flex-direction: column; }
.k-plp__filters .products-filter-header {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: none; text-align: left; cursor: pointer;
  font-family: var(--k-font-body); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--k-muted-2); margin-bottom: 14px; padding: 0 0 10px; border-bottom: 1px solid var(--k-line);
}
.k-plp__filters .products-filter-header i { font-size: 12px; transition: transform 0.2s ease; }
.k-plp__filters .products-filter-header[aria-expanded="true"] i { transform: rotate(180deg); }
.k-plp__filters .products-filter-header[aria-expanded="false"] { margin-bottom: 0; }
.k-plp__filters .products-filter-body { display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
/* "Ostali filteri" body groups each attribute */
#filter-attributes-body .text-uppercase { font-family: var(--k-font-body); font-size: 11px; letter-spacing: 0.14em; color: var(--k-muted); margin-bottom: 8px; }

/* PRICE RANGE SLIDER (drives hidden #filter-price-min/max) */
.k-price { padding-top: 6px; }
.k-price__slider { position: relative; height: 24px; }
.k-price__track { position: absolute; top: 11px; left: 0; right: 0; height: 3px; background: var(--k-line); border-radius: 100px; }
.k-price__fill { position: absolute; top: 11px; height: 3px; background: var(--k-accent); border-radius: 100px; }
.k-price__range {
  position: absolute; top: 0; left: 0; width: 100%; height: 24px; margin: 0;
  background: none; pointer-events: none; -webkit-appearance: none; appearance: none;
}
.k-price__range::-webkit-slider-runnable-track { background: none; height: 24px; }
.k-price__range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto;
  width: 16px; height: 16px; margin-top: 4px; border-radius: 50%;
  background: #fff; border: 2px solid var(--k-accent); cursor: pointer;
  box-shadow: 0 1px 3px rgba(20, 19, 15, 0.2);
}
.k-price__range::-moz-range-track { background: none; height: 24px; }
.k-price__range::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px solid var(--k-accent); cursor: pointer;
}
.k-price__values { display: flex; justify-content: space-between; font-family: var(--k-font-body); font-size: 13px; color: var(--k-ink); margin-top: 10px; }

/* TOOLBAR */
.k-plp__toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.k-plp__showing { font-family: var(--k-font-body); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--k-muted); }
.k-plp__sort { display: flex; align-items: center; gap: 10px; }
.k-plp__sort-label { font-family: var(--k-font-body); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--k-muted); margin: 0; }
.k-plp__sort-select {
  font-family: var(--k-font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--k-ink);
  background-color: #fff;
  /* custom chevron (matches the design) — hides the native OS arrow */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2314130f' stroke-width='1.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: 1px solid var(--k-line);
  border-radius: 8px;
  padding: 9px 34px 9px 13px;
  cursor: pointer;
  outline: none;
}

/* ACTIVE FILTER PILLS (products.js renders .products-active-filter-tag) */
.k-plp__chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 24px; }
.k-plp__chips .products-active-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--k-font-body);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--k-ink);
  color: var(--k-surface);
  border: none;
  border-radius: 100px;
  padding: 7px 13px;
}
.k-plp__chips .products-active-filter-tag .btn-close {
  width: 0.6em;
  height: 0.6em;
  padding: 0;
  margin: 0;
  opacity: 1;
  filter: invert(1) grayscale(1);
  background-size: contain;
  cursor: pointer;
}
.k-plp__chips .btn-close:hover { filter: none; }
/* the "clear all" link inside the chip bar */
.k-plp__chips #btn-clear-all-filters {
  font-family: var(--k-font-body); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  background: none; border: none; color: var(--k-muted); cursor: pointer; padding: 0 4px;
}
.k-plp__chips #btn-clear-all-filters:hover { color: var(--k-accent); }

/* GRID — uses the shared .k-card; just set the columns */
.k-plp__main .k-product-grid { grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 18px; }

/* EMPTY STATE */
.k-plp__empty { padding: 48px 0; text-align: center; }
.k-plp__empty-title { font-family: var(--k-font-display); font-weight: 800; font-size: 24px; margin: 0 0 6px; }
.k-plp__empty-text { font-family: var(--k-font-body); font-size: 14px; color: var(--k-muted); margin: 0; }

/* PAGINATION */
.k-plp__pagination { margin-top: 40px; }
.k-plp__pagination .page-link {
  font-family: var(--k-font-body);
  color: var(--k-ink);
  border: 1px solid var(--k-line);
  margin: 0 3px;
  border-radius: 8px;
}
.k-plp__pagination .page-item.active .page-link { background: var(--k-ink); border-color: var(--k-ink); color: var(--k-surface); }
.k-plp__pagination .page-link:hover { background: var(--k-bg); color: var(--k-accent); }
.k-plp__pagination-note { font-family: var(--k-font-body); font-size: 12px; color: var(--k-muted); text-align: center; margin-top: 10px; }

/* =========================================================================
   MOBILE FILTER SHEET — the sidebar becomes a bottom sheet (matches the
   "Products Mobile" design). These elements are desktop-hidden by default.
   ========================================================================= */
.k-plp__filters-btn,
.k-plp__sheet-head,
.k-plp__sheet-foot,
.k-plp__sheet-backdrop { display: none; }

/* RESPONSIVE */
@media (max-width: 991.98px) {
  .k-plp { grid-template-columns: 1fr; gap: 0; }

  /* Sticky toolbar carries the "Filters" trigger + sort, just below the header.
     When the header hides on scroll-down it slides up to the top (no gap),
     staying in sync with the header's own transform. */
  .k-plp__toolbar {
    position: sticky;
    top: 64px;
    z-index: 30;
    background: var(--k-bg);
    padding: 12px 0;
    margin: 0 0 6px;
    gap: 10px;
    transition: top 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  }
  body.is-header-hidden .k-plp__toolbar { top: 0; }
  .k-plp__showing { display: none; }              /* count already lives in the page head */
  .k-plp__sort { flex: 1; min-width: 0; }
  .k-plp__sort-label { display: none; }
  .k-plp__sort-select { width: 100%; height: 46px; border-radius: 10px; padding: 0 38px 0 14px; background-position: right 14px center; }

  /* "Filters" trigger button */
  .k-plp__filters-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    height: 46px;
    font-family: var(--k-font-body);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: #fff;
    color: var(--k-ink);
    border: 1px solid var(--k-line);
    border-radius: 10px;
    padding: 0 16px;
    cursor: pointer;
  }
  .k-plp__filters-btn-ico { font-size: 14px; line-height: 1; }
  .k-plp__filters-btn-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 6px;
    background: var(--k-accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* The sidebar → bottom sheet */
  .k-plp__sidebar {
    position: fixed;
    left: 50%;
    bottom: 0;
    top: auto;
    transform: translateX(-50%) translateY(100%);
    width: min(440px, 100%);
    max-height: 86vh;
    margin: 0;
    background: var(--k-surface);
    border-top: 1px solid var(--k-ink);
    border-radius: 18px 18px 0 0;
    z-index: 65;
    display: flex;
    flex-direction: column;
    transition: transform 0.32s cubic-bezier(0.22, 0.61, 0.36, 1);
  }
  .k-plp__sidebar.is-open { transform: translateX(-50%) translateY(0); }

  /* Sheet header */
  .k-plp__sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 18px 20px;
    border-bottom: 1px solid var(--k-line);
  }
  .k-plp__sheet-title { font-family: var(--k-font-display); font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
  .k-plp__sheet-close { background: none; border: none; font-size: 24px; line-height: 1; color: var(--k-ink); cursor: pointer; padding: 2px 4px; }

  /* Scrollable filter body */
  .k-plp__filters {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 20px 20px 8px;
    gap: 26px;
    margin: 0;
  }
  .k-plp__filters::-webkit-scrollbar { width: 0; height: 0; }
  .k-filter-head { display: none; }               /* replaced by the sheet header/footer */

  /* Sheet footer */
  .k-plp__sheet-foot {
    display: flex;
    gap: 12px;
    flex: 0 0 auto;
    padding: 14px 20px;
    border-top: 1px solid var(--k-line);
    background: var(--k-bg);
  }
  .k-plp__sheet-clearbtn {
    flex: 0 0 auto;
    font-family: var(--k-font-body);
    font-size: 12px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: #fff;
    color: var(--k-ink);
    border: 1px solid var(--k-line);
    border-radius: 10px;
    padding: 15px 18px;
    cursor: pointer;
  }
  .k-plp__sheet-apply {
    flex: 1;
    font-family: var(--k-font-body);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: var(--k-ink);
    color: var(--k-surface);
    border: none;
    border-radius: 10px;
    padding: 15px;
    cursor: pointer;
  }

  /* Backdrop */
  .k-plp__sheet-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 64;
    background: rgba(20, 19, 15, 0.42);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
  }
  .k-plp__sheet-backdrop.is-visible { opacity: 1; visibility: visible; }
}
@media (max-width: 767.98px) {
  .k-plp-head { padding: 20px 0; }
  .k-plp__main .k-product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .k-plp { padding-bottom: 40px; }   /* trim the oversized gap before the footer */
}

/* =========================================================================
   LOADING OVERLAY + SPINNER (shown over the grid during a filter/sort change)
   ========================================================================= */
.products-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 90px;
  background: color-mix(in srgb, var(--k-bg) 55%, transparent);
  pointer-events: none;
}
.products-loading-overlay.is-visible { display: flex; }
.products-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--k-ink) 18%, transparent);
  border-top-color: var(--k-accent);
  animation: k-spin 0.7s linear infinite;
}
@keyframes k-spin { to { transform: rotate(360deg); } }
