/**
 * D11 / Radix / Bootstrap fixes for dynamics_contact locations composite.
 * Loaded after contact-form.css.
 */

/* Top-level form layout only — do not flex table cells. */
form.lfmk-contact-webform.webform-submission-dynamics-contact-form,
.block-webform form.webform-submission-dynamics-contact-form {
  display: flex;
  flex-wrap: wrap;
  column-gap: 190px;
  justify-content: flex-start;
}

/* Locations block: normal block flow, not flex row on cells. */
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table {
  display: block !important;
  flex: 0 0 100% !important;
  width: 100% !important;
  max-width: 100% !important;
}

form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table {
  display: table !important;
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}

form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table td,
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table th,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table td,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table th {
  display: table-cell !important;
  vertical-align: top;
  overflow: visible;
  flex: none !important;
  flex-wrap: nowrap !important;
  column-gap: unset !important;
}

form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table td.webform-multiple-table--operations,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table td.webform-multiple-table--operations {
  width: 56px;
  text-align: center;
  vertical-align: top;
  padding-top: 0.5rem !important;
}

/* Validation / status messages above the table. */
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table > .messages,
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table .messages__wrapper,
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table .messages,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table > .messages,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table .messages__wrapper {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 0 1rem 0 !important;
  float: none !important;
  clear: both;
  position: static !important;
}

/* Location fields stack in the data column. */
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table td[data-drupal-locations-response] .form-group,
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table td[data-drupal-locations-response] .js-form-wrapper,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table td[data-drupal-locations-response] .form-group {
  display: block;
  width: 100%;
  max-width: 390px;
  margin-bottom: 0.75rem;
}

/* Remove location: Webform uses input[type=image], not button. */
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table input.image-button[name*="remove"],
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table input[type="image"][name*="remove"],
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table input.image-button[name*="remove"] {
  width: 32px !important;
  height: 32px !important;
  min-width: 32px !important;
  max-width: 32px !important;
  padding: 6px !important;
  margin: 0 auto !important;
  display: inline-block !important;
  background-color: #fff !important;
  background-repeat: no-repeat !important;
  background-position: center center !important;
  background-size: 16px 16px !important;
  border: 1px solid #a3aaad !important;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: none !important;
}

form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table input.image-button[name*="remove"]:hover,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table input.image-button[name*="remove"]:hover {
  border-color: #337ab7 !important;
  background-color: #f5f9fc !important;
}

/* Add another location — no negative offset from legacy layout. */
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table .webform-multiple-add,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table .webform-multiple-add {
  float: none !important;
  position: static !important;
  top: auto !important;
  margin: 1.25rem 0 0 0 !important;
  width: 100% !important;
  clear: both;
  text-align: left;
}

form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table .webform-multiple-add .button,
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table .webform-multiple-add button,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table .webform-multiple-add .button {
  display: inline-block;
  min-width: 220px;
  margin-top: 0 !important;
}

/* Hide empty table header row (Radix table). */
form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table thead,
.block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table thead {
  display: none;
}

@media (max-width: 768px) {
  form.lfmk-contact-webform.webform-submission-dynamics-contact-form,
  .block-webform form.webform-submission-dynamics-contact-form {
    column-gap: 0;
    flex-direction: column;
  }

  form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table td[data-drupal-locations-response] .form-group,
  .block-webform form.webform-submission-dynamics-contact-form #add_another_location_table td[data-drupal-locations-response] .form-group {
    max-width: 100%;
  }

  form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table,
  .block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table {
    display: block !important;
  }

  form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table tbody,
  form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table tr,
  form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table td,
  .block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table tbody,
  .block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table tr,
  .block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table td {
    display: block !important;
    width: 100% !important;
  }

  form.lfmk-contact-webform.webform-submission-dynamics-contact-form #add_another_location_table table td.webform-multiple-table--operations,
  .block-webform form.webform-submission-dynamics-contact-form #add_another_location_table table td.webform-multiple-table--operations {
    text-align: left;
    padding-bottom: 1rem;
  }
}
