/* PartsPC one-page checkout - xkom style
 * Forces all reachable steps to display simultaneously,
 * provides 2-column layout with sticky cart summary.
 */

/* === Force all reachable/complete steps to be expanded simultaneously === */
body#checkout.ppc-onepage .checkout-step.-reachable .content,
body#checkout.ppc-onepage .checkout-step.-complete .content,
body#checkout.ppc-onepage .checkout-step.-current .content {
  display: block !important;
}

/* Hide PS step headers (we render our own titles inside step body) */
body#checkout.ppc-onepage .checkout-step__header {
  display: none !important;
}

/* Hide step entirely only if it is BOTH unreachable AND not reachable AND not complete.
   PS sometimes adds -unreachable to a step that is also -reachable (state bug after submit) —
   we must keep it visible in that case. */
body#checkout.ppc-onepage .checkout-step.-unreachable:not(.-reachable):not(.-complete):not(.-current) {
  display: none;
}

/* Card wrapper around the whole process - flat */
body#checkout.ppc-onepage .cart-grid-body .card {
  background: transparent;
  border: none;
  box-shadow: none;
}
body#checkout.ppc-onepage .cart-grid-body .card .card-body,
body#checkout.ppc-onepage .cart-grid-body .card-body {
  padding: 0;
}

/* === Each step becomes a card === */
body#checkout.ppc-onepage .checkout-step {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin-bottom: 18px;
  padding: 22px 24px;
  border-top: 1px solid #e2e8f0 !important; /* override PS rule */
}
body#checkout.ppc-onepage .checkout-step .content {
  border-top: none !important;
  padding: 0;
}

/* Custom section title (injected by JS) */
.ppc-section-heading {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 16px;
  padding: 0;
}
.ppc-section-heading-sub {
  font-size: 0.82rem;
  color: #64748b;
  font-weight: 400;
  margin: -10px 0 14px;
}

/* === Page header (Dostawa i platnosc) === */
.ppc-page-header {
  margin-bottom: 18px;
}
.ppc-page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin: 0 0 4px;
  color: #1e293b;
}
.ppc-page-header p {
  font-size: 0.88rem;
  color: #64748b;
  margin: 0;
}

/* === "Kupujesz jako" toggle === */
.ppc-buyer-type {
  display: flex;
  gap: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  background: #f8fafc;
}
.ppc-buyer-type__btn {
  flex: 1;
  padding: 14px 16px;
  background: transparent;
  border: none;
  font-size: 0.92rem;
  font-weight: 600;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.ppc-buyer-type__btn:hover {
  background: #f1f5f9;
}
.ppc-buyer-type__btn.is-active {
  background: #fff;
  color: #1e293b;
  box-shadow: inset 0 0 0 2px #007bff;
  border-radius: 10px;
}

/* === Hide PS Continue buttons (we use single bottom button) ===
   BUT keep visible when inside inline new-address form (delivery-address / invoice-address)
   — that's the "Save address" button user needs when adding a new address. */
body#checkout.ppc-onepage button[name="confirmDeliveryOption"] {
  display: none !important;
}
body#checkout.ppc-onepage button[name="confirm-addresses"] {
  display: none !important;
}
body#checkout.ppc-onepage #delivery-address button[name="confirm-addresses"],
body#checkout.ppc-onepage #invoice-address button[name="confirm-addresses"],
body#checkout.ppc-onepage #delivery-address button[type="submit"],
body#checkout.ppc-onepage #invoice-address button[type="submit"] {
  display: inline-block !important;
}

/* Hide PS "Złóż zamówienie" inside payment step — but keep it CLICKABLE
   (our bottom button triggers it via .click()). Use visually-hidden trick. */
body#checkout.ppc-onepage #checkout-payment-step #payment-confirmation button.btn-primary.btn-lg {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  pointer-events: auto;
}
/* Keep terms checkbox visible (we need user to accept) */

/* But keep the form structure, hide visually only */
body#checkout.ppc-onepage form .text-right.mt-3:has(button[name="confirmDeliveryOption"]) {
  display: none;
}

/* === Address step rewrite === */
/* Hide native PS h2 titles inside address step (we add our own) */
body#checkout.ppc-onepage #checkout-addresses-step h2.h4 {
  display: none;
}
body#checkout.ppc-onepage #checkout-addresses-step .js-address-form > form > p.mb-4 {
  display: none;
}
/* Hide native "use_same_address" checkbox in address form (we have our own UI) */
body#checkout.ppc-onepage #checkout-addresses-step .custom-control:has(#use_same_address) {
  display: none;
}

/* Address summary card */
.ppc-addr-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  margin-bottom: 12px;
}
.ppc-addr-summary__text {
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.6;
}
.ppc-addr-summary__edit {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: #007bff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  transition: background 0.15s;
}
.ppc-addr-summary__edit:hover {
  background: #f0f9ff;
}
.ppc-addr-summary__edit .material-icons {
  font-size: 16px;
}

/* === "Inne dane do faktury" checkbox === */
.ppc-invoice-info {
  font-size: 0.85rem;
  color: #64748b;
  margin: 0 0 12px;
  line-height: 1.5;
}
.ppc-diff-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  margin: 0;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  transition: border-color 0.15s, background 0.15s;
}
.ppc-diff-toggle:hover {
  border-color: #cbd5e1;
  background: #f1f5f9;
}
.ppc-diff-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #007bff;
  flex-shrink: 0;
  margin: 0;
}
.ppc-invoice-form-area {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

/* === Delivery options - improve carrier cards === */
body#checkout.ppc-onepage .delivery-options .checkout-option-block {
  margin-bottom: 10px;
}
body#checkout.ppc-onepage .delivery-options .checkout-option-block .card {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  transition: border-color 0.15s;
}
body#checkout.ppc-onepage .delivery-options .checkout-option-block.selected .card,
body#checkout.ppc-onepage .delivery-options .checkout-option-block:has(input:checked) .card {
  border-color: #007bff;
  background: #f0f9ff;
}
body#checkout.ppc-onepage .delivery-options input[type="radio"] {
  position: absolute;
  left: -99999em;
}

/* === Final submit button === */
.ppc-final-submit {
  margin: 22px 0 0;
}
.ppc-final-submit-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 1rem;
  font-weight: 700;
  border-radius: 10px;
  background: #007bff;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ppc-final-submit-btn:hover:not(:disabled) {
  background: #0056b3;
}
.ppc-final-submit-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* === Sticky right column === */
@media (min-width: 992px) {
  body#checkout.ppc-onepage .cart-grid-right {
    position: sticky;
    top: 90px;
    align-self: flex-start;
  }
}

/* === Loading overlay === */
.ppc-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.6;
}
.ppc-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 32px;
  margin: -16px 0 0 -16px;
  border: 3px solid #cbd5e1;
  border-top-color: #007bff;
  border-radius: 50%;
  animation: ppc-spin 0.8s linear infinite;
}
@keyframes ppc-spin {
  to { transform: rotate(360deg); }
}

/* Disabled section overlay (when prerequisite not done) */
.ppc-section-disabled {
  position: relative;
  opacity: 0.55;
  pointer-events: none;
}
.ppc-section-disabled::before {
  content: attr(data-disabled-msg);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 0.88rem;
  color: #475569;
  pointer-events: auto;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Highlight invalid section on validation fail */
.ppc-section-invalid {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Error message under "Przejdź do podsumowania" button */
.ppc-submit-error {
  margin-top: 10px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 0.88rem;
  text-align: center;
  animation: ppc-shake 0.4s;
}

/* Inline error inside invalid section (above content) */
.ppc-section-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #b91c1c;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 14px;
  animation: ppc-shake 0.4s;
}
.ppc-section-error::before {
  content: "⚠";
  font-size: 1rem;
}
@keyframes ppc-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
