/* Keep all overrides inside MShop address forms and dialogs. */
.cwa-fields, .msaddr-search-popup, .mshop_address_search, .msaddr_edit_address_popup, #pafw-dc-address {
  --cwa-purple: var(--cw-primary, var(--cwm-purple, #6b37e8));
  --cwa-purple-hover: var(--cw-primary-hover, #592dc5);
  --cwa-text: var(--cw-text, #171719);
  --cwa-muted: #746b83;
  --cwa-line: #e8e3f0;
  --cwa-soft: #f6f3fd;
  font-family: 'hallymr', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--cwa-text);
  box-sizing: border-box;
}
.cwa-fields *, .msaddr-search-popup *, .mshop_address_search *, .msaddr_edit_address_popup *, #pafw-dc-address * { box-sizing: border-box; }
body .woocommerce .cwa-fields:not(.msaddr_widget), body .msaddr_edit_address_popup form.cwa-fields { padding: 28px; border: 1px solid var(--cwa-line); border-radius: 24px; background: #fff; }
/* WooCommerce's last email/phone columns can float past their field wrapper. */
body .cwa-fields .woocommerce-billing-fields__field-wrapper,
body .cwa-fields .woocommerce-shipping-fields__field-wrapper,
body .cwa-fields .woocommerce-address-fields__field-wrapper { display: flow-root; }
body .woocommerce .cwa-fields:not(.msaddr_widget)::after,
body .msaddr_edit_address_popup form.cwa-fields::after { content: ''; display: table; clear: both; }
body .cwa-fields .form-row, body .cwa-fields .field { margin-bottom: 18px; }
body .cwa-fields label { margin-bottom: 8px; color: #3e384b; font-family: inherit; font-size: 14px; font-weight: 700; line-height: 1.5; }
body .cwa-fields input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=button]):not([type=submit]),
body .cwa-fields select, body .cwa-fields textarea,
body.cw-commerce #main .woocommerce .cwa-fields input:not([type=checkbox]):not([type=radio]):not([type=hidden]):not([type=file]):not([type=button]):not([type=submit]),
body.cw-commerce #main .woocommerce .cwa-fields select, body.cw-commerce #main .woocommerce .cwa-fields textarea,
body #pafw-dc-address .destination-search input {
  width: 100%; max-width: 100%; min-width: 0; min-height: 52px; height: auto; margin: 0;
  padding: 13px 16px; border: 1px solid var(--cwa-line); border-radius: 14px;
  background: #fff; color: var(--cwa-text); font-family: inherit; font-size: 16px; line-height: 1.5;
  box-shadow: none; transition: border-color .15s, box-shadow .15s;
}
body .cwa-fields input[readonly] { background: var(--cwa-soft) !important; color: #665773; }
body .cwa-fields input::placeholder, body .cwa-fields textarea::placeholder { color: #91879c; opacity: 1; }
body .cwa-fields :is(input, select, textarea):focus,
body #pafw-dc-address .destination-search input:focus { outline: none; border-color: var(--cwa-purple) !important; box-shadow: 0 0 0 3px rgb(107 55 232 / 12%) !important; }
body .cwa-fields .select2-container { width: 100% !important; max-width: 100%; }
body .cwa-fields .select2-container .select2-selection--single { min-height: 52px; border: 1px solid var(--cwa-line); border-radius: 14px; background: #fff; }
body .cwa-fields .select2-selection--single .select2-selection__rendered { padding: 0 38px 0 16px; line-height: 50px; font-size: 16px; color: var(--cwa-text); }
body .cwa-fields .select2-selection--single .select2-selection__arrow { height: 50px; right: 10px; }
body .cwa-fields input[type=checkbox], body .cwa-fields input[type=radio] { accent-color: var(--cwa-purple); }
body .cwa-fields .required { color: #be2855; }
/* Inline widths belong to the original plugin; override only the postcode layout. */
body .cwa-fields .cwa-postcode-row > label { display: block; margin: 0 0 8px; }
body .cwa-fields .cwa-postcode-controls { display: flex; gap: 10px; align-items: center; width: 100%; }
body .cwa-fields .cwa-postcode-controls > input.postnum { flex: 1; width: 100% !important; min-width: 0; }
body .cwa-fields .cwa-postcode-controls > a { flex-shrink: 0; }
body .cwa-fields a.ms-open-popup-link, body .msaddr_widget input[name="msm_address_search"],
body button.cwa-save-address, body #pafw-dc-address input.save-address,
body .msaddr_shipping_buttons input.msaddr_update, body input.msaddr_edit_btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 52px; height: auto;
  margin: 0; padding: 13px 22px; border: 1px solid #6b37e8; border-radius: 14px;
  background: var(--cw-primary, #6b37e8); color: #fff; font-family: 'hallymr', sans-serif; font-size: 15px; font-weight: 700;
  line-height: 1.5; letter-spacing: 0; text-align: center; text-decoration: none; text-transform: none; white-space: nowrap; cursor: pointer; box-shadow: none;
}
body .cwa-fields a.ms-open-popup-link:hover, body .msaddr_widget input[name="msm_address_search"]:hover,
body button.cwa-save-address:hover, body #pafw-dc-address input.save-address:hover,
body .msaddr_shipping_buttons input.msaddr_update:hover { background: var(--cw-primary-hover, #592dc5); border-color: var(--cw-primary-hover, #592dc5); color: #fff; }
body .cwa-fields a.ms-open-popup-link { background: var(--cwa-purple) !important; border-color: var(--cwa-purple) !important; color: #fff !important; }
body .cwa-fields a.ms-open-popup-link:hover { background: var(--cwa-purple-hover) !important; border-color: var(--cwa-purple-hover) !important; }
body .cwa-fields :is(a, button, input):focus-visible, body button.cwa-save-address:focus-visible { outline: 3px solid #b398f2; outline-offset: 3px; }
body .msaddr_widget .two.fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; margin: 0 0 18px; }
body .msaddr_widget .two.fields > .field { width: 100%; padding: 0; margin: 0; }
body .msaddr_widget .two.fields > .field:empty { display: none; }
body .msaddr_widget .cwa-widget-postcode { display: grid; grid-template-columns: minmax(110px, 1fr) auto; gap: 10px; }
body .msaddr_widget .cwa-widget-postcode input[readonly] { width: 100% !important; }
/* Native Magnific Popup address search retains its result selection handlers. */
body .mfp-content #ms_addr_1.msaddr-search-popup { width: 100%; max-width: 640px; height: min(640px, calc(100vh - 40px)); height: min(640px, calc(100dvh - 40px)); margin: 20px auto; padding: 0; border: 1px solid #e8e3f0; border-radius: 24px; background: #fff; box-shadow: 0 24px 80px rgb(36 17 65 / 20%); overflow: hidden; }
body #ms_addr_1 .msaddr-search-wrap { height: 100%; min-height: 0; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-header { display: flex; align-items: center; flex-shrink: 0; height: auto; min-height: 76px; padding: 16px 22px; background: #f4f0fd; color: #302344; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-header p { float: none; width: auto; min-height: 0 !important; margin: 0 !important; padding: 0 !important; color: #302344 !important; font-size: 20px !important; font-weight: 700; line-height: 1.5 !important; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-header p:last-child { margin-left: auto !important; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-header button.mfp-close { appearance: none; -webkit-appearance: none; width: 44px; height: 44px; margin: 0 !important; border: 1px solid #e0d6f3; border-radius: 14px; color: #6b37e8; background: #fff; opacity: 1; line-height: 42px; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-keyword { flex-shrink: 0; padding: 20px 22px 16px; background: #fff; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-keyword input { min-height: 52px; padding: 13px 16px; border: 1px solid #e8e3f0; border-radius: 14px; background: #faf9fd; font-family: inherit; font-size: 16px; line-height: 1.5; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-keyword input:focus { outline: 0; border-color: #6b37e8; box-shadow: 0 0 0 3px rgb(107 55 232 / 12%); }
body #ms_addr_1 .msaddr-search-wrap .msaddr-search-result { min-height: 0; padding: 0 22px; }
body #ms_addr_1 .msaddr-search-result table { background: #fff; border-collapse: separate; border-spacing: 0; }
body #ms_addr_1 .msaddr-search-result :is(th, td) { padding: 14px 12px; border: 0; border-bottom: 1px solid #e8e3f0; font-family: inherit; font-size: 14px; line-height: 1.6; }
body #ms_addr_1 .msaddr-search-result th { position: sticky; top: 0; background: #f6f3fd; color: #746b83; font-weight: 700; }
body #ms_addr_1 .msaddr-search-result th:first-child { width: 86px; border-radius: 12px 0 0 0; }
body #ms_addr_1 .msaddr-search-result th:last-child { border-radius: 0 12px 0 0; }
body #ms_addr_1 .msaddr-search-result td:first-child { color: #6b37e8; font-weight: 700; }
body #ms_addr_1 .msaddr-search-result tr.address_row:hover { background: #f4f0fd; }
body #ms_addr_1 .msaddr-search-wrap .msaddr-pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; flex-shrink: 0; padding: 16px 22px 20px; }
body #ms_addr_1 .msaddr-pagination input.msaddr-nav-button { width: 36px; height: 36px; margin: 0; border: 1px solid #e8e3f0; border-radius: 10px; background: #fff; color: #746b83 !important; line-height: 1; }
body #ms_addr_1 .msaddr-pagination input.msaddr-page.current { background: #6b37e8 !important; border-color: #6b37e8; color: #fff !important; opacity: 1; }
body #ms_addr_1 .msaddr-pagination input:disabled:not(.current) { opacity: .4; }
/* MShop Members' Semantic UI address widget. */
body .mshop_address_search.ui.modal { border: 1px solid #e8e3f0; border-radius: 24px; overflow: hidden; font-family: 'hallymr', sans-serif; }
body .mshop_address_search.ui.modal > .header { padding: 22px; background: #f4f0fd; color: #302344; font-family: inherit; font-size: 20px; }
body .mshop_address_search.ui.modal > .content { padding: 22px; }
body .mshop_address_search .search_wrapper { height: min(480px, 55vh); min-height: 0; }
body .mshop_address_search input.msaddr_keyword { min-height: 52px; border: 1px solid #e8e3f0; border-radius: 14px; padding: 14px 16px; font-size: 16px; }
body .mshop_address_search table.mshop_address_result { border: 1px solid #e8e3f0; border-radius: 14px; font-family: inherit; font-size: 14px; }
body .mshop_address_search table.mshop_address_result th { background: #f6f3fd; color: #746b83; }
body .mshop_address_search table.mshop_address_result tr.address_row:hover td { background: #f4f0fd; }
body .mshop_address_search .actions { padding: 16px 22px; background: #fff; border-top: 1px solid #e8e3f0; }
body .mshop_address_search .actions .button { min-height: 44px; border-radius: 12px; background: #f4f0fd; color: #6b37e8; }
body .mshop_address_search .actions .positive.button { background: #6b37e8; color: #fff; }
/* Saved destinations and the order address edit dialog. */
body #pafw-dc-address > ul { display: flex; gap: 8px; padding: 6px; border: 0; border-radius: 16px; background: #f4f0fd; }
body #pafw-dc-address > ul > li { flex: 1; border: 0; border-radius: 12px; background: transparent; }
body #pafw-dc-address > ul > li a { display: block; padding: 12px; color: #746b83; text-align: center; font-size: 14px; }
body #pafw-dc-address > ul > li.ui-state-active { border: 0; background: #fff; box-shadow: 0 3px 10px rgb(72 39 117 / 5%); }
body #pafw-dc-address > ul > li.ui-state-active a { color: #6b37e8; }
body #pafw-dc-address .info-panel .history { margin-bottom: 12px; padding: 18px; border: 1px solid #e8e3f0; border-radius: 18px; background: #fff; }
body #pafw-dc-address .info-panel .history.selected { border-color: #6b37e8; background: #f6f3fd !important; }
body #pafw-dc-address .pafw-icon::before { color: #6b37e8 !important; }
body .msaddr_edit_address_popup .edit_address_popup_wrapper { border: 1px solid #e8e3f0; border-radius: 24px; box-shadow: 0 24px 80px rgb(36 17 65 / 20%); overflow: hidden; }
body .msaddr_edit_address_popup .edit_address_popup_head { background: #f4f0fd; color: #302344; padding: 18px 22px; }
body .msaddr_edit_address_popup .edit_address_popup_head h3 { margin: 0; color: #302344; font-family: inherit; }
body .msaddr_edit_address_popup .edit_address_content { max-height: 75vh; overflow-y: auto; padding: 22px; }
body .msaddr_shipping_buttons { display: flex; justify-content: flex-end; gap: 10px; padding-top: 18px; }
body .msaddr_shipping_buttons input.msaddr_close { min-height: 52px; padding: 13px 22px; margin: 0; border: 1px solid #e8e3f0; border-radius: 14px; background: #f4f0fd; color: #6b37e8; font-family: inherit; font-size: 15px; }
@media (max-width: 760px) {
  body .woocommerce .cwa-fields:not(.msaddr_widget), body .msaddr_edit_address_popup form.cwa-fields { padding: 20px 16px; border-radius: 20px; }
  body .cwa-fields .form-row-first, body .cwa-fields .form-row-last { float: none !important; width: 100% !important; margin-left: 0 !important; margin-right: 0 !important; }
  body .cwa-fields .cwa-postcode-controls { gap: 8px; }
  body .msaddr_widget .cwa-widget-postcode { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  body .cwa-fields a.ms-open-popup-link, body .msaddr_widget input[name="msm_address_search"] { padding-inline: 16px; font-size: 14px; }
  body .mfp-content #ms_addr_1.msaddr-search-popup { max-width: calc(100vw - 24px); height: min(640px, calc(100vh - 24px)) !important; height: min(640px, calc(100dvh - 24px)) !important; margin: 12px auto !important; border-radius: 20px; }
  body #ms_addr_1 .msaddr-search-wrap .msaddr-search-header { padding: 12px 16px; min-height: 68px; }
  body #ms_addr_1 .msaddr-search-wrap .msaddr-search-header button.mfp-close { background: #fff !important; color: #6b37e8 !important; }
  body #ms_addr_1 .msaddr-search-wrap .msaddr-search-keyword { padding: 16px; }
  body #ms_addr_1 .msaddr-search-wrap .msaddr-search-result { padding: 0 16px; }
  body #ms_addr_1 .msaddr-search-result :is(th, td) { padding: 12px 8px; font-size: 13px; word-break: keep-all; overflow-wrap: anywhere; }
  body #ms_addr_1 .msaddr-search-result th:first-child { width: 68px; }
  body .msaddr_edit_address_popup .edit_address_content { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { .cwa-fields * { transition: none !important; } }
