/* CC Saved Addresses
   Scoped styles only. Existing WooCommerce address styling remains in control. */

/* =========================================================
   CHECKOUT
   ========================================================= */

.woocommerce-checkout .cchsa-checkout-selector {
  margin: 0 0 18px 0 !important;
}

.woocommerce-checkout .cchsa-checkout-selector label {
  display: block;
  font-family: var(--cc-address-font, inherit) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: var(--cc-address-heading, currentColor) !important;
  margin-bottom: 7px !important;
}

.woocommerce-checkout .cchsa-saved-address-select {
  width: 100% !important;
  min-height: 36px !important;
  font-family: var(--cc-address-font, inherit) !important;
  font-size: 15px !important;
  font-weight: 400 !important;
  color: var(--cc-address-text, currentColor) !important;

  background-color: var(--cc-address-background, transparent) !important;

  /* Remove native browser arrow */
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;

  /* Same Font Awesome chevron-down shape used in the header */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%239A75EF' d='M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 13px center !important;
  background-size: 13px 15px !important;

  border: 1px solid var(--cc-address-border, #ddd) !important;
  border-radius: 4px !important;
  padding: 0 38px 0 12px !important;
  box-sizing: border-box !important;
}

.woocommerce-checkout .cchsa-saved-address-select:focus,
.woocommerce-checkout .cchsa-saved-address-select:focus-visible {
  border: 1px solid var(--cc-address-heading, currentColor) !important;
  outline: none !important;
  box-shadow: none !important;

  /* Same darker-purple chevron state as the header */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512'%3E%3Cpath fill='%238364CB' d='M207.029 381.476L12.686 187.132c-9.373-9.373-9.373-24.569 0-33.941l22.667-22.667c9.357-9.357 24.522-9.375 33.901-.04L224 284.505l154.745-154.021c9.379-9.335 24.544-9.317 33.901.04l22.667 22.667c9.373 9.373 9.373 24.569 0 33.941L240.971 381.476c-9.373 9.372-24.569 9.372-33.942 0z'/%3E%3C/svg%3E") !important;
}

.woocommerce-checkout .cchsa-save-address-row {
  clear: both;
  margin: 20px 0 15px 0 !important;
}

/*
 * Hidden whenever the address on screen is already the selected saved address,
 * the account default, or an existing address-book entry.
 */
.woocommerce-checkout .cchsa-save-address-row--hidden {
  display: none !important;
}

.woocommerce-checkout .cchsa-save-address-row label {
  display: inline-flex !important;
  align-items: center !important;
  gap: 7px !important;

  font-family: var(--cc-address-font, inherit) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  line-height: 16px !important;
  color: var(--cc-address-heading, currentColor) !important;
}

.woocommerce-checkout .cchsa-save-address-row input[type="checkbox"] {
  width: 13px !important;
  height: 13px !important;
  margin: 0 !important;
  transform: none !important;
}

/* =========================================================
   MY ACCOUNT > ADDRESSES OVERVIEW
   ========================================================= */

.woocommerce-account .cchsa-address-book {
  clear: both;
  margin-top: 35px !important;
  padding-top: 28px !important;
  border-top: 1px solid var(--cc-address-border, #ddd) !important;
}

/* Heading and Add Saved Address stacked exactly like Billing/Shipping */
.woocommerce-account .woocommerce-MyAccount-content .cchsa-address-book__header {
  display: block !important;
  margin: 0 0 18px 0 !important;
}

.woocommerce-account .woocommerce-MyAccount-content .cchsa-address-book__header h2,
.woocommerce-account .woocommerce-MyAccount-content .cchsa-address-form > h2 {
  font-family: var(--cc-address-heading-font, inherit) !important;
  font-size: 24px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  color: var(--cc-address-heading, currentColor) !important;
  text-transform: uppercase !important;
}

/*
 * Only the address-book heading needs its margins normalised. The form heading
 * deliberately keeps the theme's native h2 spacing so it sits exactly like
 * "Billing address" / "Shipping address" above their fields.
 */
.woocommerce-account .woocommerce-MyAccount-content .cchsa-address-book__header h2 {
  margin: 0 0 15px 0 !important;
}

/* Add Saved Address - same visual treatment as Edit Billing/Shipping */
.woocommerce-account .woocommerce-MyAccount-content a.cchsa-add-address.button {
  display: inline !important;
  width: auto !important;
  height: auto !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;

  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;

  font-family: var(--cc-address-font, inherit) !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  line-height: normal !important;
  text-transform: none !important;

  color: var(--cc-address-accent, currentColor) !important;
  text-decoration: none !important;
  transition: color .25s ease !important;
}

.woocommerce-account .woocommerce-MyAccount-content a.cchsa-add-address.button:hover {
  background: transparent !important;
  color: var(--cc-address-accent-hover, currentColor) !important;
}

.woocommerce-account .cchsa-empty {
  margin: 0 !important;
  font-family: var(--cc-address-font, inherit) !important;
  font-size: 15px !important;
  font-weight: 500 !important;
  color: var(--cc-address-text, currentColor) !important;
}


/* =========================================================
   SAVED ADDRESS CARDS
   ========================================================= */

.woocommerce-account .woocommerce-MyAccount-content .cchsa-address-grid {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 18px !important;
}

/*
 * Cards stretch to the tallest in the row (grid default). Laying each one out
 * as a flex column lets the address block absorb the leftover space, so the
 * Edit / Delete row always sits on the bottom edge - addresses with fewer
 * lines no longer float their actions higher than their neighbour's.
 */
.woocommerce-account .woocommerce-MyAccount-content .cchsa-address-card {
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;

  border: 1px solid var(--cc-address-border, #ddd) !important;
  background: var(--cc-address-background, transparent) !important;
  border-radius: 4px !important;
  padding: 20px !important;
  box-sizing: border-box !important;
}

.woocommerce-account .woocommerce-MyAccount-content .cchsa-address-card h3 {
  font-family: var(--cc-address-heading-font, inherit) !important;
  font-size: 18px !important;
  font-weight: 700 !important;
  line-height: 1.3 !important;
  color: var(--cc-address-heading, currentColor) !important;
  margin: 0 0 10px 0 !important;
}

/*
 * Saved address details.
 * Exact typography to match the native Billing / Shipping address text:
 * Inherited font, 15px / 500 / var(--cc-address-text, currentColor) / 21px line-height.
 */
.woocommerce-account .woocommerce-MyAccount-content
.cchsa-address-grid .cchsa-address-card > address {
  display: block !important;
  flex: 1 1 auto !important;
  min-height: 105px !important;
  margin: 0 0 15px 0 !important;

  font-family: var(--cc-address-detail-font, var(--cc-address-font, inherit)) !important;
  font-size: 15px !important;
  font-weight: 500 !important;
  font-style: normal !important;
  line-height: 21px !important;

  color: var(--cc-address-text, currentColor) !important;
}

/* Do not apply spacing/min-height to the <br> elements inside the address */
.woocommerce-account .woocommerce-MyAccount-content
.cchsa-address-grid .cchsa-address-card > address br {
  margin: 0 !important;
  padding: 0 !important;
}


/* =========================================================
   EDIT / DELETE ACTIONS
   ========================================================= */

/*
 * Grid makes the positioning deterministic:
 * Edit stays hard-left, Delete stays hard-right.
 */
.woocommerce-account .woocommerce-MyAccount-content
.cchsa-address-card .cchsa-address-card__actions {
  margin-top: auto !important;
  display: grid !important;
  grid-template-columns: 1fr auto !important;
  align-items: center !important;
  width: 100% !important;
  gap: 0 !important;

  padding-top: 13px !important;
  border-top: 1px solid var(--cc-address-border, #ddd) !important;
  box-sizing: border-box !important;
}

.woocommerce-account .woocommerce-MyAccount-content
.cchsa-address-card .cchsa-address-card__actions > a {
  font-family: var(--cc-address-font, inherit) !important;
  font-size: 14px !important;
  font-weight: 500 !important;
  line-height: 1.4 !important;

  color: var(--cc-address-heading, currentColor) !important;
  text-decoration: underline !important;
  text-underline-offset: 2px !important;

  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: 0 !important;

  transition: color .25s ease !important;
}

.woocommerce-account .woocommerce-MyAccount-content
.cchsa-address-card .cchsa-address-card__actions > .cchsa-address-edit {
  justify-self: start !important;
}

.woocommerce-account .woocommerce-MyAccount-content
.cchsa-address-card .cchsa-address-card__actions > .cchsa-address-delete {
  justify-self: end !important;
  margin-left: 0 !important;
}

.woocommerce-account .woocommerce-MyAccount-content
.cchsa-address-card .cchsa-address-card__actions > a:hover {
  color: var(--cc-address-accent, currentColor) !important;
}


/* =========================================================
   MY ACCOUNT ADD / EDIT SAVED ADDRESS FORM
   ========================================================= */

/*
 * Nothing is styled here on purpose.
 *
 * The form now uses exactly the same markup as WooCommerce's native
 * Billing / Shipping address form - woocommerce_form_field() rows inside
 * .woocommerce-address-fields__field-wrapper, and a plain paragraph for the
 * submit button - so the theme's own address-form rules give it identical
 * label, field and row spacing. Any override added back here will make the
 * two forms drift apart again.
 */


/* =========================================================
   RESPONSIVE
   ========================================================= */

@media (max-width: 767px) {
  .woocommerce-account .woocommerce-MyAccount-content .cchsa-address-grid {
    grid-template-columns: 1fr !important;
  }

  .woocommerce-account .woocommerce-MyAccount-content
  .cchsa-address-grid .cchsa-address-card > address {
    min-height: 0 !important;
  }
}
