/* UPS Shipping Methods - Cart & Checkout Styles */
/* Targeting actual WooCommerce HTML structure - NO <p> tags, just input+label */

/* ── Commercial address: company field highlight ──────────────────────── */
.ups-commercial-required input[type="text"] {
  border-color: #B7791F !important;
  box-shadow: 0 0 0 2px rgba(183, 121, 31, 0.2) !important;
  background-color: #FFFFF5 !important;
}
.ups-commercial-required label::after {
  content: " *";
  color: #B7791F;
  font-weight: 700;
}

/* PlaceAutocompleteElement — match WooCommerce input styling */
gmp-place-autocomplete.ups-place-ac {
  display: block;
  width: 100%;
  --gmp-input-border-radius: 0;
  --gmp-input-border: 1px solid #ccc;
  --gmp-input-padding: 6px 10px;
  --gmp-input-font-size: 14px;
  --gmp-input-background-color: #fff;
  --gmp-input-color: #43454b;
  --gmp-input-placeholder-color: #888;
  --gmp-input-height: 38px;
}

/* Legacy fallback: pac-container z-index (if old Autocomplete ever used) */
.pac-container {
  z-index: 99999 !important;
}

/* ── PO/APO notice under Street Address field ──────────────────────── */
#billing_address_1_field  .woocommerce-input-wrapper::after,
#shipping_address_1_field .woocommerce-input-wrapper::after {
  content: "We don\2019t ship to PO / APO addresses";
  display: block;
  margin-top: 8px;
  padding: 7px 14px;
  border: 1.5px solid #DA291C;   /* Pantone 485 C */
  border-radius: 4px;
  background: #fff5f5;
  color: #DA291C;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

/* ── Address type badge in checkout order review table ─────────────── */
.ups-addr-type-row td {
  padding-top: 4px !important;
  padding-bottom: 8px !important;
  border: none !important;
}

.ups-addr-type {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}

.ups-addr-type--residential {
  background: #ebf8ff;
  color: #1a365d;
  border: 1px solid #90cdf4;
}

.ups-addr-type--commercial {
  background: #f7fafc;
  color: #4a5568;
  border: 1px solid #cbd5e0;
}

.ups-addr-type--unconfirmed {
  background: #fffff0;
  color: #744210;
  border: 1px solid #f6e05e;
}

/* Container for shipping methods */
body .woocommerce-shipping-totals #shipping_method,
body .woocommerce-shipping-totals span#shipping_method,
body tr.shipping td #shipping_method,
body tr.shipping td span#shipping_method,
body .woocommerce-checkout-review-order #shipping_method,
body.woocommerce-cart td #shipping_method,
body.woocommerce-cart td span#shipping_method,
body.woocommerce-checkout td #shipping_method,
body.woocommerce-checkout td span#shipping_method {
  display: flex ;
  flex-direction: column ;
  gap: 10px ;
  padding: 0 ;
  margin: 0 ;
  font-size: inherit ;
}

/* Wrapper for each shipping method (input + label pair) */
body #shipping_method input[type="radio"] + label {
  display: block ;
  padding: 14px 16px 14px 30px ;
  border: 2px solid #d6e4f0 ;
  border-radius: 10px ;
  margin-bottom: 10px ;
  cursor: pointer ;
  transition: all 0.2s ;
  background: #fff ;
  position: relative ;
  box-sizing: border-box ;
  visibility: visible ;
  opacity: 1 ;
  font-size: 14px ;
  font-weight: 600 ;
  color: #333 ;
}

body #shipping_method input[type="radio"] + label:hover {
  border-color: #a8c5e0 ;
  background: #f8fbfd ;
}

/* Selected shipping method - soft blue border */
body #shipping_method input[type="radio"]:checked + label {
  border-color: #4a90e2 ;
  background: #e8f2fc ;
  box-shadow: 0 0 0 1px #4a90e2 ;
}

/* Checkmark icon on selected method - LEFT SIDE */
body #shipping_method input[type="radio"]:checked + label::before {
  content: '✓' ;
  position: absolute ;
  top: 50% ;
  left: 12px ;
  transform: translateY(-50%) ;
  width: 24px ;
  height: 24px ;
  background: #4a90e2 ;
  color: #fff ;
  border-radius: 50% ;
  display: flex ;
  align-items: center ;
  justify-content: center ;
  font-size: 16px ;
  font-weight: bold ;
  line-height: 1 ;
}

/* Hide radio button visually but keep it functional */
body #shipping_method input[type="radio"] {
  position: absolute ;
  opacity: 0 ;
  pointer-events: none ;
  width: 0 ;
  height: 0 ;
}

/* Shipping cost */
body #shipping_method label .woocommerce-Price-amount {
  font-weight: 700 ;
  color: #333 ;
  margin-left: 8px ;
}

/* ETA display - now inline within label */
body .ups-eta-inline {
  display: block ;
  margin-top: 4px ;
}

body .ups-eta-inline small {
  font-size: 13px ;
  color: #666 ;
  font-weight: normal ;
}

body .ups-eta-inline strong {
  font-weight: 600 ;
  color: #333 ;
}

/* Legacy .ups-eta support (if still used somewhere) */
body .ups-eta {
  display: none ;
}

/* Place Order button spinner (checkout only) */
body .woocommerce-checkout button[type="submit"].loading,
body .woocommerce-checkout button[type="submit"].is-loading {
  color: transparent ;
  pointer-events: none ;
  position: relative ;
}

body .woocommerce-checkout button[type="submit"].loading::after,
body .woocommerce-checkout button[type="submit"].is-loading::after {
  content: '' ;
  position: absolute ;
  width: 16px ;
  height: 16px ;
  top: 50% ;
  left: 50% ;
  margin-left: 31px ;
  margin-top: -8px ;
  border: 2px solid #fff ;
  border-radius: 50% ;
  border-top-color: transparent ;
  animation: ups-spinner 0.6s linear infinite ;
}

@keyframes ups-spinner {
  to { transform: rotate(360deg); }
}

/* Cart totals section */
body .cart_totals .shipping {
  padding: 16px ;
  #background: #fff ;
  #border: 1px solid #ddd ;
  border-radius: 12px ;
  margin-bottom: 16px ;
}

/* Shipping calculator form */
body .shipping-calculator-form {
  padding: 16px ;
  background: #fff ;
  border: 1px solid #ddd ;
  border-radius: 12px ;
  margin-top: 16px ;
}

body .shipping-calculator-form .form-row {
  margin-bottom: 12px ;
}

body .shipping-calculator-form input[type="text"],
body .shipping-calculator-form select {
  height: 40px ;
  padding: 0 12px ;
  border-radius: 8px ;
  border: 1px solid #ddd ;
  font-size: 14px ;
  transition: border-color 0.2s ;
}

body .shipping-calculator-form input[type="text"]:focus,
body .shipping-calculator-form select:focus {
  outline: none ;
  border-color: #999 ;
}

body .shipping-calculator-form button {
  height: 40px ;
  padding: 0 20px ;
  border-radius: 8px ;
  border: 1px solid #333 ;
  background: #333 ;
  color: #fff ;
  font-weight: 600 ;
  font-size: 14px ;
  cursor: pointer ;
  transition: all 0.2s ;
}

body .shipping-calculator-form button:hover {
  background: #555 ;
  border-color: #555 ;
}

/* ── Checkout "Calculate Shipping" button ────────────────────────── */
.ups-checkout-calc-row td {
  padding: 0 0 12px !important;
  border: none !important;
}

.ups-checkout-calc-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ups-checkout-calc-btn {
  display: inline-block;
  height: 40px;
  padding: 0 20px;
  border-radius: 8px;
  border: 1px solid #333;
  background: #333;
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  align-self: flex-start;
}

.ups-checkout-calc-btn:hover {
  background: #555;
  border-color: #555;
}

.ups-checkout-calc-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.ups-checkout-calc-note {
  font-size: 13px;
  color: #888;
  margin: 0;
}

/* ── "Detecting best shipping cost…" banner ─────────────────────── */
#ups-detecting-banner,
#ups-detecting-banner-cart {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
  border: 2px solid #00A651;
  border-radius: 8px;
  background: #f0faf4;
  color: #1a5c35;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.ups-detecting-spinner {
  display: inline-block;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  border: 2px solid #00A651;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ups-spinner 0.7s linear infinite;
}

/* Responsive */
@media (max-width: 768px) {
  body .woocommerce-shipping-totals #shipping_method > p,
  body tr.shipping td #shipping_method > p {
    padding: 12px 14px ;
  }
  
  body .woocommerce-shipping-totals #shipping_method label,
  body tr.shipping td #shipping_method label {
    font-size: 13px ;
  }
}

/* ── SES/MetaMask notice (address autocomplete unavailable) ─────────────── */
.ups-ac-ses-notice {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    margin-top: 6px;
    padding: 8px 12px;
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 4px;
    font-size: 12px;
    color: #7a6000;
    line-height: 1.5;
}
.ups-ac-ses-notice svg { color: #f59e0b; margin-top: 1px; }
