/*
 * TP Event Management — WooCommerce Checkout Styles
 * Design tokens from src/styles/theme.css.
 * Covers WooCommerce Blocks checkout (primary) + classic checkout (fallback).
 *
 * Banner is injected via wp_body_open so it sits before all page-builder
 * containers and is naturally full viewport width.
 */

/* ── Design tokens ─────────────────────────────────────────────── */
:root {
  --em-bg:          #f8fafc;
  --em-fg:          #0f172a;
  --em-card:        #ffffff;
  --em-primary:     #1e3a5f;
  --em-primary-fg:  #ffffff;
  --em-accent:      #f97316;
  --em-accent-fg:   #ffffff;
  --em-border:      #e2e8f0;
  --em-muted:       #f1f5f9;
  --em-muted-fg:    #64748b;
  --em-radius:      0.625rem;
  --em-destructive: #dc2626;
}

/* ── Page base ─────────────────────────────────────────────────── */
body.woocommerce-checkout,
body.woocommerce-cart {
  background-color: var(--em-bg) !important;
  font-family: 'Inter', sans-serif;
  color: var(--em-fg);
}

/* ── Branded header banner ─────────────────────────────────────── */
/* Rendered by wp_body_open — sits before all page-builder wrappers */
.em-checkout-banner {
  width: 100%;
  background-color: var(--em-primary);
  color: var(--em-primary-fg) !important;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: baseline;
  gap: 1rem;
  /* Push page content down by the banner height via margin-bottom only */
}
.em-checkout-banner__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--em-primary-fg) !important;
  margin: 0;
  letter-spacing: -0.01em;
}
.em-checkout-banner__subtitle {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--em-primary-fg) !important;
  opacity: 0.65;
}

/* ═══════════════════════════════════════════════════════════════
   WooCommerce BLOCKS checkout
   ═══════════════════════════════════════════════════════════════ */

.wp-block-woocommerce-checkout {
  font-family: 'Inter', sans-serif !important;
}

/* Step cards */
.wc-block-components-checkout-step {
  background: var(--em-card);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  padding: 1.25rem 1.375rem;
  margin-bottom: 0.75rem;
}

/* Step title */
.wc-block-components-checkout-step__title {
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  color: var(--em-fg) !important;
  margin: 0 0 1rem !important;
  padding-bottom: 0.75rem !important;
  border-bottom: 1px solid var(--em-border) !important;
}

/* Step number */
.wc-block-components-checkout-step__index {
  background: var(--em-primary);
  color: var(--em-primary-fg) !important;
  width: 1.375rem;
  height: 1.375rem;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.5rem;
}

/* ── Text inputs ───────────────────────────────────────────────── */
.wc-block-components-text-input {
  margin-bottom: 0.75rem;
}
.wc-block-components-text-input label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--em-muted-fg);
  margin-bottom: 0.25rem;
}
.wc-block-components-text-input input,
.wc-block-components-text-input select {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem !important;
  background: var(--em-card) !important;
  border: 1px solid var(--em-border) !important;
  border-radius: var(--em-radius) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 0.9375rem !important;
  color: var(--em-fg) !important;
  outline: none !important;
  box-shadow: none !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.wc-block-components-text-input input:focus,
.wc-block-components-text-input select:focus {
  border-color: var(--em-primary) !important;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1) !important;
}
.wc-block-components-validation-error {
  color: var(--em-destructive);
  font-size: 0.8125rem;
  margin-top: 0.25rem;
}

/* ── Payment methods ───────────────────────────────────────────── */
.wc-block-components-payment-methods {
  background: var(--em-card);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  overflow: hidden;
}
.wc-block-components-payment-method {
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--em-border);
}
.wc-block-components-payment-method:last-child {
  border-bottom: none;
}
.wc-block-components-radio-control__input[type="radio"] {
  accent-color: var(--em-accent);
}
.wc-block-components-payment-method-label__primary {
  font-size: 0.9375rem !important;
  font-weight: 500 !important;
  color: var(--em-fg) !important;
}
.wc-block-components-payment-method__content {
  font-size: 0.8125rem;
  color: var(--em-muted-fg);
  padding: 0.5rem 0 0 1.625rem;
  line-height: 1.6;
}

/* ── Place Order button ────────────────────────────────────────── */
.wc-block-components-checkout-place-order {
  margin-top: 1rem;
}
.wc-block-components-checkout-place-order__button,
.wc-block-components-button.wc-block-components-checkout-place-order-button {
  width: 100% !important;
  background-color: var(--em-accent) !important;
  color: var(--em-accent-fg) !important;
  border: none !important;
  border-radius: var(--em-radius) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  height: 2.875rem !important;
  padding: 0 1.25rem !important;
  cursor: pointer !important;
  transition: background-color 0.15s !important;
  box-shadow: none !important;
  text-shadow: none !important;
  letter-spacing: -0.01em !important;
}
.wc-block-components-checkout-place-order__button:hover,
.wc-block-components-button.wc-block-components-checkout-place-order-button:hover {
  background-color: #ea6c05 !important;
}

/* Return to basket */
.wc-block-components-checkout-return-to-cart-button {
  color: var(--em-muted-fg) !important;
  font-size: 0.8125rem;
  background: none !important;
  border: none !important;
  padding: 0 !important;
  cursor: pointer;
}
.wc-block-components-checkout-return-to-cart-button:hover {
  color: var(--em-fg) !important;
}

/* Terms line */
.wc-block-checkout__terms {
  font-size: 0.8125rem;
  color: var(--em-muted-fg);
  text-align: center;
}
.wc-block-checkout__terms a {
  color: var(--em-primary);
}

/* ── Order summary sidebar ─────────────────────────────────────── */
/* Container */
.wc-block-order-summary,
.wc-block-components-order-summary {
  background: var(--em-card);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
  font-family: 'Inter', sans-serif !important;
}

/* "Order summary" toggle header */
.wc-block-order-summary__button-text,
.wc-block-components-order-summary__button-text {
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  color: var(--em-fg) !important;
  padding: 0.875rem 1rem;
  display: block;
}

/* Line items list */
.wc-block-order-summary__cart-items,
.wc-block-components-order-summary__cart-items {
  padding: 0 1rem;
  margin: 0;
  list-style: none;
}

/* Individual item row */
.wc-block-order-summary-item,
.wc-block-components-order-summary-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--em-border);
}
.wc-block-order-summary-item:last-child,
.wc-block-components-order-summary-item:last-child {
  border-bottom: none;
}

/* Thumbnail */
.wc-block-order-summary-item__image img,
.wc-block-components-order-summary-item__image img {
  width: 3rem;
  height: 3rem;
  object-fit: cover;
  border-radius: calc(var(--em-radius) - 0.125rem);
  border: 1px solid var(--em-border);
  display: block;
}

/* Quantity badge on thumbnail */
.wc-block-order-summary-item__quantity,
.wc-block-components-order-summary-item__quantity {
  background: var(--em-primary) !important;
  color: var(--em-primary-fg) !important;
  font-size: 0.6875rem !important;
  font-weight: 700 !important;
  min-width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--em-card) !important;
  top: -0.375rem !important;
  right: -0.375rem !important;
}

/* Item name — target heading tags AND the name class to cover all WC versions */
.wc-block-order-summary-item h2,
.wc-block-order-summary-item h3,
.wc-block-order-summary-item h4,
.wc-block-components-order-summary-item h2,
.wc-block-components-order-summary-item h3,
.wc-block-components-order-summary-item h4,
.wc-block-order-summary-item__name,
.wc-block-components-order-summary-item__name {
  font-size: 0.875rem !important;
  font-weight: 500 !important;
  line-height: 1.4 !important;
  margin: 0 !important;
  color: var(--em-fg) !important;
  padding: 0 !important;
  border: none !important;
}

/* Unit price */
.wc-block-order-summary-item__individual-prices,
.wc-block-components-order-summary-item__individual-prices,
.wc-block-order-summary-item__individual-price,
.wc-block-components-order-summary-item__individual-price {
  font-size: 0.75rem !important;
  color: var(--em-muted-fg) !important;
  margin-top: 0.125rem;
}

/* Line total (right-aligned) */
.wc-block-order-summary-item__full-price,
.wc-block-components-order-summary-item__full-price,
.wc-block-order-summary-item__amount,
.wc-block-components-order-summary-item__amount {
  font-size: 0.875rem !important;
  font-weight: 600 !important;
  color: var(--em-fg) !important;
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

/* ── Totals panel ──────────────────────────────────────────────── */
.wc-block-components-totals-wrapper {
  background: var(--em-card);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  overflow: hidden;
  margin-bottom: 0.75rem;
}
.wc-block-components-totals-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border-bottom: 1px solid var(--em-border);
  color: var(--em-fg);
}
.wc-block-components-totals-item:last-child {
  border-bottom: none;
  font-weight: 700;
  font-size: 1rem;
}
/* Subtotal/Total labels */
.wc-block-components-totals-item__label {
  font-size: 0.9375rem !important;
  color: var(--em-fg) !important;
}
/* Subtotal/Total values */
.wc-block-components-totals-item .wc-block-components-formatted-money-amount,
.wc-block-components-totals-item__value {
  font-weight: 600 !important;
  color: var(--em-fg) !important;
}

/* Coupon row */
.wc-block-components-totals-coupon {
  padding: 0.625rem 1rem;
  border-bottom: 1px solid var(--em-border);
}
.wc-block-components-totals-coupon__toggle {
  font-size: 0.875rem !important;
  color: var(--em-muted-fg) !important;
  background: none !important;
  border: none !important;
  cursor: pointer;
  padding: 0 !important;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}
.wc-block-components-totals-coupon__toggle svg {
  width: 0.875rem;
  height: 0.875rem;
}
.wc-block-components-totals-coupon__form {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.wc-block-components-totals-coupon__form input[type="text"] {
  flex: 1;
  height: 2.375rem;
  padding: 0 0.75rem;
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
}
.wc-block-components-totals-coupon__button {
  background: var(--em-primary) !important;
  color: var(--em-primary-fg) !important;
  border: none !important;
  border-radius: var(--em-radius) !important;
  font-weight: 500 !important;
  font-size: 0.875rem !important;
  padding: 0 0.875rem !important;
  height: 2.375rem !important;
  cursor: pointer !important;
}

/* Notices */
.wc-block-components-notice-banner,
.wc-block-components-notice-banner.is-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--em-radius);
  color: var(--em-destructive);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
}
.wc-block-components-notice-banner.is-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}
.wc-block-components-notice-banner.is-info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--em-primary);
}

/* ═══════════════════════════════════════════════════════════════
   Classic WooCommerce checkout (fallback)
   ═══════════════════════════════════════════════════════════════ */

.woocommerce-checkout .col2-set {
  width: 100%;
  float: none;
}
.woocommerce-checkout h3 {
  font-size: 0.9375rem !important;
  font-weight: 600 !important;
  color: var(--em-fg) !important;
  margin: 0 0 1rem !important;
  padding-bottom: 0.75rem !important;
  border-bottom: 1px solid var(--em-border) !important;
}
.woocommerce-checkout .form-row label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--em-muted-fg);
}
.woocommerce-checkout .form-row .input-text,
.woocommerce-checkout .form-row select {
  height: 2.5rem;
  padding: 0 0.75rem;
  background: var(--em-card) !important;
  border: 1px solid var(--em-border) !important;
  border-radius: var(--em-radius) !important;
  font-family: 'Inter', sans-serif;
  font-size: 0.9375rem;
  color: var(--em-fg);
  box-shadow: none !important;
}
.woocommerce-checkout .form-row .input-text:focus {
  border-color: var(--em-primary) !important;
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1) !important;
}
.woocommerce-checkout-review-order-table th,
.woocommerce-checkout-review-order-table td {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--em-border);
  font-size: 0.9375rem;
}
.woocommerce-checkout-review-order-table tfoot .order-total th,
.woocommerce-checkout-review-order-table tfoot .order-total td {
  font-weight: 700;
  font-size: 1rem;
  color: var(--em-fg);
  border-top: 2px solid var(--em-border);
}
#payment {
  background: var(--em-card);
  border: 1px solid var(--em-border);
  border-radius: var(--em-radius);
  overflow: hidden;
}
#payment ul.payment_methods { padding: 0; margin: 0; list-style: none; }
#payment ul.payment_methods li {
  padding: 0.875rem 1.125rem;
  border-bottom: 1px solid var(--em-border);
  font-size: 0.9375rem;
}
#payment ul.payment_methods li:last-child { border-bottom: none; }
#payment input[type="radio"] { accent-color: var(--em-accent); margin-right: 0.5rem; }
#payment .payment_box {
  background: var(--em-muted);
  border-radius: calc(var(--em-radius) - 0.125rem);
  padding: 0.625rem 0.875rem;
  font-size: 0.8125rem;
  color: var(--em-muted-fg);
  margin-top: 0.375rem;
}
#payment .place-order { padding: 1.125rem; }
#place_order {
  width: 100%;
  background-color: var(--em-accent) !important;
  color: var(--em-accent-fg) !important;
  border: none !important;
  border-radius: var(--em-radius) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 1rem !important;
  font-weight: 600 !important;
  height: 2.875rem !important;
  cursor: pointer;
  transition: background-color 0.15s;
  text-shadow: none !important;
  box-shadow: none !important;
}
#place_order:hover { background-color: #ea6c05 !important; }

.woocommerce-error, .woocommerce-message, .woocommerce-info {
  border-radius: var(--em-radius);
  font-size: 0.875rem;
  margin-bottom: 0.875rem;
  list-style: none;
  padding: 0.875rem 1rem;
}
.woocommerce-error { background: #fef2f2; border: 1px solid #fecaca; color: var(--em-destructive); }
.woocommerce-message { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; }
.woocommerce-info { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--em-primary); }

/* ── Classic checkout — EM item thumbnails ─────────────────────── */
/* Injected via woocommerce_checkout_cart_item_quantity filter */
.em-checkout-item-img {
  width: 2.75rem;
  height: 2.75rem;
  object-fit: cover;
  border-radius: calc(var(--em-radius) - 0.125rem);
  border: 1px solid var(--em-border);
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.625rem;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .em-checkout-banner { padding: 0.75rem 1rem; }
  .wc-block-components-checkout-step { padding: 1rem; }
}
