/**
 * Responsive patches — layered last.
 * Mobile header (≤640px): logo + auth | search | category slider.
 */

/* --- .pl-container padding --- */
.pl-container {
  padding-left: 12px;
  padding-right: 12px;
}

@media (min-width: 641px) {
  .pl-container {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (min-width: 1025px) {
  .pl-container {
    padding-left: 24px;
    padding-right: 24px;
  }
}

/* --- Main category nav in header (not separate mobile strip) --- */
@media (max-width: 1023px) {
  .pl-header-cats--desktop:not([hidden]) {
    display: block !important;
  }

  .pl-site-chrome--mobile-cats {
    display: none !important;
  }
}

/* --- Mobile header --- */
@media (max-width: 640px) {
  /* Row 1: logo (left) + auth (right). Row 2: full-width search. */
  .pl-topbar--minimal .pl-topbar__inner {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto !important;
    align-items: center !important;
    gap: 10px 8px !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 10px 12px 8px !important;
  }

  .pl-topbar--minimal .pl-logo {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    margin-left: 0 !important;
    max-width: min(128px, 40vw);
  }

  .pl-topbar--minimal .pl-logo__img {
    max-width: 100% !important;
    max-height: 38px !important;
    width: auto !important;
    height: auto !important;
  }

  .pl-topbar--minimal .pl-topbar__end {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    gap: 4px !important;
  }

  .pl-topbar--minimal .pl-topbar-search {
    display: flex !important;
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
  }

  .pl-topbar-search .pl-chrome-search__form {
    width: 100%;
    align-items: center !important;
    padding: 2px 6px 2px 8px;
  }

  .pl-topbar-search .pl-chrome-search__icon {
    width: 28px;
  }

  .pl-topbar-search .pl-chrome-search__icon svg {
    width: 16px;
    height: 16px;
  }

  .pl-topbar-search .pl-chrome-search__input {
    min-height: 40px;
    padding: 6px 28px 6px 2px;
    font-size: 0.875rem;
  }

  .pl-topbar__auth {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
  }

  .pl-topbar__auth-link[data-auth-open="login"] {
    display: inline-flex !important;
    align-items: center;
    padding: 6px 8px;
    font-size: 0.75rem;
    min-height: 36px;
    white-space: nowrap;
  }

  .pl-topbar__auth .btn--sm {
    padding: 6px 10px;
    font-size: 0.75rem;
    min-height: 36px;
    white-space: nowrap;
  }

  .pl-topbar-instagram,
  .pl-topbar--minimal .pl-nav-toggle {
    display: none !important;
  }

  .pl-header-cats--desktop .pl-header-cats__container {
    padding-top: 2px;
    padding-bottom: 6px;
  }

  .pl-header-cats--desktop .pl-header-cats__bar {
    gap: 2px;
  }

  .pl-header-cats--desktop .pl-cat-carousel__nav {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
  }

  .pl-header-cats--desktop .pl-cat-carousel__nav svg {
    width: 14px;
    height: 14px;
  }

  /* ~4 category pills visible; horizontal slider unchanged */
  .pl-header-cats--desktop .pl-cat-carousel .pl-cat-pill,
  .pl-header-cats--desktop .pl-cat-carousel .pl-cat-pill.cat-pill {
    --cat-cols: 4 !important;
    --cat-gap: 3px !important;
    padding: 0 0 3px;
    flex: 0 0
      calc((100cqw - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols)) !important;
    width: calc((100cqw - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols)) !important;
    min-width: 0 !important;
    max-width: calc((100cqw - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols)) !important;
  }

  .pl-header-cats--desktop .pl-cat-pill__label {
    font-size: 0.625rem;
    line-height: 1.15;
  }

  .pl-header-cats--desktop .pl-cat-pill.is-carousel-center {
    transform: none;
  }

  /* Waitlist CTA (#prijava) */
  .pl-cta {
    padding: 1.75rem 0 2rem;
  }

  .pl-cta__inner {
    gap: 1rem;
  }

  .pl-cta__title {
    font-size: 1.25rem;
    line-height: 1.25;
    margin-bottom: 0.375rem;
  }

  .pl-cta__lead {
    font-size: 0.8125rem;
    line-height: 1.45;
  }

  .pl-cta-form__row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.625rem;
  }

  .pl-cta-form__input {
    font-size: 0.875rem;
    padding: 0.625rem 0.75rem;
    min-height: 44px;
  }

  .pl-cta-form__row .btn {
    width: 100%;
    min-height: 44px;
    font-size: 0.875rem;
    padding: 0.625rem 1rem;
    white-space: normal;
  }

  .pl-cta-form__status {
    margin-top: 0.5rem;
    font-size: 0.8125rem;
    line-height: 1.4;
  }

  /* App soon modal — waitlist shortcut */
  .pl-app-soon-modal {
    padding: 12px;
    align-items: flex-end;
  }

  .pl-app-soon-modal__dialog {
    width: 100%;
    max-width: none;
    padding: 1.125rem 1rem 1rem;
    border-radius: 16px 16px 0 0;
  }

  .pl-app-soon-modal__title {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
  }

  .pl-app-soon-modal__desc {
    font-size: 0.8125rem;
    line-height: 1.45;
    margin-bottom: 1rem;
  }

  .pl-app-soon-modal__actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .pl-app-soon-modal__actions .btn {
    width: 100%;
    min-height: 44px;
    font-size: 0.875rem;
    white-space: normal;
  }

  #catalog-browse-screen-products.cat-products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

/*
 * Mobile (≤767px): category slider in header (under search), not separate #pl-site-chrome-mobile strip.
 */
@media (max-width: 767px) {
  .pl-header-cats--desktop:not([hidden]) {
    display: block !important;
    width: 100%;
  }

  .pl-site-chrome--mobile-cats {
    display: none !important;
  }

  .pl-header-cats--desktop .pl-header-cats__container {
    padding-top: 2px;
    padding-bottom: 6px;
  }

  .pl-header-cats--desktop .pl-header-cats__bar {
    gap: 2px;
  }

  .pl-header-cats--desktop .pl-cat-carousel__nav {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
  }

  .pl-header-cats--desktop .pl-cat-carousel__nav svg {
    width: 14px;
    height: 14px;
  }

  .pl-header-cats--desktop .pl-cat-carousel .pl-cat-pill,
  .pl-header-cats--desktop .pl-cat-carousel .pl-cat-pill.cat-pill {
    --cat-cols: 4 !important;
    --cat-gap: 3px !important;
    padding: 0 0 3px;
    flex: 0 0
      calc((100cqw - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols)) !important;
    width: calc((100cqw - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols)) !important;
    min-width: 0 !important;
    max-width: calc((100cqw - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols)) !important;
  }

  .pl-header-cats--desktop .pl-cat-pill__label {
    font-size: 0.625rem;
    line-height: 1.15;
  }

  .pl-header-cats--desktop .pl-cat-pill.is-carousel-center {
    transform: none;
  }
}

/* Safari/iOS: container query units can collapse pills — use % of scroll viewport width */
@supports not (width: 1cqw) {
  @media (min-width: 768px) and (max-width: 1023px) {
    .pl-header-cats--desktop .pl-header-cats__scroll .pl-cat-pill,
    .pl-header-cats--desktop .pl-header-cats__scroll .pl-cat-pill.cat-pill {
      flex: 0 0
        calc((100% - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols));
      width: calc((100% - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols));
      min-width: calc((100% - (var(--cat-cols) - 1) * var(--cat-gap)) / var(--cat-cols));
    }
  }
}

@media (max-width: 1023px) {
  .pl-header-cats--desktop .pl-header-cats__scroll .pl-cat-pill,
  .pl-header-cats--desktop .pl-header-cats__scroll .pl-cat-pill.cat-pill {
    min-width: 4.25rem;
  }
}

@media (max-width: 767px) {
  .pl-header-cats--desktop .pl-header-cats__scroll .pl-cat-pill,
  .pl-header-cats--desktop .pl-header-cats__scroll .pl-cat-pill.cat-pill {
    min-width: 0 !important;
  }
}

/*
 * Tablet only (641px–1023px): fixed card width, more per row — mobile/desktop unchanged here.
 */
@media (min-width: 641px) and (max-width: 1023px) {
  #catalog-browse-screen-products.cat-products {
    display: grid;
    grid-template-columns: repeat(auto-fill, 172px);
    justify-content: start;
    gap: 14px;
  }

  .pl-home-products-row.cat-products .product-card,
  .pl-product-detail__similar-row.cat-products .product-card {
    flex: 0 0 172px;
    min-width: 172px;
    max-width: 172px;
    width: 172px;
  }
}

/*
 * Mobile only (≤767px): compact product card chrome and smaller title.
 * Row count unchanged: 2-col catalog grid (≤640px), 2-card home carousel (≤1023px).
 */
@media (max-width: 767px) {
  .product-card {
    --pc-title-fs: 0.6875rem;
    --pc-title-lh: 1.25;
    --pc-offer-row-h: 20px;
    --pc-offer-gap: 2px;
    border-radius: 8px;
  }

  .product-card__media {
    max-height: none;
  }

  .product-card__img {
    padding: 4px;
  }

  .product-card__body {
    padding: 5px 6px 6px;
  }

  .product-card__text {
    min-height: calc(var(--pc-title-block-h) + 4px + var(--pc-offers-block-h));
  }

  .product-card__offer-row {
    gap: 4px;
    min-height: var(--pc-offer-row-h);
  }

  .product-card__offer-logo {
    width: var(--pc-offer-row-h);
    height: var(--pc-offer-row-h);
  }

  .product-card__offer-logo-img {
    padding: 2px;
  }

  .product-card__offer-prices {
    min-height: var(--pc-offer-row-h);
    gap: 0;
  }

  .product-card__offer-compare {
    font-size: 0.5625rem;
    line-height: 1.1;
  }

  .product-card__offer-price {
    font-size: 0.625rem;
    line-height: 1.15;
  }

  .product-card__discount {
    top: 4px;
    left: 4px;
    padding: 2px 5px;
    font-size: 0.5625rem;
  }

  .pl-favourite-btn--card {
    top: 3px;
    right: 3px;
    width: 24px;
    height: 24px;
  }

  .pl-favourite-btn--card .pl-favourite-btn__icon {
    width: 14px;
    height: 14px;
  }
}
