/* =========================================================
   Konfigurator płotki — Etap 3 / v1.2.1
   Frontend modułu bez an_pf_name.
========================================================= */

/* =========================================================
   Bezpieczny akordeon — wzorowany na starszym konfiguratorze.
   Ma ograniczyć wpływ modułu na układ formularza produktu.
========================================================= */

body#product .kp-accordion,
body#product .kp-accordion *,
body#product .kp-configurator,
body#product .kp-configurator * {
  box-sizing: border-box;
}

body#product .kp-accordion {
  width: 100%;
  max-width: 100%;
  margin: 14px 0 16px;
  clear: both;
}

body#product .kp-accordion.kp-is-booting {
  min-height: 54px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body#product .kp-accordion.kp-is-ready {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.16s ease;
}

body#product .kp-accordion__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 50px;
  padding: 12px 15px;
  border: 1px solid #111827;
  border-radius: 12px;
  background: #111827;
  color: #ffffff;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
  text-align: left;
}

body#product .kp-accordion__toggle:hover,
body#product .kp-accordion__toggle:focus {
  background: #000000;
  border-color: #000000;
  color: #ffffff;
  outline: none;
}

body#product .kp-accordion__toggle-arrow {
  flex: 0 0 auto;
  margin-left: 12px;
  font-size: 13px;
  line-height: 1;
  transition: transform 0.22s ease;
}

body#product .kp-accordion.is-open .kp-accordion__toggle-arrow {
  transform: rotate(180deg);
}

body#product .kp-accordion__panel {
  display: none;
}

body#product .kp-accordion.is-open .kp-accordion__panel {
  display: block;
}

@media (prefers-reduced-motion: reduce) {
  body#product .kp-accordion.kp-is-ready,
  body#product .kp-accordion__toggle-arrow {
    transition: none;
  }
}

body#product .kp-configurator {
  width: 100%;
  max-width: 100%;
  margin: 10px 0 0;
  clear: both;
  color: #111827;
}

body#product .kp-configurator__inner {
  padding: 16px 18px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 26px rgba(17, 24, 39, 0.06);
}

body#product .kp-configurator__title {
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.3;
  color: #111827;
}

body#product .kp-configurator__info {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
}

body#product .kp-configurator__info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  line-height: 1.45;
  color: #374151;
}

body#product .kp-configurator__info-row + .kp-configurator__info-row {
  margin-top: 4px;
}

body#product .kp-configurator__info-row strong {
  font-weight: 700;
}

body#product .kp-js-height,
body#product .kp-js-plotek-width {
  font-weight: 800;
  color: #111827;
}

body#product .kp-configurator__section {
  margin-top: 14px;
  text-align: left !important;
}

body#product .kp-configurator__label {
  display: block;
  text-align: left !important;
  margin: 0 0 7px;
  font-size: 17px;
  font-weight: 800;
  line-height: 1.35;
  color: #1f2937;
}

body#product .kp-configurator__input-row {
  display: flex;
  align-items: stretch;
  gap: 10px;
  flex-wrap: nowrap;
}

body#product .kp-configurator__input {
  flex: 0 1 260px;
  width: 260px;
  max-width: 260px;
  min-height: 46px;
  height: 46px;
  padding: 0 14px;
  margin: 0;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font-size: 16px;
  line-height: normal;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

body#product .kp-configurator__input::placeholder {
  color: #8a8f98;
  opacity: 1;
}

body#product .kp-configurator__input:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.12);
  outline: none;
}

body#product .kp-configurator__input.is-locked {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #4b5563;
  cursor: default;
}

body#product .kp-configurator__help {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.45;
  color: #6b7280;
}

body#product .kp-configurator__button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  height: 46px;
  margin: 0;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
}

body#product .kp-configurator__button:active {
  transform: translateY(1px);
}

body#product .kp-configurator__button--primary {
  border: 1px solid #111827;
  background: #111827;
  color: #ffffff;
}

body#product .kp-configurator__button--primary:hover,
body#product .kp-configurator__button--primary:focus {
  border-color: #000000;
  background: #000000;
  color: #ffffff;
  outline: none;
}

body#product .kp-configurator__button--secondary {
  border: 1px solid #d1d5db;
  background: #ffffff;
  color: #111827;
}

body#product .kp-configurator__button--secondary:hover,
body#product .kp-configurator__button--secondary:focus {
  border-color: #111827;
  outline: none;
}

body#product .kp-configurator__pleats {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

body#product .kp-configurator__pleat-option {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: #f9fafb;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.4;
  color: #1f2937;
}

body#product .kp-configurator__pleat-option input {
  margin: 0;
  accent-color: #111827;
}

body#product .kp-configurator__pleat-option strong {
  margin-right: 6px;
  color: #111827;
}

body#product .kp-configurator__message {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
}

body#product .kp-configurator__message.is-info {
  display: block;
  background: #eff6ff;
  color: #1e40af;
}

body#product .kp-configurator__message.is-error {
  display: block;
  background: #fef2f2;
  color: #991b1b;
}

body#product .kp-configurator__result {
  margin: 14px 0 0;
  padding: 14px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f1f5f9;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

body#product .kp-configurator__result.is-visible {
  opacity: 1;
  transform: translateY(0);
}

body#product .kp-configurator__result-line {
  margin-top: 6px;
  color: #1f2937;
  line-height: 1.5;
}

body#product .kp-configurator__result-line:first-child {
  margin-top: 0;
}

body#product .kp-configurator__result-line--main {
  font-size: 20px;
  font-weight: 900;
  color: #111827;
}


/* v1.1.10: bez efektu flash — wynik ma pozostać stabilny przy zmianie marszczenia. */
body#product .kp-configurator__result.is-updated {
  animation: none;
}

body#product .kp-configurator__section--note {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

body#product .kp-configurator__section--note.is-visible {
  opacity: 1;
  transform: translateY(0);
}

body#product .kp-configurator__textarea {
  width: 100%;
  max-width: 520px;
  min-height: 92px;
  padding: 10px 12px;
  border: 1px solid #cfd8e3;
  border-radius: 10px;
  background: #ffffff;
  color: #111827;
  font-size: 14px;
  line-height: 1.45;
  box-sizing: border-box;
  resize: vertical;
}

body#product .kp-configurator__textarea:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.12);
  outline: none;
}

@media (max-width: 768px) {
  body#product .kp-configurator__inner {
    padding: 15px;
  }

  body#product .kp-configurator__input-row {
    flex-direction: column;
    align-items: stretch;
  }

  body#product .kp-configurator__input,
  body#product .kp-configurator__button,
  body#product .kp-configurator__textarea {
    width: 100%;
    max-width: 100%;
    flex: 1 1 100%;
  }

  body#product .kp-configurator__info-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }
}


/* =========================================================
   v1.1.5 — wyrównanie tytułów pól jak w starym konfiguratorze
   oraz twarde zabezpieczenie: moduł nie pokazuje ceny.
========================================================= */

body#product .kp-configurator .kp-configurator__label,
body#product .kp-configurator label.kp-configurator__label,
body#product .kp-configurator div.kp-configurator__label {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  float: none !important;
  clear: both !important;
  margin: 0 0 7px 0 !important;
  padding: 0 !important;
  text-align: left !important;
  transform: none !important;
}

body#product .kp-configurator .kp-configurator__section--width,
body#product .kp-configurator .kp-configurator__section--note {
  text-align: left !important;
}

body#product .kp-configurator .kp-configurator__section--width > .kp-configurator__label,
body#product .kp-configurator .kp-configurator__section--note > .kp-configurator__label {
  text-align: left !important;
  justify-content: flex-start !important;
}

/* Gdyby w cache lub z poprzedniej wersji została dodatkowa linia ceny, ukrywamy ją bez wpływu na wynik. */
body#product .kp-configurator .kp-configurator__price,
body#product .kp-configurator [data-kp-price-line] {
  display: none !important;
}

/* Wersja 1.1.6: gdyby starszy hook zostawił blok w .product-quantity,
   nie pozwalamy mu pracować jako element flex obok ilości i przycisku. */
body#product .product-quantity > .kp-accordion {
  flex: 0 0 100%;
  width: 100%;
  order: -1;
}

/* =========================================================
   Etap 3 — konfiguracja widoczna w koszyku
========================================================= */
.kp-cart-summary {
  margin: 10px 0 0;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f8fafc;
  color: #111827;
  font-size: 13px;
  line-height: 1.45;
  clear: both;
}

.kp-cart-summary__title {
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
  color: #111827;
}

.kp-cart-summary__row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 3px;
}

.kp-cart-summary__row span,
.kp-cart-summary__note span {
  color: #475569;
}

.kp-cart-summary__row strong,
.kp-cart-summary__note strong {
  color: #111827;
  font-weight: 800;
}

.kp-cart-summary__row--main strong {
  font-size: 14px;
}

.kp-cart-summary__note {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid #e5e7eb;
}

.kp-cart-summary__note span,
.kp-cart-summary__note strong {
  display: block;
}

/* v1.2.3 — przycisk dodania przez konfigurator, jak w konfigurator_firany */
.kp-configurator__actions {
  margin-top: 16px;
}

.kp-configurator__button--cart {
  width: 100%;
  justify-content: center;
  background: #111;
  color: #fff;
  border-color: #111;
  min-height: 46px;
  font-weight: 700;
}

.kp-configurator__button--cart:hover,
.kp-configurator__button--cart:focus {
  background: #000;
  color: #fff;
}


/* v1.2.5 — konfiguracja w oknie modal po dodaniu do koszyka */
.kp-modal-config {
  margin-top: 12px;
  padding: 12px 14px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f8fafc;
  color: #111827;
  font-size: 14px;
  line-height: 1.45;
}

.kp-modal-config__title {
  margin-bottom: 7px;
  font-size: 14px;
  font-weight: 800;
  color: #111827;
}

.kp-modal-config__row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 3px;
}

.kp-modal-config__row span,
.kp-modal-config__note span {
  color: #475569;
}

.kp-modal-config__row strong,
.kp-modal-config__note strong {
  color: #111827;
  font-weight: 800;
}

.kp-modal-config__row--main strong {
  font-size: 15px;
}

.kp-modal-config__note {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid #e5e7eb;
}

.kp-modal-config__note span,
.kp-modal-config__note strong {
  display: block;
}


/* v1.2.6 — modal jak w konfigurator_firany: prawa kolumna zamiast bloku pod zdjęciem */
body.kp-modal-preparing #blockcart-modal .bcx-info-col,
body.kp-modal-preparing #blockcart-modal .modal-body .divide-right .row > .col-md-6:last-child {
  visibility: hidden;
}

#blockcart-modal .bcx-info-col {
  min-width: 0;
}

#blockcart-modal .kp-modal-product-title {
  color: #24b9d7;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 4px;
}

#blockcart-modal .kp-modal-product-price {
  color: #111827;
  font-size: 15px;
  line-height: 1.35;
  margin-bottom: 14px;
}

#blockcart-modal .kp-modal-config,
#blockcart-modal .kp-modal-config * {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}


/* =========================================================
   v1.3.3 – marszczenia jak w konfigurator_firany
   Miniaturka + powiększenie po najechaniu, bez dublowania opisu
========================================================= */
body#product .kp-configurator__pleats {
  overflow: visible !important;
}

body#product .kp-configurator__pleat-option {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  min-height: 52px !important;
  overflow: visible !important;
}

body#product .kp-configurator__pleat-option input[type="radio"] {
  flex: 0 0 auto !important;
  width: auto !important;
  height: auto !important;
}

body#product .kp-configurator__pleat-thumb-wrap {
  position: relative !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex: 0 0 42px !important;
  width: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  overflow: visible !important;
}

body#product img.kp-configurator__pleat-thumb {
  display: block !important;
  flex: 0 0 42px !important;
  width: 42px !important;
  min-width: 42px !important;
  max-width: 42px !important;
  height: 42px !important;
  min-height: 42px !important;
  max-height: 42px !important;
  object-fit: cover !important;
  border: 1px solid #d1d5db !important;
  border-radius: 6px !important;
  background: #fff !important;
  cursor: zoom-in !important;
}

body#product .kp-configurator__pleat-text {
  flex: 1 1 auto !important;
  min-width: 0 !important;
  text-align: left !important;
}

body#product .kp-configurator__pleat-preview {
  position: absolute !important;
  left: 52px !important;
  top: 50% !important;
  z-index: 99999 !important;
  display: none !important;
  width: 300px !important;
  max-width: 72vw !important;
  height: auto !important;
  padding: 8px !important;
  background: #fff !important;
  border: 1px solid #d1d5db !important;
  border-radius: 10px !important;
  box-shadow: 0 14px 34px rgba(17, 24, 39, 0.22) !important;
  pointer-events: none !important;
  transform: translateY(-50%) !important;
}

body#product .kp-configurator__pleat-preview img {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  height: auto !important;
  max-height: 420px !important;
  object-fit: contain !important;
  border-radius: 8px !important;
  background: #fff !important;
}

body#product .kp-configurator__pleat-thumb-wrap:hover .kp-configurator__pleat-preview,
body#product .kp-configurator__pleat-thumb-wrap:focus-within .kp-configurator__pleat-preview,
body#product .kp-configurator__pleat-thumb-wrap.is-open .kp-configurator__pleat-preview {
  display: block !important;
}

@media (max-width: 768px) {
  body#product .kp-configurator__pleat-preview {
    left: 0 !important;
    top: auto !important;
    bottom: calc(100% + 8px) !important;
    width: min(260px, 78vw) !important;
    transform: none !important;
  }
}


/* =========================================================
   v1.3.7 — dymki informacyjne przy wymiarach jak w konfigurator_firany
========================================================= */

body#product .kp-field-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  vertical-align: middle;
  cursor: help;
  z-index: 20;
}

body#product .kp-field-tooltip-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #e8eef7;
  color: #26364d;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
}

body#product .kp-field-tooltip-box {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  width: 300px;
  max-width: min(300px, calc(100vw - 28px));
  padding: 10px 12px;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #ffffff;
  color: #111827;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  box-shadow: 0 10px 24px rgba(17, 24, 39, 0.16);
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
  z-index: 1000;
}

body#product .kp-field-tooltip-box::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-right: 1px solid #d7dee8;
  border-bottom: 1px solid #d7dee8;
  transform: translateX(-50%) rotate(45deg);
}

body#product .kp-field-tooltip:hover .kp-field-tooltip-box,
body#product .kp-field-tooltip:focus .kp-field-tooltip-box,
body#product .kp-field-tooltip:focus-within .kp-field-tooltip-box {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 767px) {
  body#product .kp-field-tooltip-box {
    position: fixed;
    left: 50%;
    top: var(--kp-tooltip-mobile-top, 96px);
    bottom: auto;
    width: min(300px, calc(100vw - 28px));
    transform: translateX(-50%) translateY(4px);
  }

  body#product .kp-field-tooltip:hover .kp-field-tooltip-box,
  body#product .kp-field-tooltip:focus .kp-field-tooltip-box,
  body#product .kp-field-tooltip:focus-within .kp-field-tooltip-box {
    transform: translateX(-50%) translateY(0);
  }

  body#product .kp-field-tooltip-box::after {
    display: none;
  }
}


/* =========================================================
   v1.3.13 — przyciski wymiaru jak w konfigurator_firany
   - zatwierdzanie: czarny przycisk
   - edycja zatwierdzonego wymiaru: jasny przycisk z zielonym ✓
========================================================= */
body#product .kp-configurator .kp-js-confirm-width,
body#product .kp-configurator .kp-js-edit-width {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  height: 46px;
  margin: 0;
  padding: 0 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  box-sizing: border-box;
  cursor: pointer;
  box-shadow: none;
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.12s ease;
}

body#product .kp-configurator .kp-js-confirm-width {
  border: 1px solid #111827 !important;
  background: #111827 !important;
  color: #ffffff !important;
}

body#product .kp-configurator .kp-js-confirm-width:hover,
body#product .kp-configurator .kp-js-confirm-width:focus {
  border-color: #000000 !important;
  background: #000000 !important;
  color: #ffffff !important;
  outline: none;
}

body#product .kp-configurator .kp-js-edit-width {
  border: 1px solid #9ca3af !important;
  background: #ffffff !important;
  color: #111827 !important;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.04);
}

body#product .kp-configurator .kp-js-edit-width:hover,
body#product .kp-configurator .kp-js-edit-width:focus {
  border-color: #6b7280 !important;
  background: #f3f4f6 !important;
  color: #111827 !important;
  outline: none;
}

body#product .kp-configurator .kp-js-edit-width::before {
  content: "✓";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

body#product .kp-configurator .kp-js-confirm-width:active,
body#product .kp-configurator .kp-js-edit-width:active {
  transform: translateY(1px);
}


/* =========================================================
   v1.3.14 — podgląd marszczenia z lewej + stabilna wysokość input/przycisk
   - desktop: powiększenie miniatury otwiera się po lewej stronie opcji,
     żeby nie zasłaniać listy marszczeń
   - input i przycisk wymiaru wymuszone jak w konfigurator_firany
========================================================= */
body#product .kp-configurator .kp-configurator__input,
body#product .kp-configurator input.kp-configurator__input {
  min-height: 46px !important;
  height: 46px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: normal !important;
  box-sizing: border-box !important;
}

body#product .kp-configurator .kp-js-confirm-width,
body#product .kp-configurator .kp-js-edit-width,
body#product .kp-configurator button.kp-configurator__button {
  min-height: 46px !important;
  height: 46px !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  line-height: 1 !important;
  align-items: center !important;
  justify-content: center !important;
  box-sizing: border-box !important;
}

@media (min-width: 769px) {
  body#product .kp-configurator,
  body#product .kp-configurator__body,
  body#product .kp-configurator__section,
  body#product .kp-configurator__pleats,
  body#product .kp-configurator__pleat-option,
  body#product .kp-configurator__pleat-thumb-wrap {
    overflow: visible !important;
  }

  body#product .kp-configurator__pleat-preview {
    left: auto !important;
    right: calc(100% + 12px) !important;
    top: 50% !important;
    bottom: auto !important;
    width: 300px !important;
    max-width: min(300px, 34vw) !important;
    transform: translateY(-50%) !important;
    z-index: 2147482000 !important;
  }

  body#product .kp-configurator__pleat-preview::after {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border-top: 1px solid #d1d5db;
    border-right: 1px solid #d1d5db;
    transform: translate(-5px, -50%) rotate(45deg);
  }
}
