/* ==========================================================================
   Open-shop theme (body.theme-shop) — admin-created retail shops served by
   public/shop.html. Structure copied from themes/autoexperten.css so a shop
   looks like the Autoexperten storefront; the brand tokens
   (--brand-primary, -hover, -soft, -ring, --text-on-brand) are NOT set here —
   services/shopPageService.js injects them per shop from its brand colour.
   Inert when the class is absent, so the default storefront is unchanged.
   ========================================================================== */

body.theme-shop {
  /* Themed storefronts follow their own brand colour and keep their old corner sizes. */
  --brand-primary-text: var(--brand-primary);
  --radius-md: 8px;
  --radius-lg: 12px;
  --bg-page: #F5F6F7;
  --bg-surface: #FFFFFF;
  --bg-surface-muted: #F5F6F7;
  --bg-surface-hover: #EEF1F4;
  --border-default: rgba(55, 71, 79, 0.18);
  --border-strong: rgba(55, 71, 79, 0.48);
  --border-subtle: #DCE1E5;
  --text-primary: #37474F;
  --text-secondary: #54656E;
  /* Solid grey: the old see-through rgba(55,71,79,.72) was 4.20:1 on the page
     background, under the 4.5:1 floor (see themes/autoexperten.css). */
  --text-muted: #5A6A72;
  --status-success: var(--brand-primary);
  --status-success-soft: var(--brand-primary-soft);
  --status-info: var(--brand-primary);
  --status-info-soft: var(--brand-primary-soft);
  background: var(--bg-page);
}

body.theme-shop,
body.theme-shop .product-card,
body.theme-shop .product-info,
body.theme-shop .toolbar-content,
body.theme-shop .basket-order-modal,
body.theme-shop .modal-content {
  text-align: left;
}

body.theme-shop .navbar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  min-height: 100px;
}

body.theme-shop .navbar-brand {
  margin: 0 !important;
  padding: 0.75rem 0;
}

body.theme-shop .toolbar {
  background: var(--bg-page);
  border-bottom-color: var(--border-subtle);
}

/* Primary actions in the shop's own colour. */
body.theme-shop .btn-primary,
body.theme-shop .toolbar-cart-btn,
body.theme-shop .product-cta__btn,
body.theme-shop #checkoutNextBtn {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-on-brand);
}

body.theme-shop .btn-primary:hover,
body.theme-shop .btn-primary:focus,
body.theme-shop .toolbar-cart-btn:hover,
body.theme-shop .product-cta__btn:hover,
body.theme-shop #checkoutNextBtn:hover {
  background: var(--brand-primary-hover);
  border-color: var(--brand-primary-hover);
  color: var(--text-on-brand);
}

body.theme-shop .btn-primary:focus-visible {
  box-shadow: 0 0 0 calc(var(--space-1) / 2) var(--brand-primary-ring);
}

body.theme-shop .btn-primary:disabled,
body.theme-shop .btn-primary.disabled {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-on-brand);
  opacity: 0.45;
}

body.theme-shop .toolbar-cart-badge,
body.theme-shop .product-card-badge {
  background: var(--text-primary) !important;
  color: var(--bg-surface) !important;
}

body.theme-shop .product-card:hover,
body.theme-shop .product-gallery__thumb.is-active {
  border-color: var(--brand-primary);
}

body.theme-shop .product-card:focus-visible {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 calc(var(--space-1) / 2) var(--brand-primary-ring);
}

body.theme-shop .product-size-row__hint--existing {
  color: var(--brand-primary);
}

/* Shop customers never need raw product codes. */
body.theme-shop .product-card__sku,
body.theme-shop .product-info__code {
  display: none;
}

/* Product photos ship on white: keep the card media frame white. */
body.theme-shop .product-card__media {
  background: var(--bg-surface);
}

body.theme-shop .product-color-switcher__swatch.is-active {
  border-color: var(--brand-primary);
  background: var(--brand-primary-soft);
}

body.theme-shop .product-color-switcher__swatch:focus-visible {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 calc(var(--space-1) / 2) var(--brand-primary-ring);
}

/* Stable 1:1 gallery frame, as on the Autoexperten detail page. */
body.theme-shop .product-gallery__main {
  aspect-ratio: 1 / 1;
  width: 100%;
}

body.theme-shop .product-gallery__img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Step indicator (cart pop-up and checkout page). */
body.theme-shop .checkout-stepper {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3) var(--space-4);
  list-style: none;
  border-bottom: 1px solid var(--border-default);
}

body.theme-shop .checkout-stepper__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
}

body.theme-shop .checkout-stepper__item:not(:last-child)::after {
  content: '';
  width: var(--space-6);
  height: 2px;
  margin-left: var(--space-2);
  background: var(--border-default);
}

body.theme-shop .checkout-stepper__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: var(--radius-pill);
  background: var(--bg-surface-muted);
  border: 1px solid var(--border-default);
  font-size: var(--font-size-xs);
  font-weight: 700;
}

body.theme-shop .checkout-stepper__item.is-active {
  color: var(--text-primary);
}

body.theme-shop .checkout-stepper__item.is-active .checkout-stepper__num {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-on-brand);
}

body.theme-shop .checkout-stepper__item.is-done .checkout-stepper__num {
  background: var(--brand-primary-soft);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

/* ---- Product page: size picker + add bar ---------------------------------
   product.css is the B2B page's (one roomy row per size, the stepper on its
   own full-width line on phones). A retail buyer picks one or two sizes, so
   here each size is one short line: label left, compact − qty + stepper
   right, on every screen width. The rows form one bordered list. */

body.theme-shop .shop-buy {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

body.theme-shop .product-sizes__heading {
  margin-bottom: var(--space-2);
}

body.theme-shop .product-sizes__list {
  gap: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  overflow: hidden;
}

body.theme-shop .product-size-row,
body.theme-shop .product-size-row.is-pending {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-3);
  background: var(--bg-surface);
  border: 0;
  border-bottom: 1px solid var(--border-subtle);
  border-radius: 0;
}

body.theme-shop .product-size-row:last-child {
  border-bottom: 0;
}

/* A size with a quantity picked gets the shop's soft colour. */
body.theme-shop .product-size-row.is-pending {
  background: var(--brand-primary-soft);
}

body.theme-shop .product-size-row__label {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: var(--space-2);
}

/* The stepper is the shared one (44px .stepper-btn / .stepper-qty from
   design-system.css, same as the B2B product page); only the colours are the
   shop's. */
body.theme-shop .product-size-row__controls .btn {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-primary);
}

body.theme-shop .product-size-row__controls .btn:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

body.theme-shop .product-size-row__controls .btn:disabled {
  background: var(--bg-surface);
  border-color: var(--border-default);
  color: var(--text-muted);
  opacity: 0.5;
}

body.theme-shop .product-size-row__qty {
  border-color: var(--border-default);
}

/* Add bar: the running summary and the button share one line. After adding,
   the confirmation takes the summary's place on that line (the summary would
   only say "Ei valintoja" then); a capped / full-cart warning is longer, so
   it gets a full line of its own above the button. */
body.theme-shop .product-cta {
  gap: var(--space-2) var(--space-3);
  padding-top: var(--space-3);
}

body.theme-shop .product-cta__btn {
  margin-left: auto;
}

body.theme-shop .product-cta .shop-added-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: var(--text-primary);
}

body.theme-shop .product-cta .shop-added-note.d-none {
  display: none;
}

body.theme-shop .shop-added-note__icon {
  flex: none;
  width: var(--space-5);
  height: var(--space-5);
  padding: calc(var(--space-1) / 2);
  border-radius: var(--radius-pill);
  background: var(--brand-primary);
  color: var(--text-on-brand);
}

body.theme-shop .product-cta .shop-added-note.is-capped {
  flex: 1 0 100%;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--status-warning-soft);
}

body.theme-shop .product-cta__btn.is-added,
body.theme-shop .product-cta__btn.is-added:disabled {
  opacity: 1;
}

/* One-column layout (below product.css's 62rem two-column breakpoint): the
   add bar sticks to the bottom of the screen. It is bounded by .shop-buy, so
   it only sticks while the size list is on screen and settles back into
   place under the last size — never over the description or the footer. */
@media (max-width: 61.98rem) {
  body.theme-shop .product-cta {
    position: sticky;
    bottom: 0;
    z-index: 5;
    margin-inline: calc(var(--space-6) * -1);
    padding: var(--space-3) var(--space-6);
    padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom, 0px));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-default);
    box-shadow: 0 calc(var(--space-1) * -1) var(--space-3) calc(var(--space-1) * -1) var(--border-default);
  }

  body.theme-shop .product-cta__summary {
    flex: 1 1 0;
    min-width: 0;
  }

  body.theme-shop .product-cta__btn {
    flex: 0 0 auto;
    min-width: calc(var(--space-10) * 4);
    min-height: calc(var(--space-10) + var(--space-1));
  }
}

@media (max-width: 36rem) {
  body.theme-shop .product-cta {
    margin-inline: calc(var(--space-4) * -1);
    padding-inline: var(--space-4);
  }
}

/* Checkout on a phone: iOS zooms the page in on any field under 16px and leaves
   it zoomed, so the delivery fields use --font-size-md (17px) here, at full
   finger height; the consent tick box and the step buttons are finger-sized too. */
@media (max-width: 767.98px) {
  body.theme-shop .form-control,
  body.theme-shop .form-select {
    min-height: var(--control-height-touch);
    font-size: var(--font-size-md);
  }
}

body.theme-shop .btn:not(.btn-sm) {
  min-height: var(--control-height-touch);
}

body.theme-shop .shop-consent {
  min-height: var(--control-height-touch);
  padding-left: calc(var(--space-6) + var(--space-3));
}

body.theme-shop .shop-consent .form-check-input {
  width: var(--space-6);
  height: var(--space-6);
  margin-top: 0;
  margin-left: calc((var(--space-6) + var(--space-3)) * -1);
}
