/**
 * m4p_buyonrequest – purchase-on-request button and modal
 */
.m4p_buyonrequest-wrap {
  width: 100%;
  border-top: 2px solid lightgray;
  padding-top: var(--gap-lg);
}

.m4p_buyonrequest-wrap button {
  width: 50%;

  @media (max-width: 768px) {
    width: 100%;
  }
}

.m4p_buyonrequest-wrap:has(.m4p_buyonrequest-error:not(:empty)) .messages-wrapper {
  margin-top: 1rem;
}

.m4p_buyonrequest-wrap .messages-wrapper .m4p_buyonrequest-success,
.m4p_buyonrequest-wrap .messages-wrapper .m4p_buyonrequest-error {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  width: 50%;

  @media (max-width: 768px) {
    width: 100%;
  }
}

.product-miniature .messages-wrapper .m4p_buyonrequest-success,
.product-miniature .messages-wrapper .m4p_buyonrequest-error {
  width: 100%;
}

.m4p_buyonrequest-wrap .messages-wrapper .m4p_buyonrequest-success {
    background-color: #28a745;
    border-color: #28a745;
    color: #fff;
}

.m4p_buyonrequest-wrap .messages-wrapper .m4p_buyonrequest-error {
  background-color: #f8d7da;
  border-color: #f8d7da;
  color: #721c24;
}

.m4p_buyonrequest-miniature-wrap .messages-wrapper {
  margin-bottom: 0.5rem;
}

.m4p_buyonrequest-miniature-wrap {
  border: none;
  padding: 0;
}

.m4p_buyonrequest-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

body:not(.page-product) .m4p_buyonrequest-modal {
  display: none;
}

.m4p_buyonrequest-modal.m4p_buyonrequest-modal-open {
  pointer-events: auto;
  visibility: visible;
  opacity: 1;
  display: flex !important;
}

.m4p_buyonrequest-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.m4p_buyonrequest-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
}

.m4p_buyonrequest-modal-content {
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.m4p_buyonrequest-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #eee;
}

.m4p_buyonrequest-modal-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.m4p_buyonrequest-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  color: #666;
}

.m4p_buyonrequest-modal-close:hover {
  color: #333;
}

.m4p_buyonrequest-modal-body {
  padding: 1.25rem;
}

.m4p_buyonrequest-form-group {
  margin-bottom: 1rem;
}

.m4p_buyonrequest-form-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 500;
}

.m4p_buyonrequest-form-group .required {
  color: #c00;
}

.m4p_buyonrequest-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 1rem;
}

.m4p_buyonrequest-modal-message {
  margin: 0.75rem 0 0;
  padding: 0.5rem;
  border-radius: 4px;
}

.m4p_buyonrequest-modal-message.m4p_buyonrequest-success {
  background: #d4edda;
  color: #155724;
}

.m4p_buyonrequest-modal-message.m4p_buyonrequest-error {
  background: #f8d7da;
  color: #721c24;
}

.m4p_buyonrequest-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid #eee;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
}

.m4p_buyonrequest-btn[aria-busy="true"] {
  opacity: 0.7;
  cursor: wait;
}

/* Hide native out-of-stock flag when "Pod rezerwację" is shown (product page and miniatures) */
#main[data-can-be-buy-on-request="true"] .product-flag.out_of_stock,
.product-miniature:has([data-can-be-buy-on-request="true"]) .product-flag.out_of_stock {
  display: none !important;
}

/* "Pod rezerwację" flag: primary color */
.product-flag.m4p-flag-buy-on-request {
  background-color: var(--primary, #000) !important;
  color: #fff !important;
}

/* Product list: position reservation flag at top of card (with other flags) */
.product-miniature:has(.m4p-buyonrequest-flag-wrp) {
  position: relative;
}
.product-miniature .m4p-buyonrequest-flag-wrp {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
}

/* Miniature: hide "Poinformuj o dostępności" when we show "Zamów" (buy on request) */
.product-miniature[data-can-be-buy-on-request="true"] .inform-when-available {
  display: none !important;
}