/* Controls: button, icon button, fields, select, checkbox / radio / switch, quantity stepper,
   segmented, tag (03-components, S-Core). `.is-hover` / `.is-active` force a state on /dev/ui/. */

/* ---------- cmp.button ---------- */
.np-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--np-c-button-gap);
  height: var(--np-c-button-height-md); padding: 0 var(--np-c-button-paddingX-md);
  border: var(--np-borderWidth-default) solid transparent; border-radius: var(--np-c-button-radius);
  font-family: var(--np-font-family-sans); font-size: 14px; font-weight: var(--np-font-weight-semibold); line-height: 1;
  white-space: nowrap; text-decoration: none; cursor: pointer; -webkit-user-select: none; user-select: none;
}
.np-btn .np-icon { width: var(--np-size-icon-sm); height: var(--np-size-icon-sm); }
.np-btn--sm { height: var(--np-c-button-height-sm); padding: 0 var(--np-c-button-paddingX-sm); font-size: 13px; }
.np-btn--lg { height: var(--np-c-button-height-lg); padding: 0 var(--np-c-button-paddingX-lg); }
.np-btn--block { width: 100%; }

.np-btn--primary { background: var(--np-c-button-primary-bg); border-color: var(--np-c-button-primary-bg); color: var(--np-c-button-primary-fg); }
.np-btn--primary:hover, .np-btn--primary.is-hover { background: var(--np-c-button-primary-bgHover); border-color: var(--np-c-button-primary-bgHover); color: var(--np-c-button-primary-fg); }
.np-btn--primary:active, .np-btn--primary.is-active { background: var(--np-c-button-primary-bgPressed); border-color: var(--np-c-button-primary-bgPressed); }

.np-btn--secondary { background: var(--np-c-button-secondary-bg); border-color: var(--np-c-button-secondary-border); color: var(--np-c-button-secondary-fg); }
.np-btn--secondary:hover, .np-btn--secondary.is-hover { background: var(--np-c-button-secondary-bgHover); color: var(--np-c-button-secondary-fg); }
.np-btn--secondary:active, .np-btn--secondary.is-active { background: var(--np-color-action-secondary-bgPressed); }

.np-btn--tertiary { background: transparent; color: var(--np-c-button-tertiary-fg); padding-inline: var(--np-space-1-5); text-decoration: underline; text-underline-offset: 3px; }
.np-btn--tertiary:hover, .np-btn--tertiary.is-hover { color: var(--np-c-button-tertiary-fgHover); }

.np-btn:disabled, .np-btn[aria-disabled="true"] {
  background: var(--np-c-button-disabled-bg); border-color: var(--np-c-button-disabled-bg);
  color: var(--np-c-button-disabled-fg); cursor: not-allowed; transform: none;
}
.np-btn--tertiary:disabled, .np-btn--tertiary[aria-disabled="true"] { background: transparent; border-color: transparent; }
.np-btn[aria-busy="true"] { cursor: progress; }
/* Only "Dodaj do koszyka" has a success state (2 s, then default). */
.np-btn--success, .np-btn--success:hover { background: var(--np-color-feedback-success-fg); border-color: var(--np-color-feedback-success-fg); color: var(--np-color-text-inverse); }
.np-btn__reason { margin-top: var(--np-space-1); font: var(--np-type-caption); color: var(--np-color-text-secondary); }

/* ---------- cmp.spinner (in buttons and small areas) ---------- */
.np-spinner {
  display: inline-block; flex: none; width: 14px; height: 14px; border-radius: var(--np-radius-full);
  border: var(--np-borderWidth-strong) solid color-mix(in srgb, currentColor 35%, transparent);
  border-top-color: currentColor;
}
.np-spinner--lg { width: var(--np-space-8); height: var(--np-space-8); border-width: 3px; border-color: var(--np-color-border-service); border-top-color: var(--np-color-action-primary-bg); }

/* ---------- cmp.iconButton ---------- */
.np-icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: var(--np-size-control-md); height: var(--np-size-control-md); padding: 0;
  border: var(--np-borderWidth-default) solid transparent; border-radius: var(--np-radius-md);
  background: var(--np-color-bg-page); color: var(--np-color-text-primary); text-decoration: none;
  transition: background-color var(--np-motion-hover), color var(--np-motion-hover);
}
.np-icon-btn .np-icon { width: 22px; height: 22px; stroke-width: 1.8; }
.np-icon-btn:hover, .np-icon-btn.is-hover { background: var(--np-color-bg-subtle); color: var(--np-color-text-primary); }
.np-icon-btn:disabled { color: var(--np-color-action-disabled-fg); background: transparent; cursor: not-allowed; }
@media (max-width: 1023.98px) { .np-icon-btn { width: var(--np-size-control-lg); height: var(--np-size-control-lg); } }
.np-counter {
  position: absolute; top: var(--np-space-0-5); right: 0; min-width: 18px; height: 18px; padding: 0 var(--np-space-1);
  border-radius: var(--np-radius-full); background: var(--np-c-cartCounter-bg); color: var(--np-c-cartCounter-fg);
  font: var(--np-font-weight-semibold) 11px/18px var(--np-font-family-mono); text-align: center;
}

/* ---------- labels, fields (cmp.textField, cmp.numberField, cmp.select) ---------- */
.np-form { display: flex; flex-direction: column; gap: var(--np-space-4); }
.np-field { display: flex; flex-direction: column; gap: var(--np-space-1-5); min-width: 0; }
.np-field__fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: flex; flex-direction: column; gap: var(--np-space-2); }
.np-label { font: var(--np-type-label); letter-spacing: var(--np-type-label-tracking); color: var(--np-color-text-secondary); padding: 0; }
.np-label__optional { font-weight: var(--np-font-weight-regular); color: var(--np-color-text-muted); }
.np-field__help { font: var(--np-type-caption); color: var(--np-color-text-muted); }

.np-input,
.np-field :is(input:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"], [type="button"]), select, textarea) {
  width: 100%; min-width: 0; height: var(--np-c-field-height); padding: 0 var(--np-c-field-paddingX);
  border: var(--np-borderWidth-default) solid var(--np-c-field-border); border-radius: var(--np-c-field-radius);
  background: var(--np-color-bg-page); color: var(--np-color-text-primary);
  font-family: var(--np-font-family-sans); font-size: 14px; font-weight: var(--np-font-weight-medium);
  transition: border-color var(--np-motion-hover);
}
.np-field textarea, textarea.np-input { height: auto; min-height: calc(3 * var(--np-c-field-height)); padding-block: var(--np-space-2-5); resize: vertical; }
.np-input::placeholder, .np-field ::placeholder { color: var(--np-color-text-muted); opacity: 1; }
.np-input:hover, .np-input.is-hover,
.np-field :is(input:not([type="checkbox"], [type="radio"]), select, textarea):hover { border-color: var(--np-c-field-borderHover); }
/* Focus: 2 px border instead of the ring; padding shrinks by 1 px so the text does not jump. */
.np-input:focus, .np-input.is-focus,
.np-field :is(input:not([type="checkbox"], [type="radio"]), select, textarea):focus {
  outline: none; border: var(--np-borderWidth-strong) solid var(--np-c-field-borderFocus); padding-inline: calc(var(--np-c-field-paddingX) - 1px);
}
.np-input[aria-invalid="true"],
.np-field :is(input:not([type="checkbox"], [type="radio"]), select, textarea)[aria-invalid="true"] {
  border: var(--np-borderWidth-strong) solid var(--np-c-field-borderError); padding-inline: calc(var(--np-c-field-paddingX) - 1px);
}
.np-input.is-success { border-color: var(--np-color-feedback-success-fg); }
.np-input:disabled, .np-field :is(input:not([type="checkbox"], [type="radio"]), select, textarea):disabled {
  background: var(--np-c-field-bgDisabled); border-color: var(--np-color-border-default); color: var(--np-color-text-muted); cursor: not-allowed;
}
input.np-input:read-only:not(:disabled), .np-field :is(input, textarea):read-only:not(:disabled, [type="checkbox"], [type="radio"]) {
  background: var(--np-color-bg-muted); border-style: dashed;
}
.np-input--mono { font: var(--np-type-numInput); }
/* iOS zooms into inputs below 16 px. */
@media (max-width: 1023.98px) {
  .np-input, .np-field :is(input:not([type="checkbox"], [type="radio"]), select, textarea) { height: var(--np-size-control-lg); font-size: 16px; }
}

/* Native select with a drawn chevron (two gradients: no image, no raw colour). */
.np-field select, select.np-input {
  appearance: none; padding-right: calc(var(--np-c-field-paddingX) + var(--np-space-5));
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}

/* Number with a unit suffix (UnitNumberInput) */
.np-input-unit { position: relative; display: flex; min-width: 0; }
.np-input-unit > input { font: var(--np-type-numInput) !important; padding-right: calc(var(--np-c-field-suffixWidth) + var(--np-space-3)) !important; }
.np-input-unit__suffix {
  position: absolute; top: 1px; right: 1px; bottom: 1px; width: var(--np-c-field-suffixWidth);
  display: flex; align-items: center; justify-content: center; pointer-events: none;
  background: var(--np-c-field-suffixBg); border-left: var(--np-borderWidth-default) solid var(--np-color-border-default);
  border-radius: 0 var(--np-c-field-radius) var(--np-c-field-radius) 0;
  font: var(--np-type-bodySm); font-weight: var(--np-font-weight-semibold); color: var(--np-color-text-primary);
}
.np-input-unit > input:focus + .np-input-unit__suffix,
.np-input-unit > input[aria-invalid="true"] + .np-input-unit__suffix { top: 2px; right: 2px; bottom: 2px; }

/* ---------- cmp.checkbox / cmp.radio / cmp.switch ---------- */
/* The whole label is the click target, at least 44 px high (WCAG 2.5.8). */
.np-check, .np-field--radioselect label, .np-field--checkboxselectmultiple label {
  display: inline-flex; align-items: center; gap: var(--np-space-2-5); min-height: var(--np-size-control-lg); cursor: pointer;
}
:is(.np-check, .np-field) :is(input[type="checkbox"]:not([role="switch"]), input[type="radio"]) {
  appearance: none; flex: none; display: inline-grid; place-content: center; margin: 0;
  width: var(--np-space-5); height: var(--np-space-5); background: var(--np-color-bg-page);
  border: 1.5px solid var(--np-color-text-secondary); cursor: pointer;
}
/* Shape in separate rules: inside the shared rule above :is() would raise the specificity. */
:is(.np-check, .np-field) input[type="checkbox"]:not([role="switch"]) { border-radius: var(--np-radius-sm); }
:is(.np-check, .np-field) input[type="radio"] { border-radius: var(--np-radius-full); }
:is(.np-check, .np-field) input[type="checkbox"]:not([role="switch"]):is(:checked, :indeterminate) {
  background: var(--np-color-action-primary-bg); border-color: var(--np-color-action-primary-bg);
}
/* Check mark drawn with borders, the dash for "mixed" with a bar. */
:is(.np-check, .np-field) input[type="checkbox"]:not([role="switch"]):checked::before {
  content: ""; width: 6px; height: 11px; margin-top: -2px;
  border: solid var(--np-color-action-primary-fg); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
:is(.np-check, .np-field) input[type="checkbox"]:not([role="switch"]):indeterminate::before {
  content: ""; width: 10px; height: 2px; background: var(--np-color-action-primary-fg);
}
:is(.np-check, .np-field) input[type="radio"]:checked { border: var(--np-borderWidth-strong) solid var(--np-color-action-primary-bg); }
:is(.np-check, .np-field) input[type="radio"]:checked::before {
  content: ""; width: 10px; height: 10px; border-radius: var(--np-radius-full); background: var(--np-color-action-primary-bg);
}
:is(.np-check, .np-field) :is(input[type="checkbox"]:not([role="switch"]), input[type="radio"]):disabled {
  border-color: var(--np-color-border-default); background: var(--np-color-action-disabled-bg); cursor: not-allowed;
}

/* Switch (SwitchInput): 40 x 24, only for instant settings such as «Ceny netto». */
input[type="checkbox"][role="switch"] {
  appearance: none; position: relative; flex: none; margin: 0;
  width: var(--np-space-10); height: var(--np-space-6); border: 0; border-radius: var(--np-radius-full);
  background: var(--np-color-border-strong); cursor: pointer; transition: background-color var(--np-motion-hover);
}
input[type="checkbox"][role="switch"]::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: var(--np-radius-full); background: var(--np-color-bg-page);
  transition: transform var(--np-duration-base) var(--np-easing-standard);
}
input[type="checkbox"][role="switch"]:checked { background: var(--np-color-action-primary-bg); }
input[type="checkbox"][role="switch"]:checked::before { transform: translateX(var(--np-space-4)); }
input[type="checkbox"][role="switch"]:disabled { background: var(--np-color-action-disabled-bg); cursor: not-allowed; }

/* ---------- cmp.quantityStepper ---------- */
.np-stepper-wrap { display: inline-flex; flex-direction: column; align-items: flex-start; gap: var(--np-space-1-5); }
.np-stepper {
  display: inline-flex; align-items: stretch; height: var(--np-size-control-md);
  border: var(--np-borderWidth-default) solid var(--np-c-field-border); border-radius: var(--np-c-field-radius);
  background: var(--np-color-bg-page); transition: opacity var(--np-duration-base) linear;
}
.np-stepper__btn {
  width: var(--np-size-control-md); padding: 0; border: 0; background: transparent; color: var(--np-color-text-primary);
  display: flex; align-items: center; justify-content: center;
}
.np-stepper__btn:hover:not(:disabled) { background: var(--np-color-bg-subtle); }
.np-stepper__btn:disabled { color: var(--np-color-action-disabled-fg); cursor: not-allowed; }
.np-stepper__field {
  display: flex; align-items: center; justify-content: center; gap: var(--np-space-1);
  min-width: 52px; padding: 0 var(--np-space-2);
  border-inline: var(--np-borderWidth-default) solid var(--np-color-border-default);
}
.np-stepper__input {
  width: 4ch; min-width: 0; padding: 0; border: 0; background: transparent; text-align: center;
  font: var(--np-type-numInput); font-variant-numeric: tabular-nums;
}
.np-stepper__input:focus { outline: none; }
.np-stepper__field:focus-within { outline: var(--np-focus-ring); outline-offset: -2px; }
.np-stepper__unit { font: var(--np-type-numInput); color: var(--np-color-text-secondary); }
.np-stepper.is-invalid { border: var(--np-borderWidth-strong) solid var(--np-c-field-borderError); }
.np-stepper[aria-busy="true"] { opacity: .6; }
@media (max-width: 1023.98px) {
  .np-stepper { height: var(--np-size-control-lg); }
  .np-stepper__btn { width: var(--np-size-control-lg); }
  .np-stepper__input { font-size: 16px; }
}

/* ---------- cmp.segmented (radiogroup, at most 3 options) ---------- */
.np-segmented { margin: 0; padding: 0; border: 0; min-width: 0; }
.np-segmented__options {
  display: inline-flex; border: var(--np-borderWidth-default) solid var(--np-color-border-inverse);
  border-radius: var(--np-radius-md); overflow: hidden;
}
.np-segmented__option { position: relative; display: flex; }
.np-segmented__option input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.np-segmented__option span {
  display: flex; align-items: center; min-height: var(--np-size-control-md); padding: 0 var(--np-space-4);
  font: var(--np-type-bodySm); font-weight: var(--np-font-weight-semibold);
  transition: background-color var(--np-motion-hover), color var(--np-motion-hover);
}
.np-segmented__option + .np-segmented__option span { border-left: var(--np-borderWidth-default) solid var(--np-color-border-inverse); }
.np-segmented__option input:checked + span { background: var(--np-color-bg-inverse); color: var(--np-color-text-inverse); }
.np-segmented__option input:focus-visible + span, .np-segmented__option.is-focus span { outline: var(--np-focus-ring); outline-offset: -4px; }
.np-segmented__option input:disabled + span { color: var(--np-color-action-disabled-fg); text-decoration: line-through; cursor: not-allowed; }

/* ---------- cmp.tag: accent, real data only, max one per card ---------- */
.np-tag {
  display: inline-flex; align-items: center; height: var(--np-c-tag-height); padding: 0 var(--np-c-tag-paddingX);
  border-radius: var(--np-c-tag-radius); background: var(--np-c-tag-bg); color: var(--np-c-tag-fg);
  font: var(--np-type-overline); font-size: 11.5px; letter-spacing: var(--np-type-overline-tracking); white-space: nowrap;
}
.np-segmented > .np-label { display: block; margin-bottom: var(--np-space-1-5); }
