/* =========================================================
   ROBOTIMEDZ — Shop page styles
   Loaded after main.css; reuses its tokens, product cards,
   drawers, accordions and buttons.
   Mobile-first with min-width queries only (no max-width), so
   fractional widths such as 767.2px are never left uncovered:
     base      mobile — 2-column grid, filter drawer + sort sheet
     768px     tablet — 3-column grid
     1024px    desktop — filter sidebar + sort dropdown
     1200px    wide desktop — 4-column grid
   ========================================================= */

.shop { padding-block-end: 8px; }

/* ---------- Heading ---------- */
.shop-head { padding-block: 4px 18px; }
.shop-title { font-size: 26px; font-weight: 800; line-height: 1.15; letter-spacing: -.02em; color: var(--ink); }
.shop-intro { margin-top: 8px; max-width: 80ch; font-size: 14px; line-height: 1.55; color: #444; }
.shop-intro p + p { margin-top: 8px; }
/* Category / brand page with an image: small rounded picture next to the title and description */
.shop-head--media { display: grid; grid-template-columns: minmax(0, 1fr) 72px; column-gap: 14px; align-items: start; }
.shop-head--media > :not(.shop-head__img) { grid-column: 1; }
.shop-head__img { grid-column: 2; grid-row: 1 / span 2; width: 72px; height: 72px; border-radius: 14px; object-fit: cover; background: var(--soft-2); }
.shop-head__img--logo { object-fit: contain; background: #fff; border: 1px solid var(--line); padding: 6px; }
@media (min-width: 768px) {
  .shop-head--media { grid-template-columns: minmax(0, 1fr) 120px; column-gap: 24px; }
  .shop-head__img { width: 120px; height: 120px; border-radius: 18px; }
}

/* ---------- Toolbar ---------- */
.shop-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 12px; border-block: 1px solid var(--line); }
.shop-count { font-size: 14px; color: var(--muted); order: 2; width: 100%; text-align: center; }
.shop-toolbar__actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; order: 1; }
.shop-tool { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding-inline: 14px; border: 1px solid #D6D6D6; border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--ink); transition: border-color .2s, background-color .2s; }
.shop-tool:hover { border-color: var(--ink); }
.shop-tool .icon { width: 19px; height: 19px; }
.shop-tool__badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding-inline: 5px; border-radius: 10px; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; }

/* Desktop sort dropdown (native <select>, styled) */
.shop-sort { position: relative; display: none; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); }
.shop-sort select { appearance: none; -webkit-appearance: none; min-height: 40px; padding-block: 0; padding-inline: 12px 34px; border: 1px solid #DCDCDC; border-radius: 999px; background: #fff; font: inherit; font-weight: 600; color: var(--ink); cursor: pointer; transition: border-color .2s; }
.shop-sort select:hover { border-color: var(--ink); }
.shop-sort .icon { position: absolute; inset-inline-end: 12px; width: 16px; height: 16px; color: var(--ink); pointer-events: none; }

/* ---------- Active filter chips ---------- */
.shop-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-block: 14px 2px; }
.shop-chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; max-width: 100%; padding-inline: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--soft); font-size: 13px; color: var(--ink); transition: border-color .2s; }
.shop-chip:hover { border-color: var(--ink); }
.shop-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shop-chip .icon { width: 14px; height: 14px; }
.shop-chips__clear { font-size: 13px; padding-inline: 4px; }

/* ---------- Product grid ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 12px; padding-block: 18px 8px; }
.shop-card .product-card__media { background: #fff; }
.shop-card .product-card__title { font-size: 13.5px; }
.shop-card__meta { margin-bottom: 4px; font-size: 11.5px; font-weight: 600; letter-spacing: .02em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Brand link: looks like the text around it; its keyboard focus ring is drawn inside so overflow:hidden does not cut it */
.shop-card__meta a:focus-visible { outline-offset: -2px; }
.shop-card__sku { margin-top: 4px; font-size: 11.5px; color: #8A8A8A; }
.shop-card .price { margin-top: 6px; row-gap: 0; }
.shop-card .price__current { font-size: 15px; }
.shop-card .price__compare { font-size: 12.5px; }
/* Keep "8 900 DA" in reading order inside Arabic (RTL) text.
   (The "-16%" badge uses an inner dir="ltr" span, so the badge itself keeps its RTL position.) */
.shop-card .price > span { direction: ltr; unicode-bidi: isolate; }

.shop-badge { position: absolute; top: 8px; inset-inline-start: 8px; z-index: 2; max-width: calc(100% - 60px); padding: 4px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
.shop-badge--sale { background: var(--red); color: #fff; }
.shop-badge--out { background: var(--ink); color: #fff; }

/* Sold out: stays visible and clickable; only Add to Cart is disabled */
.shop-card.is-sold-out .product-card__image img { opacity: .6; }
.shop-card .quick-add:disabled { background: #E4E4E4; color: #8A8A8A; box-shadow: none; cursor: not-allowed; }
.shop-card .quick-add:disabled .icon { opacity: .6; }

/* ---------- Empty state ---------- */
.shop-empty { margin-block: 24px; padding: 40px 20px; border: 1px dashed #DADADA; border-radius: 8px; text-align: center; }
.shop-empty__title { font-size: 17px; font-weight: 700; color: var(--ink); }
.shop-empty__text { margin: 6px 0 18px; font-size: 14px; color: var(--muted); }

/* ---------- Filters (drawer on mobile/tablet) ---------- */
.shop-filters__body { padding-inline: 22px; }
.shop-filters__foot { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; flex: none; padding: 12px 22px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); background: #fff; }
.shop-filters__foot .btn { min-height: 48px; padding-inline: 12px; }
.shop-btn-outline { border: 1px solid #D0D0D0; color: var(--ink); background: #fff; }
.shop-btn-outline:hover { border-color: var(--ink); }

.filter-group { border-bottom: 1px solid var(--line); }
.filter-group__head { font-size: inherit; }
.filter-group__toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 54px; font-size: 17px; font-weight: 700; color: var(--ink); text-align: start; }
/* Chevron points up when open, down when closed (overrides the menu's "+" rotation) */
.filter-group__toggle .acc__icon .icon { width: 18px; height: 18px; }
.filter-group__toggle[aria-expanded="true"] > .acc__icon .icon { transform: none; }
.filter-group__toggle[aria-expanded="false"] > .acc__icon .icon { transform: rotate(180deg); }
.filter-group__body { margin: 0; padding: 0 0 14px; border: 0; min-width: 0; }
/* main.css makes open accordion panels "visibility: visible", which would show them even while
   the closed drawer is hidden (visible when it slides across on RTL switch). Follow the drawer instead. */
.shop-filters .filter-group.is-open > .acc__panel { visibility: inherit; }

/* Checkbox rows */
.check { position: relative; display: flex; align-items: center; gap: 12px; min-height: 42px; cursor: pointer; font-size: 15px; color: #333; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check__box { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border: 1.5px solid #BDBDBD; border-radius: 4px; background: #fff; transition: background-color .15s, border-color .15s; }
.check__box::after { content: ""; width: 10px; height: 6px; margin-top: -2px; border: solid #fff; border-width: 0 0 2px 2px; transform: rotate(-45deg) scale(0); transition: transform .15s; }
.check input:checked + .check__box { background: var(--red); border-color: var(--red); }
.check input:checked + .check__box::after { transform: rotate(-45deg) scale(1); }
.check input:focus-visible + .check__box { outline: 2px solid var(--red); outline-offset: 2px; }
.check:hover .check__box { border-color: var(--ink); }
.check__label { min-width: 0; }
.check__count { color: var(--muted); font-size: 13px; }

/* Price range: two sliders on one track + two number fields */
.price-filter__slider { position: relative; height: 32px; margin-inline: 10px; }
.price-filter__track { position: absolute; inset-inline: 0; top: 50%; height: 3px; margin-top: -1.5px; border-radius: 2px; background: #E2E2E2; }
.price-filter__fill { position: absolute; top: 0; bottom: 0; background: var(--ink); border-radius: inherit; }
.price-filter__slider input[type="range"] { position: absolute; inset-inline: -10px; top: 0; width: calc(100% + 20px); height: 32px; margin: 0; background: none; -webkit-appearance: none; appearance: none; pointer-events: none; }
.price-filter__slider input[type="range"]::-webkit-slider-runnable-track { background: none; }
.price-filter__slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); cursor: grab; pointer-events: auto; }
.price-filter__slider input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--ink); border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .3); cursor: grab; pointer-events: auto; }
.price-filter__slider input[type="range"]::-moz-range-track { background: none; }
.price-filter__slider input[type="range"]:focus-visible { outline: none; }
.price-filter__slider input[type="range"]:focus-visible::-webkit-slider-thumb { outline: 2px solid var(--red); outline-offset: 2px; }
.price-filter__inputs { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-top: 10px; }
/* Field = [digits | unit] inside one border. The unit is a normal flex item (never on top of the digits);
   the digits are always left-to-right and sit next to the unit (DA / دج) in every language. */
.price-filter__field { display: flex; align-items: center; min-width: 0; height: 44px; border: 1px solid #DCDCDC; border-radius: 6px; background: #fff; }
.price-filter__field:focus-within { border-color: var(--ink); }
.price-filter__field input { flex: 1; width: 100%; min-width: 0; height: 100%; padding-inline: 12px 6px; border: 0; border-radius: inherit; background: none; font-size: 15px; direction: ltr; unicode-bidi: isolate; text-align: right; -moz-appearance: textfield; appearance: textfield; }
.price-filter__field input:focus { outline: none; }
.price-filter__unit { flex: none; padding-inline-end: 12px; font-size: 13px; color: var(--muted); white-space: nowrap; pointer-events: none; }
[dir="rtl"] .price-filter__field input { text-align: left; padding-inline: 6px 12px; }
.price-filter__field input::-webkit-outer-spin-button, .price-filter__field input::-webkit-inner-spin-button { -webkit-appearance: none; }
.price-filter__to { font-size: 14px; color: var(--muted); }

/* ---------- Sort sheet (bottom sheet on mobile/tablet) ---------- */
.drawer.sort-sheet { inset: auto 0 0 0; width: 100%; max-height: 82vh; border-radius: 16px 16px 0 0; transform: translateY(100%); }
.drawer.sort-sheet.is-open { transform: none; }
.sort-sheet__head { position: relative; justify-content: center; padding-inline: 56px; }
.sort-sheet__head .icon-btn { position: absolute; inset-inline-end: 10px; }
.sort-options { margin: 0; padding: 10px 22px calc(18px + env(safe-area-inset-bottom, 0px)); border: 0; min-width: 0; }
.sort-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; font-size: 17px; color: #555; cursor: pointer; border-bottom: 1px solid #F3F3F3; }
.sort-option:last-child { border-bottom: 0; }
.sort-option input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.sort-option .icon { width: 20px; height: 20px; color: var(--red); visibility: hidden; }
.sort-option:has(input:checked) { color: var(--ink); font-weight: 600; }
.sort-option:has(input:checked) .icon { visibility: visible; }
.sort-option:has(input:focus-visible) { outline: 2px solid var(--red); outline-offset: -2px; border-radius: 6px; }

/* ---------- Tablet ---------- */
@media (min-width: 768px) {
  .shop-title { font-size: 30px; }
  .shop-intro { font-size: 15px; }
  .shop-toolbar { flex-wrap: nowrap; }
  .shop-count { order: 0; width: auto; text-align: start; }
  .shop-toolbar__actions { display: flex; width: auto; }
  .shop-tool { min-width: 150px; }
  .shop-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 30px 16px; }
  .shop-card .product-card__title { font-size: 14px; }
  .shop-card .price__current { font-size: 16px; }
  .shop-filters__body { padding-inline: 32px; }
  .shop-filters__foot { padding-inline: 32px; }
  .drawer.sort-sheet { inset-inline: auto; inset-inline-start: calc(50% - 260px); width: 520px; }
}

/* ---------- Desktop: sidebar + dropdown ---------- */
@media (min-width: 1024px) {
  .shop-head { padding-block: 8px 22px; }
  .shop-title { font-size: 34px; }
  .shop-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 36px; align-items: start; }
  .shop-toolbar__actions { display: none; }
  .shop-sort { display: inline-flex; }

  /* The drawer becomes a sticky sidebar: filters stay in place while the products scroll with the page.
     top = sticky header height (+1px border) + gap, so it never slides under the header.
     It stops by itself at the end of .shop-layout, before the footer.
     If the filters are taller than the window, only the sidebar scrolls (thin scrollbar);
     the page keeps its single normal scrollbar and the wheel is never trapped (no overscroll-behavior). */
  .drawer.shop-filters { position: sticky; inset: auto; top: calc(var(--header-h) + 21px); z-index: auto; display: block; width: auto; max-height: calc(100vh - var(--header-h) - 41px); overflow-y: auto; padding-inline-end: 6px; background: none; transform: none; visibility: visible; transition: none; box-shadow: none; scrollbar-width: thin; scrollbar-color: #D0D0D0 transparent; }
  .drawer.shop-filters::-webkit-scrollbar { width: 6px; }
  .drawer.shop-filters::-webkit-scrollbar-thumb { background: #D0D0D0; border-radius: 3px; }
  .shop-filters__head, .shop-filters__foot { display: none; }
  .shop-filters__body { padding: 0; overflow: visible; border-top: 1px solid var(--line); }
  .filter-group__toggle { min-height: 50px; font-size: 15px; }
  .check { min-height: 34px; font-size: 14px; gap: 10px; }
  .check__box { width: 18px; height: 18px; }
}
@media (min-width: 1200px) {
  .shop-layout { grid-template-columns: 240px minmax(0, 1fr); gap: 48px; }
  .shop-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 34px 20px; }
}
