/**
 * PrimeFit Theme - Checkout Styles
 *
 * Colours, radii, control sizes and type sizes come from the --checkout-*
 * tokens in theme.css. Change the look there, not here.
 *
 * @package PrimeFit
 * @since 1.0.0
 */

/* ==========================================================================
   Checkout Layout & Structure
   ========================================================================== */

/* Main checkout container */
.checkout-container {
  background: var(--checkout-bg);
  color: var(--checkout-text);
  font-size: var(--checkout-font-base);
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  /* clip, not hidden: hidden makes this a scroll container and breaks the
     sticky order summary. */
  overflow-x: hidden;
  overflow-x: clip;
}

/* Form controls do not inherit the page font by default */
.checkout-container input,
.checkout-container select,
.checkout-container textarea,
.checkout-container button {
  font-family: inherit;
}

.woocommerce-checkout {
  background: var(--checkout-bg);
  margin: 0;
  padding: 0;
}

/* Empty bag state (shown in place of the form, no redirect) */
.checkout-empty {
  max-width: 480px;
  margin: 0 auto;
  padding: 96px 20px;
  text-align: center;
}

/* html and body both set overflow-x: hidden in app.css, which turns body into
   its own (non-scrolling) scroll container and stops sticky children from
   sticking to the viewport. clip gives the same cropping without that. */
html:has(body.woocommerce-checkout),
body.woocommerce-checkout {
  overflow-x: clip;
}

/* Main checkout layout */
.checkout-layout {
  display: grid;
  max-width: var(--checkout-content-width);
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

.checkout-layout > * {
  min-width: 0;
}

/* Desktop layout - use grid to control positioning */
@media (min-width: 1025px) {
  .checkout-layout {
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    /* Summary spans both rows on the right; payment sits under the form on
       the left. Spare height goes below the payment section. */
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "form summary"
      "payment summary";
    column-gap: 72px;
    padding: 56px 40px 96px;
  }

  .checkout-form-section {
    grid-area: form;
  }

  .checkout-summary-section {
    grid-area: summary;
    align-self: start;
    position: sticky;
    /* The site header is position: fixed (~57px tall), so clear it plus a gap. */
    top: 88px;
    scroll-margin-top: 88px;
    padding: 24px;
    border-radius: var(--checkout-radius-lg);
  }

  /* Position payment section in grid on desktop */
  .payment-options-section {
    grid-area: payment;
    padding: 32px 0 0;
  }
}

/* Left column - Checkout form */
.checkout-form-section {
  background: var(--checkout-bg);
  width: 100%;
  box-sizing: border-box;
}

/* Right column - Order summary */
.checkout-summary-section {
  background: var(--checkout-summary-bg);
  height: fit-content;
  box-sizing: border-box;
}

/* ==========================================================================
   Form Section Styles
   ========================================================================== */

.form-section {
  margin-bottom: var(--checkout-section-gap);
}

.form-section:last-child {
  margin-bottom: 0;
}

.section-title {
  font-size: var(--checkout-font-lg);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--checkout-text);
  margin: 0 0 6px 0;
}

.section-description {
  font-size: var(--checkout-font-base);
  color: var(--checkout-text-muted);
  margin: 0 0 18px 0;
  line-height: 1.45;
}

.guest-checkout-notice {
  font-size: var(--checkout-font-sm);
  color: var(--checkout-text-muted);
  margin: 10px 0 0 0;
}

.form-field {
  margin-bottom: 0;
  width: 100%;
}

.form-field input,
.form-field select {
  width: 100%;
  max-width: 100%;
  min-height: var(--checkout-control-height);
  padding: 0 var(--checkout-control-padding-x);
  border: 1px solid var(--checkout-input-border);
  border-radius: var(--checkout-radius);
  font-size: var(--checkout-font-md);
  background: var(--checkout-input-bg);
  color: var(--checkout-text);
  transition:
    border-color var(--checkout-transition),
    box-shadow var(--checkout-transition);
  box-sizing: border-box;
  display: block;
}

.form-field input:hover,
.form-field select:hover {
  border-color: var(--checkout-input-hover-border);
}

.form-field input:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--checkout-input-focus-border);
}

.form-field input::placeholder {
  color: var(--checkout-text-light);
}

/* Dropdowns: native arrow replaced by the themed caret */
.form-field select,
.woocommerce-checkout select {
  background-color: var(--checkout-dropdown-bg) !important;
  color: var(--checkout-dropdown-text) !important;
  border: 1px solid var(--checkout-input-border) !important;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: var(--checkout-select-caret) !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 16px !important;
  padding-right: 42px !important;
  cursor: pointer;
}

.form-field select:focus,
.woocommerce-checkout select:focus {
  border-color: var(--checkout-input-focus-border) !important;
  outline: none !important;
}

/* Dropdown options styling */
.form-field select option,
.woocommerce-checkout select option {
  background: var(--checkout-dropdown-bg) !important;
  color: var(--checkout-dropdown-text) !important;
  padding: 8px 12px !important;
}

.form-field select option:hover,
.woocommerce-checkout select option:hover {
  background: var(--checkout-dropdown-hover) !important;
}

.form-field select option:checked,
.woocommerce-checkout select option:checked {
  background: var(--checkout-dropdown-selected) !important;
}

/* Form row layout for side-by-side fields */
.form-row {
  display: flex;
  gap: var(--checkout-field-gap);
  margin-bottom: var(--checkout-field-gap);
  width: 100%;
}

.form-row .form-field {
  flex: 1;
  margin-bottom: 0;
  min-width: 0;
}

/* ==========================================================================
   Order Summary Styles
   ========================================================================== */

.summary-title {
  font-size: var(--checkout-font-md);
  font-weight: 600;
  color: var(--checkout-text);
  margin: 0;
}

/* Summary header for mobile collapsible */
.summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
}

.summary-header .summary-title {
  margin: 0;
  flex: 1;
}

.summary-total-mobile {
  font-size: var(--checkout-font-md);
  font-weight: 600;
  color: var(--checkout-text);
  margin-right: 8px;
}

.summary-toggle {
  background: none;
  border: none;
  color: var(--checkout-text);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.summary-toggle .arrow {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.summary-toggle.collapsed .arrow {
  transform: rotate(-90deg);
}

.summary-content {
  transition:
    max-height 0.3s ease,
    margin 0.3s ease,
    padding 0.3s ease,
    opacity 0.3s ease;
  overflow: hidden;
}

.summary-content.collapsed {
  max-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
}

/* Hide mobile elements on desktop */
@media (min-width: 1025px) {
  .mobile-only {
    display: none !important;
  }

  .summary-header {
    display: none;
  }

  .summary-content {
    display: block !important;
    max-height: none !important;
    opacity: 1 !important;
  }
}

/* Order items. Scoped to the summary so the order-received page, which also
   loads this file, keeps its own item styles. */
.checkout-summary-section .order-items {
  /* Room for the quantity badge, which sits outside the thumbnail */
  padding-top: 8px;
}

.checkout-summary-section .order-item {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  align-items: center;
}

.checkout-summary-section .order-item:last-child {
  margin-bottom: 0;
}

.checkout-summary-section .item-image {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  border: 1px solid var(--checkout-border);
  border-radius: var(--checkout-radius);
  background: var(--checkout-bg);
  box-sizing: border-box;
}

.checkout-summary-section .item-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  /* iOS Safari scroll flickering prevention */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.checkout-summary-section .item-image .item-quantity {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  box-sizing: border-box;
  border-radius: var(--checkout-radius-pill);
  background: var(--checkout-text);
  color: var(--checkout-bg);
  /* Ring in the panel colour so the badge reads against the thumbnail */
  box-shadow: 0 0 0 2px var(--checkout-summary-bg);
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

.checkout-summary-section .item-details {
  flex: 1;
  min-width: 0;
}

/* Two lines, so the size at the end of the name is not cut off */
.checkout-summary-section .item-name {
  max-width: calc(100% - 10px);
  font-size: var(--checkout-font-base);
  font-weight: 500;
  color: var(--checkout-text);
  margin: 0 0 2px 0;
  line-height: 1.35;
  text-transform: none;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.checkout-summary-section .item-price {
  font-size: var(--checkout-font-sm);
  color: var(--checkout-text-muted);
  margin: 0;
}

/* Hide prices for bundle child items */
.order-item.primefit-bundle-child .item-price,
.order-item.primefit-bundle-child .item-total {
  display: none !important;
}

.checkout-summary-section .item-attribute,
.checkout-summary-section .item-details .variation {
  font-size: var(--checkout-font-sm);
  color: var(--checkout-text-muted);
  margin: 2px 0 0 0;
}

.checkout-summary-section .item-details .variation dt,
.checkout-summary-section .item-details .variation dd,
.checkout-summary-section .item-details .variation p {
  display: inline;
  margin: 0;
  font-weight: 400;
}

.checkout-summary-section .item-total {
  font-size: var(--checkout-font-base);
  font-weight: 500;
  color: var(--checkout-text);
  text-align: right;
  white-space: nowrap;
  flex-shrink: 0;
}

/* NOTE: Do not hide totals globally when bundles exist.
   Only bundle child items should have prices hidden. */

/* Coupon section */
.coupon-section {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--checkout-border);
}

.coupon-toggle {
  background: none;
  border: none;
  color: var(--checkout-text);
  font-size: var(--checkout-font-base);
  font-weight: 500;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.coupon-toggle .arrow {
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.coupon-toggle.is-expanded .arrow {
  transform: rotate(180deg);
}

/* Coupon form */
.coupon-form {
  margin-top: 12px;
}

.coupon-input-group {
  display: flex;
  gap: 8px;
}

.coupon-input {
  flex: 1;
  min-width: 0;
  height: var(--checkout-control-height);
  padding: 0 var(--checkout-control-padding-x);
  border: 1px solid var(--checkout-input-border);
  border-radius: var(--checkout-radius);
  font-size: var(--checkout-font-md);
  background: var(--checkout-input-bg);
  color: var(--checkout-text);
  box-sizing: border-box;
  text-transform: uppercase;
  transition:
    border-color var(--checkout-transition),
    box-shadow var(--checkout-transition);
}

.coupon-input:focus {
  outline: none;
  border-color: var(--checkout-input-focus-border);
  box-shadow: var(--focus-ring-inset);
}

.coupon-input::placeholder {
  color: var(--checkout-text-light);
  text-transform: none;
}

.coupon-apply-btn {
  height: var(--checkout-control-height);
  padding: 0 20px;
  background: var(--checkout-button-bg);
  color: var(--checkout-button-text);
  border: none;
  border-radius: var(--checkout-radius);
  font-size: var(--checkout-font-base);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--checkout-transition);
  white-space: nowrap;
}

.coupon-apply-btn:hover {
  background: var(--checkout-button-hover-bg);
}

.coupon-apply-btn:disabled {
  background: var(--checkout-button-disabled-bg);
  color: var(--checkout-button-disabled-text);
  cursor: not-allowed;
}

.coupon-section.coupon-section--active .coupon-form,
.coupon-form.coupon-form--disabled {
  cursor: not-allowed;
}

.coupon-section.coupon-section--active .coupon-input,
.coupon-section.coupon-section--active .coupon-apply-btn,
.coupon-form.coupon-form--disabled .coupon-input,
.coupon-form.coupon-form--disabled .coupon-apply-btn {
  cursor: not-allowed;
}

/* Order totals */
.order-totals {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--checkout-border);
}

.total-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  font-size: var(--checkout-font-base);
}

.total-label {
  color: var(--checkout-text-muted);
}

.total-value {
  font-weight: 500;
  color: var(--checkout-text);
  text-align: right;
}

/* "Remove" link WooCommerce prints beside an applied coupon */
.total-value .woocommerce-remove-coupon {
  margin-left: 6px;
  font-size: var(--checkout-font-sm);
  font-weight: 400;
  color: var(--checkout-text-muted);
  text-decoration: underline;
}

.total-line.final-total {
  margin-top: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--checkout-border);
  color: var(--checkout-text);
}

.total-line.final-total .total-label {
  font-size: var(--checkout-font-md);
  font-weight: 600;
  color: var(--checkout-text);
}

.total-line.final-total .total-value {
  font-size: var(--checkout-font-lg);
  font-weight: 700;
  color: var(--checkout-text);
}

.total-line.bundle-savings .total-label,
.total-line.bundle-savings .total-value {
  color: var(--checkout-success);
}

/* Shipping row (WooCommerce prints it as a table row): same look as a total line */
.order-totals .checkout-shipping-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.order-totals .checkout-shipping-table th,
.order-totals .checkout-shipping-table td {
  padding: 0;
  font-size: var(--checkout-font-base);
  vertical-align: top;
  text-transform: none;
}

.order-totals .checkout-shipping-table th {
  font-weight: 400;
  text-align: left;
  color: var(--checkout-text-muted);
}

.order-totals .checkout-shipping-table td {
  text-align: right;
  font-weight: 500;
  color: var(--checkout-text);
}

.order-totals .checkout-shipping-table #shipping_method {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* ==========================================================================
   Checkout Form Styles
   ========================================================================== */

/* Optional field wrapper for positioning optional text */
.optional-field-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

/* Optional text styling */
.optional-text {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: var(--checkout-font-xs);
  color: var(--checkout-text-light);
  pointer-events: none;
  z-index: 5;
  background: var(--checkout-input-bg);
  padding: 0 4px;
  border-radius: var(--checkout-radius-sm);
}

/* Ensure optional text doesn't interfere with input focus */
.optional-field-wrapper input:focus + .optional-text,
.optional-field-wrapper select:focus + .optional-text {
  opacity: 0.7;
}

/* Ensure optional text has proper spacing from input content */
.optional-field-wrapper input {
  padding-right: 80px; /* Make space for optional text */
}

.optional-field-wrapper select {
  padding-right: 80px; /* Make space for optional text */
}

/* Special handling for phone field to avoid conflict with help icon */
.phone-field-with-help .optional-text {
  right: 40px; /* Move left to avoid help icon */
}

/* Phone field with help icon inside */
.phone-field-with-help {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

/* The error is added after the input: give it its own line */
.phone-field-with-help .phone-error-message {
  flex-basis: 100%;
}

.phone-field-with-help input {
  width: 100%;
  padding-right: 44px; /* Make space for the help icon */
}

/* Help icon positioned inside the input field */
.help-icon-inside {
  position: absolute;
  right: 14px;
  /* Centred on the input, not the wrapper, which grows when an error shows */
  top: calc(var(--checkout-control-height) / 2);
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: var(--checkout-surface);
  border: 1px solid var(--checkout-border);
  border-radius: 50%;
  box-sizing: border-box;
  color: var(--checkout-text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  z-index: 10;
}

/* Tooltip for help icon */
.help-icon-inside::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  transform: translateX(-50%);
  background: var(--checkout-text);
  color: var(--checkout-bg);
  padding: 8px 12px;
  border-radius: var(--checkout-radius-sm);
  font-size: var(--checkout-font-xs);
  font-weight: 400;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--checkout-transition);
  z-index: 1000;
  margin-bottom: 8px;
  box-shadow: var(--checkout-shadow);
}

.help-icon-inside:hover::after {
  opacity: 1;
  visibility: visible;
}

/* Mobile tooltip behavior */
@media (max-width: 768px) {
  .help-icon-inside:hover::after {
    opacity: 0;
    visibility: hidden;
  }

  .help-icon-inside.mobile-tooltip-active::after {
    opacity: 1;
    visibility: visible;
  }
}

/* Country-based field hiding */
#billing_address_2_field,
#billing_postcode_field {
  transition:
    opacity 0.3s ease,
    max-height 0.3s ease;
  overflow: hidden;
}

#billing_address_2_field.hidden,
#billing_postcode_field.hidden {
  display: none !important;
}

/* Phone field validation styles */
#billing_phone.phone-valid {
  border-color: var(--checkout-success);
  box-shadow: 0 0 0 1px var(--checkout-success);
}

#billing_phone.phone-invalid {
  border-color: var(--checkout-error);
  box-shadow: 0 0 0 1px var(--checkout-error);
}

.phone-error-message {
  color: var(--checkout-error);
  font-size: var(--checkout-font-xs);
  margin-top: 4px;
  display: block;
}

/* ==========================================================================
   Payment Error Styles
   ========================================================================== */

.woocommerce-error {
  background: var(--checkout-error-surface);
  color: var(--checkout-error);
  border: 1px solid var(--checkout-error);
  padding: 14px 16px;
  border-radius: var(--checkout-radius);
  margin-bottom: 20px;
  font-size: var(--checkout-font-base);
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 12px;
}

.woocommerce-error::before {
  content: "!";
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  background: var(--checkout-error);
  color: var(--checkout-error-surface);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Several order-level messages: one per line beside the icon */
ul.woocommerce-error {
  display: block;
  position: relative;
  padding-left: 48px;
  list-style: none;
}

ul.woocommerce-error::before {
  position: absolute;
  left: 16px;
  top: 14px;
}

ul.woocommerce-error li + li {
  margin-top: 4px;
}

/* Field Error Styles */
.field-error {
  color: var(--checkout-error);
  font-size: var(--checkout-font-xs);
  margin-top: 4px;
  display: block;
  margin-bottom: 2px;
}

/* ==========================================================================
   Select2 Dropdown Styling
   ========================================================================== */

/* Select2 container styling */
.select2-container {
  width: 96%;
  position: relative;
  display: inline-block;
  vertical-align: middle;
  font-size: 14px;
  line-height: 1.42857143;
  color: var(--checkout-text);
  background: var(--checkout-input-bg);
  border-radius: var(--checkout-radius);
  box-sizing: border-box;
}

.select2-container--default .select2-selection--single {
  height: 48px;
  border: none;
  background: transparent;
  outline: none;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
}

.select2-container--default
  .select2-selection--single
  .select2-selection__rendered {
  color: var(--checkout-text);
  line-height: 48px;
  padding: 0;
  width: 100%;
}

.select2-container--default
  .select2-selection--single
  .select2-selection__placeholder {
  color: var(--checkout-text-light);
}

.select2-container--default
  .select2-selection--single
  .select2-selection__arrow {
  height: 46px;
  position: absolute;
  top: 1px;
  right: 1px;
  width: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.select2-container--default
  .select2-selection--single
  .select2-selection__arrow
  b {
  border-color: var(--checkout-text) transparent transparent transparent;
  border-style: solid;
  border-width: 5px 4px 0 4px;
  height: 0;
  left: 50%;
  margin-left: -4px;
  margin-top: -2px;
  position: absolute;
  top: 50%;
  width: 0;
}

.select2-container--default.select2-container--open
  .select2-selection--single
  .select2-selection__arrow
  b {
  border-color: transparent transparent var(--checkout-text) transparent;
  border-width: 0 4px 5px 4px;
}

/* Select2 dropdown styling */
.select2-dropdown {
  background: var(--checkout-dropdown-bg);
  border: 1px solid var(--checkout-input-border);
  border-radius: var(--checkout-radius);
  box-sizing: border-box;
  display: block;
  position: absolute;
  left: -100000px;
  width: 100%;
  z-index: 1051;
  box-shadow: var(--checkout-shadow);
}

.select2-container--open .select2-dropdown {
  left: 0;
}

.select2-search--dropdown {
  display: block;
  padding: 4px;
}

.select2-search--dropdown .select2-search__field {
  padding: 8px 12px;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--checkout-input-border);
  border-radius: var(--checkout-radius);
  background: var(--checkout-input-bg);
  color: var(--checkout-text);
  font-size: 14px;
}

.select2-search--dropdown .select2-search__field:focus {
  outline: none;
  border-color: var(--checkout-input-focus-border);
}

.select2-results {
  display: block;
  max-height: 200px;
  overflow-y: auto;
}

.select2-results__options {
  list-style: none;
  margin: 0;
  padding: 0;
}

.select2-results__option {
  padding: 8px 12px;
  user-select: none;
  cursor: pointer;
  color: var(--checkout-dropdown-text);
  background: var(--checkout-dropdown-bg);
  border-bottom: 1px solid var(--checkout-border);
}

.select2-results__option:last-child {
  border-bottom: none;
}

.select2-results__option--highlighted {
  background: var(--checkout-dropdown-hover);
  color: var(--checkout-text);
}

.select2-results__option[aria-selected="true"] {
  background: var(--checkout-dropdown-selected);
  color: var(--checkout-text);
}

/* Focus states */
.select2-container--default.select2-container--focus
  .select2-selection--single {
  border-color: var(--checkout-input-focus-border);
}

/* ==========================================================================
   WooCommerce Specific Overrides
   ========================================================================== */

/* Hide default WooCommerce checkout styles */
.woocommerce-checkout .woocommerce-form-coupon-toggle,
.woocommerce-checkout .woocommerce-form-coupon {
  display: none;
}

/* Override WooCommerce checkout page styling */
.woocommerce-checkout .woocommerce {
  background: var(--checkout-bg);
  margin: 0;
  padding: 0;
}

.woocommerce-checkout .woocommerce .woocommerce-checkout {
  background: var(--checkout-bg);
  margin: 0;
  padding: 0;
}

/* Hide default WooCommerce notices on checkout (not order-received) */
.woocommerce-checkout:not(.woocommerce-order-received)
  .woocommerce-notices-wrapper {
  display: none;
}

/* ...except errors. A sold-out item or another cart problem has to be visible,
   otherwise the customer cannot check out and is never told why. */
.woocommerce-checkout:not(.woocommerce-order-received)
  .woocommerce-notices-wrapper:has(.woocommerce-error) {
  display: block !important;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 16px 0;
  box-sizing: border-box;
}

.woocommerce-checkout:not(.woocommerce-order-received)
  .woocommerce-notices-wrapper:has(.woocommerce-error)
  > :not(.woocommerce-error) {
  display: none;
}

.woocommerce-checkout:not(.woocommerce-order-received) .woocommerce-message {
  display: none;
}

/* Override WooCommerce form styling */
.woocommerce-checkout .form-row {
  margin-bottom: var(--checkout-field-gap);
  box-sizing: border-box;
  flex-direction: column;
}

.woocommerce-checkout .form-row input,
.woocommerce-checkout .form-row select,
.woocommerce-checkout .form-row textarea {
  padding: 0 var(--checkout-control-padding-x);
  border: 1px solid var(--checkout-input-border);
  border-radius: var(--checkout-radius);
  font-size: var(--checkout-font-md);
  background-color: var(--checkout-input-bg) !important;
  color: var(--checkout-text) !important;
  box-sizing: border-box;
  transition:
    border-color var(--checkout-transition),
    box-shadow var(--checkout-transition);
}

/* Text-like controls share one height; checkboxes and radios keep their own */
.woocommerce-checkout
  .form-row
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
.woocommerce-checkout .form-row select {
  min-height: var(--checkout-control-height);
}

.woocommerce-checkout .form-row textarea {
  padding-top: 12px;
  padding-bottom: 12px;
  min-height: 96px;
}

.woocommerce-checkout .form-row input:hover,
.woocommerce-checkout .form-row select:hover,
.woocommerce-checkout .form-row textarea:hover {
  border-color: var(--checkout-input-hover-border);
}

.woocommerce-checkout .form-row input:focus,
.woocommerce-checkout .form-row select:focus,
.woocommerce-checkout .form-row textarea:focus {
  outline: none;
  border-color: var(--checkout-input-focus-border);
}

.woocommerce-checkout .form-row input::placeholder,
.woocommerce-checkout .form-row select::placeholder,
.woocommerce-checkout .form-row textarea::placeholder {
  color: var(--checkout-text-light);
}

/* Room for the "(optional)" hint and the phone help icon inside the field */
.woocommerce-checkout .form-row .optional-field-wrapper input,
.woocommerce-checkout .form-row .phone-field-with-help input {
  flex: 1;
  width: 100%;
  min-width: 0;
}

.woocommerce-checkout .form-row .optional-field-wrapper input {
  padding-right: 84px;
}

.woocommerce-checkout .form-row .phone-field-with-help input {
  padding-right: 44px;
}

/* Billing fields: two columns, with paired fields (first/last name,
   postcode/phone) side by side and everything else full width */
.woocommerce-checkout .woocommerce-billing-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--checkout-field-gap);
  /* Inline errors are added above a field; keep paired inputs on one line */
  align-items: end;
}

.woocommerce-checkout .woocommerce-billing-fields .form-row {
  width: auto;
  float: none;
  margin: 0;
}

.woocommerce-checkout .woocommerce-billing-fields .form-row-wide,
.woocommerce-checkout .woocommerce-billing-fields > :not(.form-row) {
  grid-column: 1 / -1;
}

/* Postcode is hidden for some countries (the script slides it shut, which
   leaves an inline display: none): let the phone take the full row */
.woocommerce-checkout
  .woocommerce-billing-fields
  #billing_postcode_field.hidden
  + .form-row-last,
.woocommerce-checkout
  .woocommerce-billing-fields
  #billing_postcode_field[style*="display: none"]
  + .form-row-last {
  grid-column: 1 / -1;
}

@media (max-width: 600px) {
  .woocommerce-checkout .woocommerce-billing-fields .form-row {
    grid-column: 1 / -1;
  }
}

/* Billing and shipping sections */
.woocommerce-checkout .woocommerce-shipping-fields {
  margin-top: var(--checkout-section-gap);
}

.woocommerce-checkout .woocommerce-billing-fields h3,
.woocommerce-checkout .woocommerce-shipping-fields h3 {
  font-size: var(--checkout-font-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--checkout-text);
  margin: 0 0 8px 0;
}

/* Additional billing details section */
.woocommerce-checkout .woocommerce-billing-fields h3:first-of-type {
  margin-top: 0;
}

.woocommerce-checkout .woocommerce-billing-fields h3:not(:first-of-type) {
  margin-top: 24px;
  margin-bottom: 8px;
}

/* Ensure all form fields have consistent width and dark theme */
.woocommerce-checkout .woocommerce-billing-fields input,
.woocommerce-checkout .woocommerce-billing-fields select,
.woocommerce-checkout .woocommerce-billing-fields textarea {
  box-sizing: border-box !important;
  background-color: var(--checkout-input-bg) !important;
  color: var(--checkout-text) !important;
  border: 1px solid var(--checkout-input-border) !important;
}

.woocommerce-checkout .woocommerce-billing-fields input:hover,
.woocommerce-checkout .woocommerce-billing-fields select:hover,
.woocommerce-checkout .woocommerce-billing-fields textarea:hover {
  border-color: var(--checkout-input-hover-border) !important;
}

.woocommerce-checkout .woocommerce-billing-fields input:focus,
.woocommerce-checkout .woocommerce-billing-fields select:focus,
.woocommerce-checkout .woocommerce-billing-fields textarea:focus {
  border-color: var(--checkout-input-focus-border) !important;
  outline: none !important;
}

.woocommerce-checkout .woocommerce-billing-fields input::placeholder,
.woocommerce-checkout .woocommerce-billing-fields textarea::placeholder {
  color: var(--checkout-text-light) !important;
}

/* Order review table */
.woocommerce-checkout-review-order-table {
  width: 100%;
  border-collapse: collapse;
}

.product-name {
  word-break: break-word;
  overflow-wrap: break-word;
  max-width: 120px;
  white-space: normal;
}

.woocommerce-checkout-review-order-table th,
.woocommerce-checkout-review-order-table td {
  padding: 12px 0;
  text-align: left;
  font-size: var(--checkout-font-base);
}

/* Right-align totals (subtotal/total) column */
.woocommerce-checkout-review-order-table th:last-child,
.woocommerce-checkout-review-order-table td:last-child {
  text-align: right;
}

.woocommerce-checkout-review-order-table th {
  font-weight: 600;
  color: var(--checkout-text);
}

.woocommerce-checkout-review-order-table td {
  color: var(--checkout-text-muted);
}

.woocommerce-checkout-review-order-table .order-total {
  font-weight: 700;
  font-size: var(--checkout-font-md);
  color: var(--checkout-text);
}

/* Payment methods: one bordered list, a row per method */
.woocommerce-checkout .payment_methods {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  border: 1px solid var(--checkout-input-border);
  border-radius: var(--checkout-radius);
  background: var(--checkout-input-bg);
  overflow: hidden;
}

.woocommerce-checkout .payment_methods li {
  margin-bottom: 0;
  position: relative;
  border-bottom: 1px solid var(--checkout-border);
}

.woocommerce-checkout .payment_methods li:last-child {
  border-bottom: none;
}

/* Payment method container */
.woocommerce-checkout .payment_methods li .payment_method {
  padding: 16px;
  position: relative;
}

.woocommerce-checkout .payment_methods li .payment_method.selected {
  background: transparent;
}

/* Payment method label */
.woocommerce-checkout .payment_methods label {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: var(--checkout-font-md);
  font-weight: 500;
  color: var(--checkout-text);
  cursor: pointer;
  margin: 0;
  padding: 0;
  width: 100%;
  position: relative;
}

/* Custom radio button: a ring that fills when selected */
.woocommerce-checkout .payment_methods input[type="radio"] {
  position: relative;
  width: 20px;
  height: 20px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--checkout-input-border);
  background: var(--checkout-input-bg);
  border-radius: 50%;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: border var(--checkout-transition);
}

.woocommerce-checkout .payment_methods input[type="radio"]:hover {
  border-color: var(--checkout-input-hover-border);
}

.woocommerce-checkout .payment_methods input[type="radio"]:checked {
  border: 6px solid var(--checkout-text);
  background: var(--checkout-bg);
}

.woocommerce-checkout .payment_methods input[type="radio"]:focus-visible {
  outline: 2px solid var(--checkout-input-focus-border);
  outline-offset: 2px;
}

/* Payment method title */
.payment-method-title {
  font-size: var(--checkout-font-md);
  font-weight: 500;
  color: var(--checkout-text);
  margin: 0;
  line-height: 1.3;
}

/* Payment method content: title, then badge, then description on its own line */
.payment-method-content {
  flex: 1;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  position: relative;
}

.payment-method-description {
  flex-basis: 100%;
  font-size: var(--checkout-font-base);
  color: var(--checkout-text-muted);
  margin: 0;
  line-height: 1.4;
}

/* Payment box - details shown under the selected method */
.woocommerce-checkout .payment_methods .payment_box {
  margin-top: 14px;
  border: none;
  border-radius: var(--checkout-radius-sm);
  font-size: var(--checkout-font-base);
  line-height: 1.45;
  color: var(--checkout-text-muted);
}

.woocommerce-checkout .payment_methods .payment_box > p {
  margin: 0;
}

.woocommerce-checkout .payment_methods .payment_box > p + p {
  margin-top: 8px;
}

/* Payment box fields */
.woocommerce-checkout .payment_methods .payment_box .form-row {
  margin-bottom: var(--checkout-field-gap);
}

.woocommerce-checkout .payment_methods .payment_box input[type="text"],
.woocommerce-checkout .payment_methods .payment_box input[type="tel"],
.woocommerce-checkout .payment_methods .payment_box input[type="email"] {
  width: 100%;
  min-height: var(--checkout-control-height);
  padding: 0 var(--checkout-control-padding-x);
  border: 1px solid var(--checkout-input-border);
  border-radius: var(--checkout-radius);
  font-size: var(--checkout-font-md);
  background: var(--checkout-input-bg);
  color: var(--checkout-text);
  transition:
    border-color var(--checkout-transition),
    box-shadow var(--checkout-transition);
  box-sizing: border-box;
}

.woocommerce-checkout .payment_methods .payment_box input[type="text"]:focus,
.woocommerce-checkout .payment_methods .payment_box input[type="tel"]:focus,
.woocommerce-checkout .payment_methods .payment_box input[type="email"]:focus {
  outline: none;
  border-color: var(--checkout-input-focus-border);
}

.woocommerce-checkout
  .payment_methods
  .payment_box
  input[type="text"]::placeholder,
.woocommerce-checkout
  .payment_methods
  .payment_box
  input[type="tel"]::placeholder,
.woocommerce-checkout
  .payment_methods
  .payment_box
  input[type="email"]::placeholder {
  color: var(--checkout-text-light);
}

/* Card number field with icon */
.woocommerce-checkout .payment_methods .payment_box .form-row-first {
  position: relative;
}

.woocommerce-checkout .payment_methods .payment_box .form-row-first input {
  padding-right: 40px;
}

.woocommerce-checkout .payment_methods .payment_box .form-row-first::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background-color: var(--checkout-text-light);
  -webkit-mask: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='4' y='11' width='16' height='10' rx='2'/%3e%3cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3e%3c/svg%3e")
    center / contain no-repeat;
  mask: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='4' y='11' width='16' height='10' rx='2'/%3e%3cpath d='M8 11V7a4 4 0 0 1 8 0v4'/%3e%3c/svg%3e")
    center / contain no-repeat;
  pointer-events: none;
  z-index: 5;
}

/* Security code field with help icon */
.woocommerce-checkout .payment_methods .payment_box .form-row-last {
  position: relative;
}

.woocommerce-checkout .payment_methods .payment_box .form-row-last input {
  padding-right: 40px;
}

.woocommerce-checkout .payment_methods .payment_box .form-row-last::after {
  content: "?";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--checkout-surface);
  border: 1px solid var(--checkout-border);
  border-radius: 50%;
  box-sizing: border-box;
  font-size: 11px;
  font-weight: 600;
  color: var(--checkout-text-muted);
  pointer-events: none;
  z-index: 5;
}

/* Side-by-side fields for expiration and security code */
.woocommerce-checkout .payment_methods .payment_box .form-row.form-row-first,
.woocommerce-checkout .payment_methods .payment_box .form-row.form-row-last {
  display: inline-block;
  width: calc(50% - 8px);
  vertical-align: top;
}

.woocommerce-checkout .payment_methods .payment_box .form-row.form-row-first {
  margin-right: 16px;
}

/* Billing address checkbox */
.woocommerce-checkout
  .payment_methods
  .payment_box
  .form-row-wide
  input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0 8px 0 0;
  cursor: pointer;
  border: 1px solid var(--checkout-input-border);
  background: var(--checkout-input-bg);
  border-radius: 4px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  position: relative;
  flex-shrink: 0;
  transition:
    background-color var(--checkout-transition),
    border-color var(--checkout-transition);
}

.woocommerce-checkout
  .payment_methods
  .payment_box
  .form-row-wide
  input[type="checkbox"]:checked {
  background: var(--checkout-text);
  border-color: var(--checkout-text);
}

.woocommerce-checkout
  .payment_methods
  .payment_box
  .form-row-wide
  input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 8px;
  border: solid var(--checkout-bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.woocommerce-checkout
  .payment_methods
  .payment_box
  .form-row-wide
  input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--checkout-input-focus-border);
  outline-offset: 2px;
}

/* Checkbox label */
.woocommerce-checkout .payment_methods .payment_box .form-row-wide label {
  display: flex;
  align-items: center;
  font-size: var(--checkout-font-base);
  color: var(--checkout-text);
  cursor: pointer;
  margin: 0;
  padding: 0;
}

/* Hide payment box when not selected - WooCommerce handles this, but ensure it works */
.woocommerce-checkout
  .payment_methods
  li:not(.payment_method_selected)
  .payment_box {
  display: none !important;
}

.woocommerce-checkout .payment_methods li.payment_method_selected .payment_box,
.woocommerce-checkout
  .payment_methods
  li
  input[type="radio"]:checked
  ~ .payment_box {
  display: block !important;
}

.woocommerce-shipping-methods {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Payment method badge */
.payment-method-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 9px;
  box-sizing: border-box;
  background: var(--checkout-surface);
  color: var(--checkout-text-muted);
  font-size: var(--checkout-font-xs);
  font-weight: 600;
  line-height: 1;
  max-width: fit-content;
  border-radius: var(--checkout-radius-pill);
}

.payment-method-badge.recommended {
  background: var(--checkout-success-surface);
  color: var(--checkout-success);
}

.payment-method-badge.secure {
  background: var(--checkout-info-surface);
  color: var(--checkout-info);
}

/* Privacy / terms text above the button */
.woocommerce-checkout .place-order {
  margin: 20px 0 0;
  gap: 0;
}

.woocommerce-terms-and-conditions-wrapper {
  font-size: var(--checkout-font-sm);
  line-height: 1.5;
  color: var(--checkout-text-muted);
}

.woocommerce-terms-and-conditions-wrapper a {
  color: var(--checkout-text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.woocommerce-privacy-policy-text > p {
  margin: 0;
  font-size: var(--checkout-font-sm);
  line-height: 1.5;
}

/* Place order button */
.woocommerce-checkout #place_order {
  width: 100%;
  min-height: var(--checkout-button-height);
  padding: 0 24px;
  background: var(--checkout-button-bg);
  color: var(--checkout-button-text);
  border: none;
  border-radius: var(--checkout-radius-pill);
  font-size: var(--checkout-font-md);
  font-weight: 600;
  letter-spacing: 0;
  cursor: pointer;
  transition: background-color var(--checkout-transition);
  margin-top: 20px;
}

.woocommerce-checkout #place_order:hover {
  background: var(--checkout-button-hover-bg);
}

.woocommerce-checkout #place_order:disabled {
  background: var(--checkout-button-disabled-bg);
  color: var(--checkout-button-disabled-text);
  cursor: not-allowed;
}

/* Loading indicator for place order button */
.woocommerce-checkout #place_order.loading,
.woocommerce-checkout #place_order.loading:hover,
.woocommerce-checkout #place_order.loading:disabled {
  position: relative;
  background: var(--checkout-button-bg);
  color: var(--checkout-button-text);
  cursor: progress;
}

.woocommerce-checkout #place_order.loading .loading-dots {
  color: var(--checkout-button-text);
}

.woocommerce-checkout #place_order.loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Animated loading dots */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.loading-dots .dot {
  width: 8px;
  height: 8px;
  background-color: currentColor;
  border-radius: 50%;
  animation: loadingDots 1.4s infinite ease-in-out both;
}

.loading-dots .dot:nth-child(1) {
  animation-delay: -0.32s;
}

.loading-dots .dot:nth-child(2) {
  animation-delay: -0.16s;
}

.loading-dots .dot:nth-child(3) {
  animation-delay: 0s;
}

@keyframes loadingDots {
  0%,
  80%,
  100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 1024px) {
  .checkout-container {
    padding: 0 20px;
    box-sizing: border-box;
  }

  .checkout-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas:
      "summary"
      "form"
      "payment";
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 0 56px;
  }

  .checkout-form-section {
    grid-area: form;
    width: 100%;
    padding: 32px 0 0;
  }

  .checkout-summary-section {
    grid-area: summary;
    width: 100%;
    border-radius: var(--checkout-radius-lg);
    padding: 16px;
  }

  /* Collapsible summary: space opens under the header only while expanded */
  .summary-content:not(.collapsed) {
    margin-top: 16px;
  }

  /* Show mobile collapsible elements */
  .mobile-only {
    display: block !important;
  }

  .summary-header {
    display: flex !important;
  }

  /* Position unified payment section as third item on mobile */
  .payment-options-section {
    grid-area: payment;
    margin-top: 0;
    padding: var(--checkout-section-gap) 0 0;
    border: none;
    display: block;
  }

  /* Keep payment widgets and Stripe iframes inside mobile viewport */
  .payment-options-section iframe,
  .payment-options-section #wc-stripe-cc-form,
  .payment-options-section #wc-stripe-upe-form,
  .payment-options-section .wc-stripe-elements-field,
  .payment-options-section .StripeElement,
  .payment-options-section .__PrivateStripeElement {
    max-width: 100% !important;
    box-sizing: border-box;
  }
}

@media (max-width: 768px) {
  .checkout-container {
    padding: 0 16px;
  }

  .checkout-layout {
    padding-top: 16px;
  }

  .form-row {
    flex-direction: column;
  }

  .section-title {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .checkout-container {
    padding: 0 12px;
  }

  .checkout-layout {
    padding-top: 12px;
  }

  /* Mobile adjustments for optional text */
  .optional-text {
    right: 10px;
  }

  .optional-field-wrapper input {
    padding-right: 76px; /* Reduce space on mobile */
  }

  .optional-field-wrapper select {
    padding-right: 76px; /* Reduce space on mobile */
  }
}

/* ==========================================================================
   Additional WooCommerce Overrides
   ========================================================================== */

/* Hide default order review heading */
.woocommerce-checkout #order_review_heading {
  display: none;
}

/* Payment methods styling - Enhanced version (consolidated with main styles above) */

/* Browser-specific dropdown styling */
select::-ms-expand {
  display: none;
}

select::-webkit-scrollbar {
  width: 8px;
}

select::-webkit-scrollbar-track {
  background: var(--checkout-dropdown-bg);
}

select::-webkit-scrollbar-thumb {
  background: var(--checkout-border);
  border-radius: var(--checkout-radius);
}

select::-webkit-scrollbar-thumb:hover {
  background: var(--checkout-text-light);
}

/* Accessibility: focused fields get an inset focus ring (cannot be clipped by overflow) */
.form-field input:focus,
.form-field select:focus,
.woocommerce-checkout .form-row input:focus,
.woocommerce-checkout .form-row select:focus,
.woocommerce-checkout .form-row textarea:focus {
  box-shadow: var(--focus-ring-inset);
}

.woocommerce-checkout #place_order:focus-visible,
.coupon-apply-btn:focus-visible,
.coupon-toggle:focus-visible,
.summary-toggle:focus-visible {
  outline: 2px solid var(--checkout-input-focus-border);
  outline-offset: 2px;
}

/* ==========================================================================
   Payment Method Styling Fix - High Specificity Override
   ========================================================================== */

/* Prevent flash of unstyled content */
body.woocommerce-checkout .woocommerce-checkout .payment_methods {
  opacity: 0;
  transition: opacity 0.3s ease;
}

body.woocommerce-checkout .woocommerce-checkout .payment_methods.enhanced {
  opacity: 1;
}

/* Ensure payment method styling persists with high specificity */
body.woocommerce-checkout
  .woocommerce-checkout
  .payment_methods
  li
  .payment_method {
  padding: 16px !important;
  position: relative !important;
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

body.woocommerce-checkout
  .woocommerce-checkout
  .payment_methods
  li
  .payment_method.selected {
  background: transparent !important;
}

/* Ensure payment method labels maintain styling */
body.woocommerce-checkout .woocommerce-checkout .payment_methods label {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  font-size: var(--checkout-font-md) !important;
  font-weight: 500 !important;
  color: var(--checkout-text) !important;
  cursor: pointer !important;
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
}

/* Stripe keeps its radio outside the label (its JS binds to it there), so lay
   the radio and label out as one row with the payment box below */
body.woocommerce-checkout
  .woocommerce-checkout
  .payment_methods
  li.payment_method_stripe
  .payment_method {
  display: flex !important;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 12px;
}

body.woocommerce-checkout
  .woocommerce-checkout
  .payment_methods
  li.payment_method_stripe
  label {
  flex: 1;
  width: auto !important;
}

body.woocommerce-checkout
  .woocommerce-checkout
  .payment_methods
  li.payment_method_stripe
  .payment_box {
  flex-basis: 100%;
}

/* Ensure payment method content styling */
body.woocommerce-checkout .payment-method-content {
  flex: 1 !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 4px 8px !important;
  position: relative !important;
}

body.woocommerce-checkout .payment-method-title {
  font-size: var(--checkout-font-md) !important;
  font-weight: 500 !important;
  color: var(--checkout-text) !important;
  line-height: 1.3 !important;
}

body.woocommerce-checkout .payment-method-description {
  font-size: var(--checkout-font-base) !important;
  color: var(--checkout-text-muted) !important;
  line-height: 1.4 !important;
}

/* ==========================================================================
   WooCommerce Checkout Processing Overlay Fix
   ========================================================================== */

/* Override WooCommerce's default checkout processing overlay */
body .blockUI.blockOverlay {
  background-color: var(--checkout-overlay) !important;
  opacity: 1 !important;
}

body .blockUI.blockOverlay::before {
  display: none !important;
}

/* Hide the default WooCommerce checkout processing message */
body .blockUI.blockMsg {
  display: none !important;
}

/* Shopify-style processing state: form goes inert, button shows the spinner */
body.checkout-processing form.checkout {
  pointer-events: none;
  user-select: none;
}

body.checkout-processing form.checkout input,
body.checkout-processing form.checkout select,
body.checkout-processing form.checkout textarea {
  opacity: 0.6;
}

body.checkout-processing #place_order {
  pointer-events: none;
  cursor: progress;
}

/* Legacy modal indicator (no longer rendered) */
body .checkout-processing-indicator {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--checkout-bg);
  color: var(--checkout-text);
  padding: 24px 32px;
  border-radius: var(--checkout-radius-lg);
  border: 1px solid var(--checkout-border);
  z-index: 9999;
  text-align: center;
  box-shadow: var(--checkout-shadow);
}

body .checkout-processing-indicator .spinner {
  width: 32px;
  height: 32px;
  border: 2px solid var(--checkout-border);
  border-top: 2px solid var(--checkout-text);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 15px auto;
}

body .checkout-processing-indicator .message {
  font-size: var(--checkout-font-base);
  font-weight: 500;
  color: var(--checkout-text);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Prevent white flash during checkout processing */
body .woocommerce-checkout .blockUI {
  background-color: transparent !important;
}

/* Ensure the checkout form doesn't show white background during processing */
body .woocommerce-checkout.processing .checkout-container {
  background: var(--checkout-bg) !important;
}

/* Alternative solution - completely hide WooCommerce's default processing overlay */
body .woocommerce-checkout .blockUI {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Override any blockUI calls on checkout pages */
body .woocommerce-checkout .blockOverlay,
body .woocommerce-checkout .blockMsg,
body .woocommerce-checkout .blockUI {
  display: none !important;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Hide the default WooCommerce processing message */
body .woocommerce-checkout .blockMsg h1 {
  display: none !important;
}

/* ==========================================================================
   Country Field Search (Select2) Styles
   ========================================================================== */

/* Select2 container - match checkout input styling */
.woocommerce-checkout .select2-container--default .select2-selection--single {
  background-color: var(--checkout-input-bg) !important;
  border: 1px solid var(--checkout-input-border) !important;
  border-radius: var(--checkout-radius) !important;
  height: var(--checkout-control-height) !important;
  display: flex !important;
  align-items: center !important;
  padding: 0 var(--checkout-control-padding-x) !important;
  font-size: var(--checkout-font-md) !important;
  color: var(--checkout-text) !important;
  /* WooCommerce pulls this up 4px, which makes the gap to the next field uneven */
  margin: 0 !important;
  transition:
    border-color var(--checkout-transition),
    box-shadow var(--checkout-transition) !important;
}

.woocommerce-checkout
  .select2-container--default
  .select2-selection--single:hover {
  border-color: var(--checkout-input-hover-border) !important;
}

.woocommerce-checkout
  .select2-container--default.select2-container--open
  .select2-selection--single,
.woocommerce-checkout
  .select2-container--default.select2-container--focus
  .select2-selection--single {
  border-color: var(--checkout-input-focus-border) !important;
  box-shadow: 0 0 0 1px var(--checkout-input-focus-border);
}

/* Select2 selected value text */
.woocommerce-checkout
  .select2-container--default
  .select2-selection--single
  .select2-selection__rendered {
  color: var(--checkout-text) !important;
  line-height: var(--checkout-control-height) !important;
  padding: 0 !important;
  font-size: var(--checkout-font-md) !important;
}

/* Select2 arrow */
.woocommerce-checkout
  .select2-container--default
  .select2-selection--single
  .select2-selection__arrow {
  top: 0 !important;
  height: var(--checkout-control-height) !important;
  right: 12px !important;
  width: 16px !important;
}

/* Select2's border triangle is swapped for the same chevron native selects use */
.woocommerce-checkout
  .select2-container--default
  .select2-selection--single
  .select2-selection__arrow
  b {
  position: static !important;
  width: 16px !important;
  height: 16px !important;
  margin: 0 !important;
  border: none !important;
  background: var(--checkout-select-caret) center / 16px no-repeat;
  transition: transform var(--checkout-transition);
}

.woocommerce-checkout
  .select2-container--default.select2-container--open
  .select2-selection--single
  .select2-selection__arrow
  b {
  transform: rotate(180deg);
}

/* Select2 dropdown */
.select2-container--default .select2-dropdown {
  background-color: var(--checkout-dropdown-bg) !important;
  border: 1px solid var(--checkout-input-border) !important;
  border-radius: var(--checkout-radius) !important;
  box-shadow: var(--checkout-shadow) !important;
  margin-top: 4px !important;
  overflow: hidden !important;
}

/* Select2 search box */
.select2-container--default .select2-search--dropdown {
  padding: 8px !important;
  background-color: var(--checkout-dropdown-bg) !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  background-color: var(--checkout-input-bg) !important;
  border: 1px solid var(--checkout-input-border) !important;
  border-radius: var(--checkout-radius-sm) !important;
  color: var(--checkout-text) !important;
  padding: 8px 12px !important;
  font-size: var(--checkout-font-md) !important;
  outline: none !important;
}

.select2-container--default
  .select2-search--dropdown
  .select2-search__field:focus {
  border-color: var(--checkout-input-focus-border) !important;
}

/* Select2 results */
.select2-container--default .select2-results__option {
  background-color: var(--checkout-dropdown-bg) !important;
  color: var(--checkout-dropdown-text) !important;
  padding: 10px 12px !important;
  font-size: var(--checkout-font-md) !important;
  cursor: pointer !important;
  transition: background-color 0.15s ease !important;
}

.select2-container--default .select2-results__option--highlighted,
.select2-container--default .select2-results__option:hover {
  background-color: var(--checkout-dropdown-hover) !important;
  color: var(--checkout-text) !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
  background-color: var(--checkout-dropdown-selected) !important;
  color: var(--checkout-text) !important;
}

/* Select2 results wrapper - prevent double scrollbar */
.select2-container--default .select2-results {
  overflow: hidden !important;
}

/* Select2 results container - single scrollbar only */
.select2-container--default .select2-results > .select2-results__options {
  max-height: 300px !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  background-color: var(--checkout-dropdown-bg) !important;
}

/* Select2 no results message */
.select2-container--default .select2-results__option--disabled {
  color: var(--checkout-text-muted) !important;
  background-color: var(--checkout-dropdown-bg) !important;
}

/* Mobile optimization for Select2 */
@media (max-width: 768px) {
  .select2-container--default .select2-dropdown {
    max-width: 100% !important;
    left: 0 !important;
    right: 0 !important;
  }

  .select2-container--default .select2-results > .select2-results__options {
    max-height: 250px !important;
  }
}

/* ==========================================================================
   Select2 dropdown – search box above a bordered option list
   ========================================================================== */

.select2-container--default .select2-dropdown {
  padding: 10px !important;
  margin-top: 6px !important;
}

.select2-container--default .select2-search--dropdown {
  padding: 0 0 10px !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field {
  box-sizing: border-box !important;
  width: 100% !important;
  height: 38px !important;
  padding: 0 12px !important;
  border-radius: 8px !important;
  font-size: 14px !important;
}

.select2-container--default
  .select2-search--dropdown
  .select2-search__field::placeholder {
  color: var(--checkout-text-muted);
  opacity: 1;
}

.select2-container--default .select2-results {
  border: 1px solid var(--checkout-input-border) !important;
  border-radius: 8px !important;
  overflow: hidden !important;
}

.select2-container--default .select2-results > .select2-results__options {
  max-height: 280px !important;
  padding: 4px 0 !important;
}

.select2-container--default .select2-results__option {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  min-height: 36px !important;
  padding: 6px 12px !important;
  font-size: 14px !important;
  background-color: transparent !important;
}

.select2-container--default .select2-results__option::before,
.select2-container--default .select2-results__option::after {
  display: none !important;
  content: none !important;
}

.select2-container--default .select2-results__option[aria-selected="true"] {
  font-weight: 600 !important;
}

.select2-container--default .select2-results__option--highlighted,
.select2-container--default .select2-results__option:hover {
  background-color: var(--checkout-dropdown-hover) !important;
}

.select2-container--default .select2-results__option--disabled {
  padding-left: 12px !important;
}

.select2-container--default .select2-results__option--disabled::before,
.select2-container--default .select2-results__option[role="alert"]::before {
  display: none;
}

/* No browser focus ring / glow on the Select2 dropdown */
.select2-container *:focus,
.select2-container *:focus-visible,
.select2-dropdown *:focus,
.select2-dropdown *:focus-visible,
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  outline: none !important;
  box-shadow: none !important;
  -webkit-tap-highlight-color: transparent;
}

/* Keyboard focus stays visible on the Select2 trigger */
.select2-container--default.select2-container--focus
  .select2-selection--single:focus-visible,
.select2-container--default .select2-selection--single:focus-visible {
  box-shadow: var(--focus-ring-inset) !important;
}

/* WooCommerce prints its own message under each invalid field; the theme
   already shows one above the field (.field-error). Keep WooCommerce's copy
   for screen readers (aria-describedby) but do not show it twice. */
.woocommerce-checkout .checkout-inline-error-message {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
