Завършете поръчката

Фактуриране и доставка

Допълнителна информация

Вашата поръчка

Продукт Общо
Комплект DIAMOND SKIN CARE – най-висок клас подмладяваща грижа за кожата  × 1 1,299.00 €
Общо 1,299.00 €
Доставка
Общо 1,299.00 €
  • Платете при получаване на продуктите от Вашата поръчка.

Вашите лични данни ще бъдат използвани за обработка на вашата поръчка, за подобряване на потребителското Ви преживяване в този уебсайт и за други цели, описани в нашата политиката на поверителност.

/* ==========================================================
   CHECKOUT PAGE - AGE CODE BRAND STYLING
   Single column layout. Vertical stack:
   1. Heading
   2. Order summary card (with editable quantities)
   3. Customer details card (billing + additional info)
   4. Payment card (standalone, at the very bottom)
   ========================================================== */

/* ── Global box-sizing ────────────────────────────────────── */
#brxe-oscomn *,
#brxe-oscomn *::before,
#brxe-oscomn *::after {
  box-sizing: border-box;
}

/* ── Page wrapper ─────────────────────────────────────────── */
#brxe-oscomn {
  margin-left: 0;
  margin-right: 0;
  background: var(--gd-warm);
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-onyx);
  line-height: 1.6;
}

/* ==========================================================
   GRID LAYOUT - single column, ordered flow
   ========================================================== */
#brxe-hzwnrv {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: 880px;
  margin: 0 auto;
}

#brxe-rpwzjw { order: 1; }   /* Heading */
#brxe-cbhgoo { order: 2; }   /* Order summary */
#brxe-ypyyhs { order: 3; }   /* Customer details */

.gd-payment-section {
  order: 4;
  width: 100%;
  margin: 0;
}

/* ── Page heading ─────────────────────────────────────────── */
#brxe-hjuofh {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--gd-onyx);
  margin-bottom: 0;
  text-align: center;
  position: relative;
  padding-bottom: 1.5rem;
}

#brxe-hjuofh::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 3rem;
  height: 1px;
  background: var(--gd-gold);
}

/* ==========================================================
   ORDER REVIEW (Order Summary card)
   ========================================================== */
#brxe-xwxgkq,
.woocommerce-checkout-review-order {
  background: var(--gd-ivory);
  padding: 2.5rem 2rem;
  border: 1px solid var(--gd-border);
  box-shadow: none;
  width: 100%;
  max-width: 100%;
}

#order_review_heading {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.75rem;
  color: var(--gd-onyx);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gd-border);
  border-top: none;
  border-left: none;
  border-right: none;
  letter-spacing: 0.005em;
}

/* Order table */
.shop_table.woocommerce-checkout-review-order-table {
  width: 100%;
  border-collapse: collapse;
  border: none;
  margin-bottom: 0;
  font-size: 15px;
  transition: opacity 0.2s ease;
}

.shop_table.gd-updating {
  opacity: 0.5;
  pointer-events: none;
}

.shop_table thead th {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gd-gold-dark);
  text-align: left;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--gd-border);
  border-top: none;
}

.shop_table thead th.product-total { text-align: right; }

.shop_table tbody tr.cart_item td {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--gd-border-soft);
  border-top: none;
  border-left: none;
  border-right: none;
  line-height: 1.5;
  vertical-align: middle;
}

.shop_table tbody tr.cart_item td.product-name {
  padding-right: 1rem;
}

.shop_table tbody tr.cart_item td.product-total {
  text-align: right;
  white-space: nowrap;
  font-weight: 500;
  color: var(--gd-onyx);
}

.shop_table .product-quantity {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: var(--gd-gold-dark);
  font-size: 16px;
  margin-left: 0.35rem;
}

/* Subtotals + totals */
.shop_table tfoot tr.cart-subtotal th,
.shop_table tfoot tr.cart-subtotal td {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-muted);
  padding: 1rem 0;
  border-bottom: 1px solid var(--gd-border-soft);
  border-top: none;
}

.shop_table tfoot tr.order-total th,
.shop_table tfoot tr.order-total td {
  padding: 1.5rem 0 0.5rem;
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gd-onyx);
  border-top: 1px solid var(--gd-border);
  border-bottom: none;
}

.shop_table tfoot tr.order-total td { text-align: right; }

/* ==========================================================
   PRICE FORMATTING - unified EUR + BGN treatment
   ========================================================== */
.woocommerce-Price-amount,
.woocommerce-Price-amount.amount,
.woocommerce-Price-amount.amount-bgn {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 15px;
  color: var(--gd-onyx);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.shop_table tfoot tr.cart-subtotal .woocommerce-Price-amount,
.shop_table tfoot tr.cart-subtotal .woocommerce-Price-amount.amount-bgn {
  font-weight: 400;
  color: var(--gd-muted);
  font-size: 15px;
}

.shop_table tbody tr.cart_item .woocommerce-Price-amount,
.shop_table tbody tr.cart_item .woocommerce-Price-amount.amount-bgn {
  font-weight: 500;
  color: var(--gd-onyx);
  font-size: 15px;
}

.shop_table tfoot tr.order-total td strong,
.shop_table tfoot tr.order-total td strong .woocommerce-Price-amount,
.shop_table tfoot tr.order-total td strong .woocommerce-Price-amount.amount-bgn {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.85rem;
  color: var(--gd-gold-dark);
  letter-spacing: 0.005em;
  text-transform: none;
  display: inline-block;
}

.woocommerce-Price-currencySymbol {
  font-weight: inherit;
  font-size: inherit;
  color: inherit;
  margin-left: 0.05em;
}

/* ==========================================================
   QUANTITY SELECTOR (editable on checkout)
   ========================================================== */
.shop_table .product-quantity-wrapper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--gd-border);
  background: var(--gd-warm);
  margin-left: 0.5rem;
  vertical-align: middle;
}

.shop_table .product-quantity-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 18px;
  color: var(--gd-gold-dark);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
  padding: 0;
  outline: none;
}

.shop_table .product-quantity-btn:hover {
  background: var(--gd-gold);
  color: var(--gd-ivory);
}

.shop_table .product-quantity-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.shop_table .product-quantity-input {
  width: 38px;
  height: 32px;
  border: none;
  border-left: 1px solid var(--gd-border);
  border-right: 1px solid var(--gd-border);
  background: var(--gd-ivory);
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: var(--gd-onyx);
  text-align: center;
  padding: 0;
  outline: none;
  -moz-appearance: textfield;
}

.shop_table .product-quantity-input::-webkit-outer-spin-button,
.shop_table .product-quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.shop_table .product-quantity-input:focus {
  background: var(--gd-warm);
}

/* Remove item button (X) */
.shop_table .product-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 0.5rem;
  background: transparent;
  border: 1px solid var(--gd-border);
  color: var(--gd-muted);
  font-family: Montserrat, sans-serif;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease;
  vertical-align: middle;
  padding: 0;
}

.shop_table .product-remove-btn:hover {
  border-color: #b85450;
  color: #b85450;
}

/* ==========================================================
   PAYMENT METHODS - standalone card at the bottom
   ========================================================== */
#payment.woocommerce-checkout-payment {
  background: var(--gd-ivory);
  padding: 2.5rem 2rem;
  border: 1px solid var(--gd-border);
  border-radius: 0;
  margin: 0;
  box-shadow: none;
  width: 100%;
}

#payment .wc_payment_methods {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#payment .wc_payment_method {
  background: var(--gd-warm);
  border: 1px solid var(--gd-border);
  box-shadow: none;
  padding: 1.1rem 1.25rem;
  transition: border-color 0.3s ease, background 0.3s ease;
  list-style: none;
}

#payment .wc_payment_method:has(input:checked) {
  border-color: var(--gd-gold);
  background: var(--gd-ivory);
}

#payment .wc_payment_method input[type="radio"] {
  accent-color: var(--gd-gold-dark);
  margin-right: 0.75rem;
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle;
  box-shadow: none;
  outline: none;
}

#payment .wc_payment_method label {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 15px;
  color: var(--gd-onyx);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  letter-spacing: 0.02em;
}

#payment .wc_payment_method label img {
  height: 22px;
  width: auto;
  vertical-align: middle;
}

#payment .payment_box {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--gd-ivory);
  border: none;
  border-left: 2px solid var(--gd-gold);
  box-shadow: none;
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  line-height: 1.6;
}

#payment .payment_box p { margin: 0 0 0.75rem; }
#payment .payment_box p:last-child { margin-bottom: 0; }

#payment .payment_box a {
  color: var(--gd-gold-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}
#payment .payment_box a:hover { color: var(--gd-onyx); }

/* Stripe upe form */
.wc-stripe-upe-form,
.wc-upe-form {
  border: none;
  padding: 0;
  margin: 0;
}

.wc-stripe-upe-element {
  background: var(--gd-warm);
  padding: 1rem;
  border: 1px solid var(--gd-border);
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 1rem;
}

/* ==========================================================
   PLACE ORDER BLOCK (terms + button) - inside payment card
   ========================================================== */
.form-row.place-order {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--gd-border);
  border-bottom: none;
  border-left: none;
  border-right: none;
}

.woocommerce-form__label-for-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  margin-bottom: 1.25rem;
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  line-height: 1.55;
}

.woocommerce-form__input-checkbox,
input[type="checkbox"] {
  accent-color: var(--gd-gold-dark);
  width: 16px;
  height: 16px;
  margin-top: 0.2rem;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: none;
  outline: none;
}

.woocommerce-privacy-policy-text {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-muted);
  line-height: 1.65;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: var(--gd-warm);
  border: none;
  border-left: 2px solid var(--gd-gold-light);
  box-shadow: none;
}

.woocommerce-privacy-policy-text p { margin: 0; }

.woocommerce-privacy-policy-link,
.woocommerce-terms-and-conditions-link {
  color: var(--gd-gold-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

.woocommerce-privacy-policy-link:hover,
.woocommerce-terms-and-conditions-link:hover {
  color: var(--gd-onyx);
}

.required {
  color: var(--gd-gold-dark);
  font-weight: 500;
}

/* Place order button */
button#place_order,
.button.alt[name="woocommerce_checkout_place_order"] {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 1.25rem 2rem;
  background: var(--gd-onyx);
  color: var(--gd-ivory);
  border: none;
  box-shadow: none;
  outline: none;
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.35s ease, transform 0.2s ease;
}

button#place_order:hover,
.button.alt[name="woocommerce_checkout_place_order"]:hover {
  background: var(--gd-gold-dark);
  transform: translateY(-1px);
}

button#place_order:focus-visible {
  outline: 2px solid var(--gd-gold);
  outline-offset: 2px;
}

/* ==========================================================
   CUSTOMER DETAILS (Billing + Additional Info card)
   ========================================================== */
#brxe-ypyyhs {
  background: var(--gd-ivory);
  padding: 2.5rem 2rem;
  border: 1px solid var(--gd-border);
  box-shadow: none;
}

.col2-set#customer_details {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.col2-set#customer_details .col-1,
.col2-set#customer_details .col-2 {
  width: 100%;
  float: none;
}

.woocommerce-billing-fields h3,
.woocommerce-additional-fields h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.75rem;
  color: var(--gd-onyx);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gd-border);
  border-top: none;
  border-left: none;
  border-right: none;
  letter-spacing: 0.005em;
}

.woocommerce-billing-fields__field-wrapper,
.woocommerce-additional-fields__field-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}

/* ==========================================================
   FORM ROWS + INPUTS
   ========================================================== */
.form-row,
.form-row .woocommerce-input-wrapper {
  border: none;
  background: transparent;
  box-shadow: none;
}

.form-row {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.form-row.form-row-first,
.form-row.form-row-last,
.form-row.form-row-wide {
  width: 100%;
  max-width: 100%;
  float: none;
  margin: 0;
}

.form-row.form-row-first { grid-column: 1; }
.form-row.form-row-last { grid-column: 2; }
.form-row.form-row-wide,
.form-row.notes { grid-column: 1 / -1; }

.form-row .woocommerce-input-wrapper {
  width: 100%;
  display: block;
}

/* Labels */
.form-row label,
.woocommerce-form__label {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gd-gold-dark);
  margin-bottom: 0.5rem;
  display: block;
  cursor: pointer;
}

.form-row label .required {
  color: var(--gd-gold-dark);
  text-decoration: none;
}

.form-row label .optional {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gd-muted);
  font-size: 14px;
}

/* Form inputs - unified treatment */
.form-row input.input-text,
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="tel"],
.form-row input[type="number"],
.form-row textarea,
.form-row select,
.form-row#billing_country_field .woocommerce-input-wrapper strong,
.intl-tel-input.allow-dropdown {
  width: 100% !important;
  max-width: 100%;
  display: block;
  background: var(--gd-warm);
  border: 1px solid var(--gd-border);
  border-radius: 0;
  padding: 0.85rem 1rem;
  font-family: Montserrat, sans-serif;
  font-weight: 400;
  font-size: 15px;
  color: var(--gd-onyx);
  line-height: 1.5;
  outline: none;
  box-shadow: none;
  transition: border-color 0.3s ease, background 0.3s ease;
  box-sizing: border-box;
  min-height: 48px;
}

.form-row input.input-text::placeholder,
.form-row textarea::placeholder {
  color: var(--gd-muted);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  opacity: 0.7;
}

.form-row input.input-text:focus,
.form-row input[type="text"]:focus,
.form-row input[type="email"]:focus,
.form-row input[type="tel"]:focus,
.form-row textarea:focus,
.form-row select:focus,
.intl-tel-input.allow-dropdown:focus-within {
  border-color: var(--gd-gold);
  background: var(--gd-ivory);
}

.form-row textarea {
  min-height: 90px;
  resize: vertical;
  font-family: Montserrat, sans-serif;
}

.form-row#billing_country_field .woocommerce-input-wrapper strong {
  display: flex;
  align-items: center;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
}

/* ==========================================================
   PHONE FIELD (intl-tel-input)
   ========================================================== */
.intl-tel-input {
  position: relative;
}

.intl-tel-input.allow-dropdown input.input-text {
  border: none !important;
  background: transparent;
  padding: 0 0 0 3.5rem;
  min-height: auto;
  width: 100%;
  box-shadow: none;
}

.intl-tel-input .flag-container {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 2;
}

.intl-tel-input .selected-flag {
  height: calc(100% + 2px);
  margin: -1px 0 -1px -1px;
  padding: 0 0.85rem;
  background: transparent;
  border-right: 1px solid var(--gd-border);
  border-top: none;
  border-bottom: none;
  border-left: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.intl-tel-input .country-list {
  background: var(--gd-ivory);
  border: 1px solid var(--gd-border);
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  max-height: 240px;
  overflow-y: auto;
}

.intl-tel-input .country-list .country {
  padding: 0.65rem 1rem;
  color: var(--gd-charcoal);
}

.intl-tel-input .country-list .country.active,
.intl-tel-input .country-list .country:hover {
  background: var(--gd-warm);
  color: var(--gd-onyx);
}

/* ==========================================================
   VALIDATION STATES
   ========================================================== */
.form-row.woocommerce-validated input.input-text,
.form-row.woocommerce-validated .intl-tel-input.allow-dropdown {
  border: 1px solid var(--gd-gold);
}

.form-row.woocommerce-invalid input.input-text,
.form-row.woocommerce-invalid textarea,
.form-row.woocommerce-invalid .intl-tel-input.allow-dropdown {
  border: 1px solid #b85450;
  background: #fdf6f5;
}

/* ==========================================================
   TERMS POLICY EXPANDED CONTENT
   ========================================================== */
.woocommerce-terms-and-conditions {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  line-height: 1.7;
  background: var(--gd-warm);
  padding: 1.5rem;
  border: 1px solid var(--gd-border);
  box-shadow: none;
  margin-bottom: 1.25rem;
}

.woocommerce-terms-and-conditions h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.35rem;
  color: var(--gd-onyx);
  margin: 1.25rem 0 0.75rem;
}

.woocommerce-terms-and-conditions h2:first-child { margin-top: 0; }

.woocommerce-terms-and-conditions p { margin-bottom: 0.85rem; }
.woocommerce-terms-and-conditions ul { margin: 0.75rem 0 1rem 1.25rem; }
.woocommerce-terms-and-conditions ul li { margin-bottom: 0.4rem; }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 640px) {
  #brxe-oscomn { padding: 2.5rem 1rem 4rem; }
  #brxe-xwxgkq,
  .woocommerce-checkout-review-order,
  #brxe-ypyyhs,
  #payment.woocommerce-checkout-payment {
    padding: 1.75rem 1.25rem;
  }
  .woocommerce-billing-fields__field-wrapper,
  .woocommerce-additional-fields__field-wrapper {
    grid-template-columns: 1fr;
  }
  .form-row.form-row-first,
  .form-row.form-row-last { grid-column: 1; }
  #brxe-hjuofh { margin-bottom: 0; }

  .shop_table tfoot tr.order-total td strong,
  .shop_table tfoot tr.order-total td strong .woocommerce-Price-amount,
  .shop_table tfoot tr.order-total td strong .woocommerce-Price-amount.amount-bgn {
    font-size: 1.5rem;
  }
}
(function() {
  'use strict';

  let cartUpdateTimer = null;
  let cartItems = [];
  let storeApiNonce = '';

  /* ============================================================
     1. NONCE HANDLING
     ============================================================ */
  async function getNonce() {
    if (storeApiNonce) return storeApiNonce;

    const meta = document.querySelector('meta[name="wc-store-api-nonce"]');
    if (meta?.content) {
      storeApiNonce = meta.content;
      return storeApiNonce;
    }

    if (window.wcSettings?.storeApiNonce) {
      storeApiNonce = window.wcSettings.storeApiNonce;
      return storeApiNonce;
    }

    try {
      const res = await fetch('/wp-json/wc/store/v1/cart', {
        credentials: 'include',
        headers: { 'Accept': 'application/json' }
      });
      const headerNonce = res.headers.get('Nonce') ||
                          res.headers.get('X-WC-Store-API-Nonce');
      if (headerNonce) {
        storeApiNonce = headerNonce;
        return storeApiNonce;
      }
    } catch (err) {
      console.error('[GD] Nonce fetch failed:', err);
    }
    return '';
  }

  /* ============================================================
     2. FETCH CART
     ============================================================ */
  async function fetchCart() {
    try {
      const res = await fetch('/wp-json/wc/store/v1/cart', {
        credentials: 'include',
        headers: { 'Accept': 'application/json' }
      });

      const headerNonce = res.headers.get('Nonce') ||
                          res.headers.get('X-WC-Store-API-Nonce');
      if (headerNonce) storeApiNonce = headerNonce;

      if (!res.ok) {
        console.error('[GD] Cart fetch failed:', res.status);
        return;
      }

      const cart = await res.json();
      cartItems = cart.items || [];
      console.log('[GD] Cart items:', cartItems);
    } catch (err) {
      console.error('[GD] Cart fetch error:', err);
    }
  }

  /* ============================================================
     3. STRING NORMALIZATION
     ============================================================ */
  function normalize(str) {
    return str
      .replace(/\u00A0/g, ' ')
      .replace(/\s+/g, ' ')
      .replace(/[\u200B-\u200D\uFEFF]/g, '')
      .trim()
      .toLowerCase();
  }

  /* ============================================================
     4. MATCH ROW TO CART ITEM
     ============================================================ */
  function findCartKeyForName(rawName) {
    const targetName = normalize(rawName);

    let match = cartItems.find(item => normalize(item.name) === targetName);
    if (match) return match.key;

    match = cartItems.find(item => {
      const itemName = normalize(item.name);
      return targetName.includes(itemName) || itemName.includes(targetName);
    });

    if (match) return match.key;
    return null;
  }

  /* ============================================================
     5. UPDATE QUANTITY
     ============================================================ */
  async function updateQuantity(cartKey, newQty) {
    if (!cartKey) return;

    const table = document.querySelector('.woocommerce-checkout-review-order-table');
    table?.classList.add('gd-updating');

    const nonce = await getNonce();

    try {
      const res = await fetch('/wp-json/wc/store/v1/cart/update-item', {
        method: 'POST',
        credentials: 'include',
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json',
          'Nonce': nonce,
          'X-WC-Store-API-Nonce': nonce
        },
        body: JSON.stringify({ key: cartKey, quantity: parseInt(newQty, 10) })
      });

      const newNonce = res.headers.get('Nonce') ||
                       res.headers.get('X-WC-Store-API-Nonce');
      if (newNonce) storeApiNonce = newNonce;

      if (!res.ok) {
        const errBody = await res.text();
        console.error('[GD] Update failed:', res.status, errBody);
        throw new Error('Update failed');
      }

      console.log('[GD] Quantity updated to', newQty);

      if (typeof jQuery !== 'undefined') {
        jQuery(document.body).trigger('update_checkout');
      } else {
        window.location.reload();
      }
    } catch (err) {
      console.error('[GD] Update error:', err);
      alert('Грешка при обновяване. Моля, опитайте отново.');
      table?.classList.remove('gd-updating');
    }
  }

  /* ============================================================
     6. REMOVE ITEM
     ============================================================ */
  async function removeItem(cartKey) {
    if (!cartKey) return;
    if (!confirm('Сигурни ли сте, че искате да премахнете този продукт?')) return;

    const table = document.querySelector('.woocommerce-checkout-review-order-table');
    table?.classList.add('gd-updating');

    const nonce = await getNonce();

    try {
      const res = await fetch('/wp-json/wc/store/v1/cart/remove-item', {
        method: 'POST',
        credentials: 'include',
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json',
          'Nonce': nonce,
          'X-WC-Store-API-Nonce': nonce
        },
        body: JSON.stringify({ key: cartKey })
      });

      if (!res.ok) throw new Error('Remove failed');

      if (typeof jQuery !== 'undefined') {
        jQuery(document.body).trigger('update_checkout');
      }

      const cartCheck = await (await fetch('/wp-json/wc/store/v1/cart', {
        credentials: 'include'
      })).json();
      if (cartCheck.items.length === 0) {
        window.location.href = '/';
      }
    } catch (err) {
      console.error('[GD] Remove error:', err);
      alert('Грешка при премахване.');
      table?.classList.remove('gd-updating');
    }
  }

  /* ============================================================
     7. BUILD UI ELEMENTS
     ============================================================ */
  function buildQuantitySelector(cartKey, currentQty) {
    const wrap = document.createElement('span');
    wrap.className = 'product-quantity-wrapper';
    wrap.dataset.cartKey = cartKey;

    const minus = document.createElement('button');
    minus.type = 'button';
    minus.className = 'product-quantity-btn product-quantity-minus';
    minus.setAttribute('aria-label', 'Намали');
    minus.textContent = '−';

    const input = document.createElement('input');
    input.type = 'number';
    input.className = 'product-quantity-input';
    input.value = currentQty;
    input.min = '1';
    input.max = '99';

    const plus = document.createElement('button');
    plus.type = 'button';
    plus.className = 'product-quantity-btn product-quantity-plus';
    plus.setAttribute('aria-label', 'Увеличи');
    plus.textContent = '+';

    wrap.appendChild(minus);
    wrap.appendChild(input);
    wrap.appendChild(plus);
    return wrap;
  }

  function buildRemoveButton(cartKey) {
    const btn = document.createElement('button');
    btn.type = 'button';
    btn.className = 'product-remove-btn';
    btn.dataset.cartKey = cartKey;
    btn.setAttribute('aria-label', 'Премахни');
    btn.innerHTML = '×';
    return btn;
  }

  /* ============================================================
     8. SETUP QUANTITY CONTROLS
     ============================================================ */
  function setupQuantityControls() {
    const rows = document.querySelectorAll('.woocommerce-checkout-review-order-table tr.cart_item');
    console.log('[GD] Found', rows.length, 'rows,', cartItems.length, 'cart items');

    rows.forEach((row, idx) => {
      const nameCell = row.querySelector('td.product-name');
      if (!nameCell) return;
      if (nameCell.querySelector('.product-quantity-wrapper')) return;

      const qtyEl = nameCell.querySelector('strong.product-quantity');
      if (!qtyEl) return;

      let rawName = '';
      for (const node of nameCell.childNodes) {
        if (node.nodeType === Node.TEXT_NODE) {
          rawName += node.textContent;
        } else if (node !== qtyEl && node.nodeType === Node.ELEMENT_NODE) {
          if (!node.classList?.contains('product-quantity')) {
            rawName += node.textContent || '';
          }
        }
      }

      let cartKey = findCartKeyForName(rawName);

      if (!cartKey && cartItems[idx]) {
        cartKey = cartItems[idx].key;
        console.log('[GD] Index fallback for row', idx);
      }

      if (!cartKey) {
        console.warn('[GD] Could not match row', idx, 'name:', rawName);
        return;
      }

      const currentQty = parseInt(qtyEl.textContent.replace(/[^0-9]/g, ''), 10) || 1;

      qtyEl.style.display = 'none';
      nameCell.appendChild(buildQuantitySelector(cartKey, currentQty));
      nameCell.appendChild(buildRemoveButton(cartKey));

      console.log('[GD] Row', idx, 'wired with key:', cartKey);
    });
  }

  /* ============================================================
     9. REORDER - Force payment block to standalone bottom section
     ============================================================ */
  function reorderCheckout() {
    const grid = document.querySelector('#brxe-hzwnrv');
    const paymentBlock = document.querySelector('#payment.woocommerce-checkout-payment');

    if (!grid || !paymentBlock) return;

    // Find existing standalone section or create new one
    let section = grid.querySelector(':scope > .gd-payment-section');
    if (!section) {
      section = document.createElement('div');
      section.className = 'gd-payment-section';
      grid.appendChild(section);
    }

    // Already inside the section AND section is a direct child of grid?
    if (paymentBlock.parentElement === section &&
        section.parentElement === grid) {
      return;
    }

    // Force-move payment into the section
    section.appendChild(paymentBlock);

    // Make sure section is the LAST child of grid
    grid.appendChild(section);

    console.log('[GD] Payment block moved to standalone bottom section.');
  }

  /* ============================================================
     10. EVENT DELEGATION
     ============================================================ */
  function bindEvents() {
    document.addEventListener('click', function(e) {
      if (e.target.closest('.product-quantity-plus')) {
        e.preventDefault();
        e.stopPropagation();
        const wrap = e.target.closest('.product-quantity-wrapper');
        const input = wrap.querySelector('.product-quantity-input');
        const cartKey = wrap.dataset.cartKey;
        const newQty = parseInt(input.value, 10) + 1;
        input.value = newQty;
        debounceUpdate(cartKey, newQty);
        return;
      }

      if (e.target.closest('.product-quantity-minus')) {
        e.preventDefault();
        e.stopPropagation();
        const wrap = e.target.closest('.product-quantity-wrapper');
        const input = wrap.querySelector('.product-quantity-input');
        const cartKey = wrap.dataset.cartKey;
        const newQty = Math.max(1, parseInt(input.value, 10) - 1);
        input.value = newQty;
        debounceUpdate(cartKey, newQty);
        return;
      }

      if (e.target.closest('.product-remove-btn')) {
        e.preventDefault();
        e.stopPropagation();
        const btn = e.target.closest('.product-remove-btn');
        removeItem(btn.dataset.cartKey);
        return;
      }
    });

    document.addEventListener('change', function(e) {
      if (e.target.matches('.product-quantity-input')) {
        const wrap = e.target.closest('.product-quantity-wrapper');
        const cartKey = wrap.dataset.cartKey;
        const newQty = Math.max(1, Math.min(99, parseInt(e.target.value, 10) || 1));
        e.target.value = newQty;
        debounceUpdate(cartKey, newQty);
      }
    });
  }

  function debounceUpdate(cartKey, newQty) {
    clearTimeout(cartUpdateTimer);
    cartUpdateTimer = setTimeout(() => {
      updateQuantity(cartKey, newQty);
    }, 500);
  }

  /* ============================================================
     INIT
     ============================================================ */
  async function init() {
    console.log('[GD] Initializing checkout enhancements...');
    await fetchCart();
    reorderCheckout();
    setupQuantityControls();
    bindEvents();
    console.log('[GD] Ready.');
  }

  if (document.readyState === 'loading') {
    document.addEventListener('DOMContentLoaded', init);
  } else {
    init();
  }

  // Re-apply enhancements after WooCommerce refreshes the order review
  if (typeof jQuery !== 'undefined') {
    jQuery(document.body).on('updated_checkout', async function() {
      console.log('[GD] Checkout updated, re-applying enhancements...');
      await fetchCart();
      reorderCheckout();
      setupQuantityControls();
      const table = document.querySelector('.woocommerce-checkout-review-order-table');
      table?.classList.remove('gd-updating');
    });
  }
})();
/* ==========================================================
   CHECKOUT PAGE - AGE CODE BRAND STYLING
   Single column layout. Vertical stack:
   1. Heading
   2. Order summary card (with editable quantities)
   3. Customer details card (billing + additional info)
   4. Payment card (standalone, at the very bottom)
   ========================================================== */

/* ── Global box-sizing ────────────────────────────────────── */
#brxe-oscomn *,
#brxe-oscomn *::before,
#brxe-oscomn *::after {
  box-sizing: border-box;
}

/* ── Page wrapper ─────────────────────────────────────────── */
#brxe-oscomn {
  margin-left: 0;
  margin-right: 0;
  background: var(--gd-warm);
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-onyx);
  line-height: 1.6;
}

/* ==========================================================
   GRID LAYOUT - single column, ordered flow
   ========================================================== */
#brxe-hzwnrv {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
  max-width: 880px;
  margin: 0 auto;
}

#brxe-rpwzjw { order: 1; }   /* Heading */
#brxe-cbhgoo { order: 2; }   /* Order summary */
#brxe-ypyyhs { order: 3; }   /* Customer details */

.gd-payment-section {
  order: 4;
  width: 100%;
  margin: 0;
}

/* ── Page heading ─────────────────────────────────────────── */
#brxe-hjuofh {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 400;
  font-size: clamp(2.25rem, 4vw, 3.25rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--gd-onyx);
  margin-bottom: 0;
  text-align: center;
  position: relative;
  padding-bottom: 1.5rem;
}

#brxe-hjuofh::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 3rem;
  height: 1px;
  background: var(--gd-gold);
}

/* ==========================================================
   ORDER REVIEW (Order Summary card)
   ========================================================== */
#brxe-xwxgkq,
.woocommerce-checkout-review-order {
  background: var(--gd-ivory);
  padding: 2.5rem 2rem;
  border: 1px solid var(--gd-border);
  box-shadow: none;
  width: 100%;
  max-width: 100%;
}

#order_review_heading {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.75rem;
  color: var(--gd-onyx);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gd-border);
  border-top: none;
  border-left: none;
  border-right: none;
  letter-spacing: 0.005em;
}

/* Order table */
.shop_table.woocommerce-checkout-review-order-table {
  width: 100%;
  border-collapse: collapse;
  border: none;
  margin-bottom: 0;
  font-size: 15px;
  transition: opacity 0.2s ease;
}

.shop_table.gd-updating {
  opacity: 0.5;
  pointer-events: none;
}

.shop_table thead th {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gd-gold-dark);
  text-align: left;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--gd-border);
  border-top: none;
}

.shop_table thead th.product-total { text-align: right; }

.shop_table tbody tr.cart_item td {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  padding: 1.1rem 0;
  border-bottom: 1px solid var(--gd-border-soft);
  border-top: none;
  border-left: none;
  border-right: none;
  line-height: 1.5;
  vertical-align: middle;
}

.shop_table tbody tr.cart_item td.product-name {
  padding-right: 1rem;
}

.shop_table tbody tr.cart_item td.product-total {
  text-align: right;
  white-space: nowrap;
  font-weight: 500;
  color: var(--gd-onyx);
}

.shop_table .product-quantity {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  color: var(--gd-gold-dark);
  font-size: 16px;
  margin-left: 0.35rem;
}

/* Subtotals + totals */
.shop_table tfoot tr.cart-subtotal th,
.shop_table tfoot tr.cart-subtotal td {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-muted);
  padding: 1rem 0;
  border-bottom: 1px solid var(--gd-border-soft);
  border-top: none;
}

.shop_table tfoot tr.order-total th,
.shop_table tfoot tr.order-total td {
  padding: 1.5rem 0 0.5rem;
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gd-onyx);
  border-top: 1px solid var(--gd-border);
  border-bottom: none;
}

.shop_table tfoot tr.order-total td { text-align: right; }

/* ==========================================================
   PRICE FORMATTING - unified EUR + BGN treatment
   ========================================================== */
.woocommerce-Price-amount,
.woocommerce-Price-amount.amount,
.woocommerce-Price-amount.amount-bgn {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 15px;
  color: var(--gd-onyx);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.shop_table tfoot tr.cart-subtotal .woocommerce-Price-amount,
.shop_table tfoot tr.cart-subtotal .woocommerce-Price-amount.amount-bgn {
  font-weight: 400;
  color: var(--gd-muted);
  font-size: 15px;
}

.shop_table tbody tr.cart_item .woocommerce-Price-amount,
.shop_table tbody tr.cart_item .woocommerce-Price-amount.amount-bgn {
  font-weight: 500;
  color: var(--gd-onyx);
  font-size: 15px;
}

.shop_table tfoot tr.order-total td strong,
.shop_table tfoot tr.order-total td strong .woocommerce-Price-amount,
.shop_table tfoot tr.order-total td strong .woocommerce-Price-amount.amount-bgn {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.85rem;
  color: var(--gd-gold-dark);
  letter-spacing: 0.005em;
  text-transform: none;
  display: inline-block;
}

.woocommerce-Price-currencySymbol {
  font-weight: inherit;
  font-size: inherit;
  color: inherit;
  margin-left: 0.05em;
}

/* ==========================================================
   QUANTITY SELECTOR (editable on checkout)
   ========================================================== */
.shop_table .product-quantity-wrapper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--gd-border);
  background: var(--gd-warm);
  margin-left: 0.5rem;
  vertical-align: middle;
}

.shop_table .product-quantity-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 18px;
  color: var(--gd-gold-dark);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
  padding: 0;
  outline: none;
}

.shop_table .product-quantity-btn:hover {
  background: var(--gd-gold);
  color: var(--gd-ivory);
}

.shop_table .product-quantity-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.shop_table .product-quantity-input {
  width: 38px;
  height: 32px;
  border: none;
  border-left: 1px solid var(--gd-border);
  border-right: 1px solid var(--gd-border);
  background: var(--gd-ivory);
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 14px;
  color: var(--gd-onyx);
  text-align: center;
  padding: 0;
  outline: none;
  -moz-appearance: textfield;
}

.shop_table .product-quantity-input::-webkit-outer-spin-button,
.shop_table .product-quantity-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.shop_table .product-quantity-input:focus {
  background: var(--gd-warm);
}

/* Remove item button (X) */
.shop_table .product-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin-left: 0.5rem;
  background: transparent;
  border: 1px solid var(--gd-border);
  color: var(--gd-muted);
  font-family: Montserrat, sans-serif;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease;
  vertical-align: middle;
  padding: 0;
}

.shop_table .product-remove-btn:hover {
  border-color: #b85450;
  color: #b85450;
}

/* ==========================================================
   PAYMENT METHODS - standalone card at the bottom
   ========================================================== */
#payment.woocommerce-checkout-payment {
  background: var(--gd-ivory);
  padding: 2.5rem 2rem;
  border: 1px solid var(--gd-border);
  border-radius: 0;
  margin: 0;
  box-shadow: none;
  width: 100%;
}

#payment .wc_payment_methods {
  list-style: none;
  margin: 0 0 2rem;
  padding: 0;
  border: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#payment .wc_payment_method {
  background: var(--gd-warm);
  border: 1px solid var(--gd-border);
  box-shadow: none;
  padding: 1.1rem 1.25rem;
  transition: border-color 0.3s ease, background 0.3s ease;
  list-style: none;
}

#payment .wc_payment_method:has(input:checked) {
  border-color: var(--gd-gold);
  background: var(--gd-ivory);
}

#payment .wc_payment_method input[type="radio"] {
  accent-color: var(--gd-gold-dark);
  margin-right: 0.75rem;
  width: 16px;
  height: 16px;
  cursor: pointer;
  vertical-align: middle;
  box-shadow: none;
  outline: none;
}

#payment .wc_payment_method label {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 15px;
  color: var(--gd-onyx);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  letter-spacing: 0.02em;
}

#payment .wc_payment_method label img {
  height: 22px;
  width: auto;
  vertical-align: middle;
}

#payment .payment_box {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: var(--gd-ivory);
  border: none;
  border-left: 2px solid var(--gd-gold);
  box-shadow: none;
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  line-height: 1.6;
}

#payment .payment_box p { margin: 0 0 0.75rem; }
#payment .payment_box p:last-child { margin-bottom: 0; }

#payment .payment_box a {
  color: var(--gd-gold-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}
#payment .payment_box a:hover { color: var(--gd-onyx); }

/* Stripe upe form */
.wc-stripe-upe-form,
.wc-upe-form {
  border: none;
  padding: 0;
  margin: 0;
}

.wc-stripe-upe-element {
  background: var(--gd-warm);
  padding: 1rem;
  border: 1px solid var(--gd-border);
  border-radius: 0;
  box-shadow: none;
  margin-bottom: 1rem;
}

/* ==========================================================
   PLACE ORDER BLOCK (terms + button) - inside payment card
   ========================================================== */
.form-row.place-order {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--gd-border);
  border-bottom: none;
  border-left: none;
  border-right: none;
}

.woocommerce-form__label-for-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  cursor: pointer;
  margin-bottom: 1.25rem;
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  line-height: 1.55;
}

.woocommerce-form__input-checkbox,
input[type="checkbox"] {
  accent-color: var(--gd-gold-dark);
  width: 16px;
  height: 16px;
  margin-top: 0.2rem;
  flex-shrink: 0;
  cursor: pointer;
  box-shadow: none;
  outline: none;
}

.woocommerce-privacy-policy-text {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-muted);
  line-height: 1.65;
  margin-bottom: 1rem;
  padding: 1rem 1.25rem;
  background: var(--gd-warm);
  border: none;
  border-left: 2px solid var(--gd-gold-light);
  box-shadow: none;
}

.woocommerce-privacy-policy-text p { margin: 0; }

.woocommerce-privacy-policy-link,
.woocommerce-terms-and-conditions-link {
  color: var(--gd-gold-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

.woocommerce-privacy-policy-link:hover,
.woocommerce-terms-and-conditions-link:hover {
  color: var(--gd-onyx);
}

.required {
  color: var(--gd-gold-dark);
  font-weight: 500;
}

/* Place order button */
button#place_order,
.button.alt[name="woocommerce_checkout_place_order"] {
  display: block;
  width: 100%;
  margin-top: 1.5rem;
  padding: 1.25rem 2rem;
  background: var(--gd-onyx);
  color: var(--gd-ivory);
  border: none;
  box-shadow: none;
  outline: none;
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.35s ease, transform 0.2s ease;
}

button#place_order:hover,
.button.alt[name="woocommerce_checkout_place_order"]:hover {
  background: var(--gd-gold-dark);
  transform: translateY(-1px);
}

button#place_order:focus-visible {
  outline: 2px solid var(--gd-gold);
  outline-offset: 2px;
}

/* ==========================================================
   CUSTOMER DETAILS (Billing + Additional Info card)
   ========================================================== */
#brxe-ypyyhs {
  background: var(--gd-ivory);
  padding: 2.5rem 2rem;
  border: 1px solid var(--gd-border);
  box-shadow: none;
}

.col2-set#customer_details {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.col2-set#customer_details .col-1,
.col2-set#customer_details .col-2 {
  width: 100%;
  float: none;
}

.woocommerce-billing-fields h3,
.woocommerce-additional-fields h3 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.75rem;
  color: var(--gd-onyx);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gd-border);
  border-top: none;
  border-left: none;
  border-right: none;
  letter-spacing: 0.005em;
}

.woocommerce-billing-fields__field-wrapper,
.woocommerce-additional-fields__field-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}

/* ==========================================================
   FORM ROWS + INPUTS
   ========================================================== */
.form-row,
.form-row .woocommerce-input-wrapper {
  border: none;
  background: transparent;
  box-shadow: none;
}

.form-row {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.form-row.form-row-first,
.form-row.form-row-last,
.form-row.form-row-wide {
  width: 100%;
  max-width: 100%;
  float: none;
  margin: 0;
}

.form-row.form-row-first { grid-column: 1; }
.form-row.form-row-last { grid-column: 2; }
.form-row.form-row-wide,
.form-row.notes { grid-column: 1 / -1; }

.form-row .woocommerce-input-wrapper {
  width: 100%;
  display: block;
}

/* Labels */
.form-row label,
.woocommerce-form__label {
  font-family: Montserrat, sans-serif;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gd-gold-dark);
  margin-bottom: 0.5rem;
  display: block;
  cursor: pointer;
}

.form-row label .required {
  color: var(--gd-gold-dark);
  text-decoration: none;
}

.form-row label .optional {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--gd-muted);
  font-size: 14px;
}

/* Form inputs - unified treatment */
.form-row input.input-text,
.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="tel"],
.form-row input[type="number"],
.form-row textarea,
.form-row select,
.form-row#billing_country_field .woocommerce-input-wrapper strong,
.intl-tel-input.allow-dropdown {
  width: 100% !important;
  max-width: 100%;
  display: block;
  background: var(--gd-warm);
  border: 1px solid var(--gd-border);
  border-radius: 0;
  padding: 0.85rem 1rem;
  font-family: Montserrat, sans-serif;
  font-weight: 400;
  font-size: 15px;
  color: var(--gd-onyx);
  line-height: 1.5;
  outline: none;
  box-shadow: none;
  transition: border-color 0.3s ease, background 0.3s ease;
  box-sizing: border-box;
  min-height: 48px;
}

.form-row input.input-text::placeholder,
.form-row textarea::placeholder {
  color: var(--gd-muted);
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  opacity: 0.7;
}

.form-row input.input-text:focus,
.form-row input[type="text"]:focus,
.form-row input[type="email"]:focus,
.form-row input[type="tel"]:focus,
.form-row textarea:focus,
.form-row select:focus,
.intl-tel-input.allow-dropdown:focus-within {
  border-color: var(--gd-gold);
  background: var(--gd-ivory);
}

.form-row textarea {
  min-height: 90px;
  resize: vertical;
  font-family: Montserrat, sans-serif;
}

.form-row#billing_country_field .woocommerce-input-wrapper strong {
  display: flex;
  align-items: center;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin: 0;
}

/* ==========================================================
   PHONE FIELD (intl-tel-input)
   ========================================================== */
.intl-tel-input {
  position: relative;
}

.intl-tel-input.allow-dropdown input.input-text {
  border: none !important;
  background: transparent;
  padding: 0 0 0 3.5rem;
  min-height: auto;
  width: 100%;
  box-shadow: none;
}

.intl-tel-input .flag-container {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 2;
}

.intl-tel-input .selected-flag {
  height: calc(100% + 2px);
  margin: -1px 0 -1px -1px;
  padding: 0 0.85rem;
  background: transparent;
  border-right: 1px solid var(--gd-border);
  border-top: none;
  border-bottom: none;
  border-left: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
}

.intl-tel-input .country-list {
  background: var(--gd-ivory);
  border: 1px solid var(--gd-border);
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  max-height: 240px;
  overflow-y: auto;
}

.intl-tel-input .country-list .country {
  padding: 0.65rem 1rem;
  color: var(--gd-charcoal);
}

.intl-tel-input .country-list .country.active,
.intl-tel-input .country-list .country:hover {
  background: var(--gd-warm);
  color: var(--gd-onyx);
}

/* ==========================================================
   VALIDATION STATES
   ========================================================== */
.form-row.woocommerce-validated input.input-text,
.form-row.woocommerce-validated .intl-tel-input.allow-dropdown {
  border: 1px solid var(--gd-gold);
}

.form-row.woocommerce-invalid input.input-text,
.form-row.woocommerce-invalid textarea,
.form-row.woocommerce-invalid .intl-tel-input.allow-dropdown {
  border: 1px solid #b85450;
  background: #fdf6f5;
}

/* ==========================================================
   TERMS POLICY EXPANDED CONTENT
   ========================================================== */
.woocommerce-terms-and-conditions {
  font-family: Montserrat, sans-serif;
  font-size: 15px;
  font-weight: 400;
  color: var(--gd-charcoal);
  line-height: 1.7;
  background: var(--gd-warm);
  padding: 1.5rem;
  border: 1px solid var(--gd-border);
  box-shadow: none;
  margin-bottom: 1.25rem;
}

.woocommerce-terms-and-conditions h2 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  font-size: 1.35rem;
  color: var(--gd-onyx);
  margin: 1.25rem 0 0.75rem;
}

.woocommerce-terms-and-conditions h2:first-child { margin-top: 0; }

.woocommerce-terms-and-conditions p { margin-bottom: 0.85rem; }
.woocommerce-terms-and-conditions ul { margin: 0.75rem 0 1rem 1.25rem; }
.woocommerce-terms-and-conditions ul li { margin-bottom: 0.4rem; }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (max-width: 640px) {
  #brxe-oscomn { padding: 2.5rem 1rem 4rem; }
  #brxe-xwxgkq,
  .woocommerce-checkout-review-order,
  #brxe-ypyyhs,
  #payment.woocommerce-checkout-payment {
    padding: 1.75rem 1.25rem;
  }
  .woocommerce-billing-fields__field-wrapper,
  .woocommerce-additional-fields__field-wrapper {
    grid-template-columns: 1fr;
  }
  .form-row.form-row-first,
  .form-row.form-row-last { grid-column: 1; }
  #brxe-hjuofh { margin-bottom: 0; }

  .shop_table tfoot tr.order-total td strong,
  .shop_table tfoot tr.order-total td strong .woocommerce-Price-amount,
  .shop_table tfoot tr.order-total td strong .woocommerce-Price-amount.amount-bgn {
    font-size: 1.5rem;
  }
}
function reorderCheckout() {
  const shippingRow = document.querySelector('tr.woocommerce-shipping-totals');
  const billingBlock = document.querySelector('#brxe-ypyyhs');
  
  if (!shippingRow || !billingBlock) return;

  // Remove old wrapper if exists
  const existing = billingBlock.querySelector('.gd-shipping-wrapper');
  if (existing) existing.remove();

  const wrapper = document.createElement('table');
  wrapper.className = 'gd-shipping-wrapper';
  wrapper.appendChild(shippingRow);
  billingBlock.appendChild(wrapper);
}

reorderCheckout();
$(document.body).on('updated_checkout', reorderCheckout);

$(document).ready(function() {
  setTimeout(reorderCheckout, 500);
  $(document.body).on('updated_checkout', reorderCheckout);
});