/**
 * MIU PLP toolbar — top pager + Nimi/Hind sort toggles (Fresh-style layout, MIU petrol).
 */
html body #center-column .products__selection.fd-sortbar {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  gap: 0.65rem !important;
  flex-wrap: wrap;
  margin: 0 !important;
  padding: 0 0 10px !important;
}

html body #center-column .fd-sortbar__right {
  margin-left: auto;
  justify-content: flex-end;
  gap: 0.55rem !important;
  min-width: 0;
}

html body #center-column .products__sort .dropdown,
html body #center-column .products__sort-dropdown-button,
html body #center-column .products__sort-label {
  display: none !important;
}

/* Pager */
html body #center-column .fd-pager {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

html body #center-column .fd-pager__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 34px;
  min-width: 34px;
  padding: 0 11px;
  border-radius: 8px;
  border: 1px solid #d5dbde;
  background: #fff;
  color: var(--miu-dark, #0b2b3b);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none !important;
  box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}

html body #center-column a.fd-pager__btn:hover {
  border-color: var(--miu-petrol, #5da2b0);
  box-shadow: 0 2px 8px -4px rgba(93, 162, 176, 0.35);
  color: var(--miu-dark, #0b2b3b);
}

html body #center-column a.fd-pager__btn:focus-visible {
  outline: 2px solid rgba(93, 162, 176, 0.45);
  outline-offset: 2px;
}

html body #center-column .fd-pager__btn.is-disabled {
  opacity: 0.38;
  pointer-events: none;
  cursor: default;
  color: #5b666b;
}

html body #center-column .fd-pager__chev {
  display: block;
  flex: 0 0 auto;
}

html body #center-column .fd-pager__status {
  font-size: 13px;
  font-weight: 600;
  color: var(--miu-text-muted, #5b666b);
  white-space: nowrap;
  padding: 0 4px;
  letter-spacing: 0.01em;
}

/* Nimi / Hind toggles */
html body #center-column .fd-sort-toggles {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

html body #center-column .fd-sort-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 11px 0 12px;
  border-radius: 8px;
  border: 1px solid #d5dbde;
  background: #fff;
  color: var(--miu-dark, #0b2b3b);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  box-sizing: border-box;
}

html body #center-column .fd-sort-toggle:hover {
  border-color: var(--miu-petrol, #5da2b0);
  color: var(--miu-dark, #0b2b3b);
  box-shadow: 0 2px 8px -4px rgba(93, 162, 176, 0.35);
}

html body #center-column .fd-sort-toggle:focus-visible {
  outline: 2px solid rgba(93, 162, 176, 0.45);
  outline-offset: 2px;
}

html body #center-column .fd-sort-toggle.is-active {
  background: var(--miu-petrol, #5da2b0);
  border-color: var(--miu-petrol, #5da2b0);
  color: #fff;
  box-shadow: none;
}

html body #center-column .fd-sort-toggle.is-active:hover {
  background: var(--miu-petrol-hover, #4a8f9c);
  border-color: var(--miu-petrol-hover, #4a8f9c);
  color: #fff;
}

html body #center-column .fd-sort-toggle__arrows {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  line-height: 0;
}

html body #center-column .fd-sort-toggle__chev {
  display: block;
  opacity: 0.32;
}

html body #center-column .fd-sort-toggle:not(.is-active) .fd-sort-toggle__chev {
  opacity: 0.38;
  color: var(--miu-dark, #0b2b3b);
}

html body #center-column .fd-sort-toggle.is-active .fd-sort-toggle__chev {
  opacity: 0.35;
  color: #fff;
}

html body #center-column .fd-sort-toggle.is-active.is-asc .fd-sort-toggle__chev--up,
html body #center-column .fd-sort-toggle.is-active.is-desc .fd-sort-toggle__chev--down {
  opacity: 1;
}

html body #center-column .fd-sortbar__count,
html body #center-column .fd-sortbar__count span {
  font-size: 13px !important;
  font-weight: 600 !important;
  color: var(--miu-text-muted, #5b666b) !important;
  white-space: nowrap;
  margin: 0 !important;
  padding: 0 !important;
}

html body #center-column .fd-sortbar__count:before {
  display: none !important;
}

@media (max-width: 575.98px) {
  html body #center-column .products__selection.fd-sortbar {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.55rem !important;
  }

  html body #center-column .fd-pager {
    width: 100%;
    justify-content: space-between;
    gap: 4px;
  }

  html body #center-column .fd-pager__btn {
    min-height: 40px;
    min-width: 40px;
    padding: 0 10px;
    font-size: 12.5px;
  }

  html body #center-column .fd-pager__status {
    font-size: 12.5px;
    flex: 1 1 auto;
    text-align: center;
    min-width: 0;
  }

  html body #center-column .fd-sortbar__right {
    width: 100% !important;
    justify-content: flex-start !important;
    gap: 0.4rem !important;
  }

  html body #center-column .fd-sort-toggle {
    min-height: 40px;
    height: 40px;
    padding: 0 10px 0 11px;
    font-size: 12.5px;
  }

  html body #center-column .miu-grid-toggle button,
  html body #center-column .miu-grid-toggle__btn {
    min-width: 40px !important;
    min-height: 40px !important;
    width: 40px !important;
    height: 40px !important;
  }

  html body #center-column .fd-sortbar__count,
  html body #center-column .fd-sortbar__count span {
    font-size: 12.5px !important;
  }

  html body #center-column .products__filter-button {
    min-height: 40px;
  }
}

@media (max-width: 379.98px) {
  html body #center-column .fd-pager__txt {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
  }

  html body #center-column .fd-pager__btn {
    padding: 0;
    width: 40px;
  }
}

/*
 * Subcategory cards: CSS stage MUST be pure white (never --miu-sand #f5f4f1).
 * Grey only on caption. No image zoom — letterboxing stays white.
 */
html body .miu-subcats__link,
html body a.miu-subcats__link.subcategory__link--with-image,
html body .subcategory__link--with-image {
  background: #ffffff !important;
  background-color: #ffffff !important;
  background-image: none !important;
}
html body .miu-subcats__media,
html body .miu-subcats__link .miu-subcats__media {
  background: #ffffff !important;
  background-color: #ffffff !important;
  background-image: none !important;
}
html body .miu-subcats__letter {
  background: #ffffff !important;
  color: rgba(11, 43, 59, 0.18);
}
html body .miu-subcats__link img.miu-subcats__cover,
html body .miu-subcats__media > img.miu-subcats__cover,
html body .subcategory__thumbnail.miu-subcats__cover,
html body .miu-subcats__link img.miu-subcats__cover--native,
html body .miu-subcats__link img.miu-subcats__cover--product {
  object-fit: contain !important;
  object-position: center center !important;
  transform: none !important;
  background: #ffffff !important;
  background-color: #ffffff !important;
}
.miu-subcats__name,
.miu-subcats__link .subcategory__name,
.subcategory__name {
  background: #e8eef1 !important;
  border-top: 1px solid rgba(11, 43, 59, 0.07);
  color: #0a2430 !important;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.32;
  padding: 0.5rem 0.7rem 0.55rem;
}
.miu-subcats__name-text {
  color: #0a2430 !important;
  line-height: 1.32;
}

/*
 * Desktop subcategory grid (ainult ≥1200px):
 * 1–9 üks rida; 10=5+5; 11=5+6 (alumine kitsam); 12=6+6; 13=6+7; …
 */
@media (min-width: 1200px) {
  .miu-subcats__list,
  .subcategory__list {
    grid-template-columns: repeat(var(--miu-subcat-cols, 6), minmax(0, 1fr));
    gap: 0.85rem;
  }
  .miu-subcats__list[data-count="7"] .miu-subcats__name,
  .miu-subcats__list[data-count="8"] .miu-subcats__name,
  .miu-subcats__list[data-count="9"] .miu-subcats__name,
  .miu-subcats__list[data-count="7"] .subcategory__name,
  .miu-subcats__list[data-count="8"] .subcategory__name,
  .miu-subcats__list[data-count="9"] .subcategory__name {
    font-size: 0.8rem;
    padding: 0.42rem 0.5rem 0.48rem;
    gap: 0.3rem;
  }
  .miu-subcats__list[data-count="8"] .miu-subcats__chev,
  .miu-subcats__list[data-count="9"] .miu-subcats__chev {
    display: none;
  }

  /* 11: ülemine 5, alumine 6 (kitsamad) — 30-veeruline LCM-grid */
  .miu-subcats__list[data-count="11"] {
    grid-template-columns: repeat(30, minmax(0, 1fr));
  }
  .miu-subcats__list[data-count="11"] > a:nth-child(-n + 5) {
    grid-column: span 6;
  }
  .miu-subcats__list[data-count="11"] > a:nth-child(n + 6) {
    grid-column: span 5;
  }
  .miu-subcats__list[data-count="11"] > a:nth-child(n + 6) .miu-subcats__name,
  .miu-subcats__list[data-count="11"] > a:nth-child(n + 6) .subcategory__name {
    font-size: 0.78rem;
    padding: 0.4rem 0.45rem 0.45rem;
  }

  /* 13: 6 + 7 */
  .miu-subcats__list[data-count="13"] {
    grid-template-columns: repeat(42, minmax(0, 1fr));
  }
  .miu-subcats__list[data-count="13"] > a:nth-child(-n + 6) {
    grid-column: span 7;
  }
  .miu-subcats__list[data-count="13"] > a:nth-child(n + 7) {
    grid-column: span 6;
  }

  /* 15: 7 + 8 */
  .miu-subcats__list[data-count="15"] {
    grid-template-columns: repeat(56, minmax(0, 1fr));
  }
  .miu-subcats__list[data-count="15"] > a:nth-child(-n + 7) {
    grid-column: span 8;
  }
  .miu-subcats__list[data-count="15"] > a:nth-child(n + 8) {
    grid-column: span 7;
  }

  /* 17: 8 + 9 */
  .miu-subcats__list[data-count="17"] {
    grid-template-columns: repeat(72, minmax(0, 1fr));
  }
  .miu-subcats__list[data-count="17"] > a:nth-child(-n + 8) {
    grid-column: span 9;
  }
  .miu-subcats__list[data-count="17"] > a:nth-child(n + 9) {
    grid-column: span 8;
  }
}

/* Mobiil 2 veergu: üksik viimane kategooria → täislaius */
@media (max-width: 767.98px) {
  html body .miu-subcats__list > a:last-child:nth-child(odd),
  html body .subcategory__list > a:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

/* Tablet 3 veergu: üksik viimane (n mod 3 = 1) → täislaius */
@media (min-width: 768px) and (max-width: 1199.98px) {
  html body .miu-subcats__list > a:last-child:nth-child(3n + 1),
  html body .subcategory__list > a:last-child:nth-child(3n + 1) {
    grid-column: 1 / -1;
  }
}
