/* ======================================================
   DONATION AMOUNT ELEMENT CUSTOMIZATION
   ====================================================== */

/* 2 & 5. Set whole "Donation Amount" element to 50% max-width & responsive for mobile (STEP 1 ONLY) */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2--wrapper"],
.webform-submission-form:not(.webform-preview) .form-item-donation-amount2,
.webform-submission-form:not(.webform-preview) .js-form-item-donation-amount2,
.webform-submission-form:not(.webform-preview) fieldset[id*="donation-amount2"] {
  display: block !important;
  width: 50% !important; /* 50% width on desktop */
  max-width: 100% !important; /* Prevents breaking out on mobile */
  float: none !important;
  clear: both !important;
  margin: 0 0 16px 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}

/* 1. Make the "Donation Amount" title text NOT bold (STEP 1 ONLY) */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2--wrapper"] legend,
.webform-submission-form:not(.webform-preview) .form-item-donation-amount2 > label,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2--wrapper"] .fieldset-legend {
  display: block !important;
  width: 100% !important;
  font-weight: normal !important; /* Removes bold */
  font-size: 16px !important;
  margin-bottom: 12px !important;
  padding: 0 !important;
}

/* ROW 2: The 4 Buttons side-by-side in 1 horizontal row within the 50% element */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] .form-radios,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] .fieldset-wrapper,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] .js-webform-radios,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2--wrapper"] .fieldset-wrapper {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  gap: 8px !important;
  width: 100% !important;
  margin: 0 0 10px 0 !important;
  padding: 0 !important;
}

/* 4 Equal-width buttons inside the container */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] .form-type-radio,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] .js-form-type-radio {
  display: flex !important;
  flex: 1 1 calc(25% - 6px) !important;
  width: auto !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Hide native circular radio dot */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] input[type="radio"] {
  position: absolute !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
}

/* Unselected button styling */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] label {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
  min-height: 44px !important;
  box-sizing: border-box !important;
  margin: 0 !important;
  padding: 6px 8px !important;
  background-color: #ffffff !important;
  color: #333333 !important;
  border: 1px solid #d0d0d0 !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  text-align: center !important;
  cursor: pointer !important;
  transition: all 0.2s ease-in-out !important;
}

/* Hover state */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] label:hover {
  border-color: #d83b01 !important;
}

/* Selected state */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] input[type="radio"]:checked + label,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] input[type="radio"]:checked ~ label {
  background-color: #d83b01 !important;
  border-color: #d83b01 !important;
  color: #ffffff !important;
}

/* 3. ROW 3: Input field spans 100% of the 50% container */
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] input[type="text"],
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2-other"],
.webform-submission-form:not(.webform-preview) .form-item-donation-amount2-others,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2-others--wrapper"] {
  flex: 1 0 100% !important;
  width: 100% !important;
  min-height: 44px !important;
  box-sizing: border-box !important;
  margin-top: 8px !important;
  border: 1px solid #d0d0d0 !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  clear: both !important;
}

/* Hide duplicate label for 'Other' text input if present */
.webform-submission-form:not(.webform-preview) .form-item-donation-amount2-others > label,
.webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2-others--wrapper"] label {
  display: none !important;
}

/* 5. Mobile Responsiveness (< 768px): Expand container to 100% on small screens */
@media screen and (max-width: 768px) {
  .webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2--wrapper"],
  .webform-submission-form:not(.webform-preview) .form-item-donation-amount2,
  .webform-submission-form:not(.webform-preview) .js-form-item-donation-amount2,
  .webform-submission-form:not(.webform-preview) fieldset[id*="donation-amount2"] {
    width: 100% !important; /* Full width on mobile screens so it won't overflow */
  }

  .webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] .form-type-radio,
  .webform-submission-form:not(.webform-preview) [id*="edit-donation-amount2"] .js-form-type-radio {
    flex: 1 1 calc(50% - 4px) !important; /* Switches to 2x2 grid on mobile for optimal fit */
  }
}

/* ======================================================
   STRICT OVERRIDE FOR DRUPAL INLINE ERROR MESSAGE
   ====================================================== */

/* Target the exact label ID created by client-side validation */
#edit-donation-amount2-other-error,
label#edit-donation-amount2-other-error,
.webform-submission-form #edit-donation-amount2-other-error {
  display: block !important;
  width: 100% !important;
  background: none !important;
  background-color: transparent !important;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 4px 0 0 0 !important;
  margin: 0 !important;
  color: #e63946 !important; /* Red text */
  font-size: 13px !important;
  font-weight: normal !important;
  text-align: left !important;
  position: relative !important;
}

/* Strip any background/icons from pseudo-elements on this ID */
#edit-donation-amount2-other-error::before,
#edit-donation-amount2-other-error::after {
  content: none !important;
  display: none !important;
}

/* Highlight input border in red when invalid */
#edit-donation-amount2-other.error,
.webform-submission-form input.error {
  border: 1px solid #e63946 !important;
  box-shadow: none !important;
}

/* ======================================================
   PREVIEW / CONFIRMATION STEP STYLES (ISOLATED TO PREVIEW)
   ====================================================== */

/* 1. Target the Fieldset wrapper on the Preview step */
.webform-preview fieldset[id*="donation-amount2"],
.webform-preview [data-webform-key="donation_amount"],
.webform-preview .webform-preview-element-donation_amount {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 12px !important;
  width: 100% !important;
  margin-bottom: 0.75rem !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
}

/* 2. Label sitting on the left */
.webform-preview fieldset[id*="donation-amount2"] > legend,
.webform-preview [data-webform-key="donation_amount"] legend,
.webform-preview .webform-preview-element-donation_amount .webform-preview-label {
  display: inline-block !important;
  width: auto !important;
  min-width: 0 !important;
  flex: 0 0 auto !important;
  font-weight: bold !important;  /* Make title bold in preview */
  color: #333333 !important;
  margin: 0 !important;
  padding: 0 !important;
  float: none !important;
}

/* 3. Value sitting directly next to label */
.webform-preview fieldset[id*="donation-amount2"] > .fieldset-wrapper,
.webform-preview [data-webform-key="donation_amount"] .webform-preview-value,
.webform-preview .webform-preview-element-donation_amount .webform-preview-value {
  display: inline-block !important;
  width: auto !important;
  flex: 0 0 auto !important;
  font-weight: normal !important;
  margin: 0 !important;
  padding: 0 !important;
}