/**
 * Product Landing Page - Checkout Styles
 *
 * Purpose: Customize WooCommerce checkout for product landing pages
 * - Hide unnecessary sections (coupon, create account, Meta OTP)
 * - Streamline checkout appearance for conversion optimization
 * - Guest checkout focused design
 *
 * Note: Uses traditional checkout (shortcode), not blocks
 * Block checkout only works on actual WooCommerce checkout page
 *
 * Architecture: Uses natural specificity with body.landing-page prefix
 * to avoid !important declarations
 *
 * @package eRide
 * @since 1.2.0
 */

/* ===== ADMIN BAR OVERRIDE ===== */
/* Hide WordPress admin bar on landing pages for cleaner look */
body.page-template-page-product-landing #wpadminbar {
  display: none;
}

body.page-template-page-product-landing html {
  margin-top: 0;
}

/* ===== HIDE UNNECESSARY SECTIONS ===== */
/* Hide coupon code section for streamlined checkout */
body.page-template-page-product-landing .woocommerce-form-coupon-toggle,
body.page-template-page-product-landing .checkout_coupon {
  display: none;
}

/* Hide "Create an account?" checkbox for guest-only checkout */
body.page-template-page-product-landing .woocommerce-account-fields,
body.page-template-page-product-landing .create-account {
  display: none;
}

/* Hide login/register prompts */
body.page-template-page-product-landing .woocommerce-info,
body.page-template-page-product-landing .showlogin {
  display: none;
}

/* ===== STREAMLINE CHECKOUT LAYOUT ===== */
/* Prevent container padding from affecting checkout wrapper */
body.page-template-page-product-landing .section-checkout .container {
  padding-left: 0;
  padding-right: 0;
}

/* Keep checkout wrapper padding as designed */
body.page-template-page-product-landing .checkout-wrapper {
  padding: var(--spacing-xl) 1rem;
}

/* ===== CHECKOUT FORM FIELDS STYLING ===== */
/* Consistent height and padding for all input fields */
body.page-template-page-product-landing .woocommerce-billing-fields input[type="text"],
body.page-template-page-product-landing .woocommerce-billing-fields input[type="email"],
body.page-template-page-product-landing .woocommerce-billing-fields input[type="tel"],
body.page-template-page-product-landing .woocommerce-billing-fields select,
body.page-template-page-product-landing .woocommerce-billing-fields textarea,
body.page-template-page-product-landing .woocommerce-shipping-fields input[type="text"],
body.page-template-page-product-landing .woocommerce-shipping-fields select {
  padding: 14px 16px;
  min-height: 48px;
  border-radius: var(--radius-md);
  border: 1px solid hsl(var(--color-border));
  font-size: 14px;
}

/* Form field spacing */
body.page-template-page-product-landing .form-row {
  margin-bottom: 16px;
}

/* Input focus state */
body.page-template-page-product-landing .woocommerce-billing-fields input:focus,
body.page-template-page-product-landing .woocommerce-billing-fields select:focus,
body.page-template-page-product-landing .woocommerce-billing-fields textarea:focus,
body.page-template-page-product-landing .woocommerce-shipping-fields input:focus,
body.page-template-page-product-landing .woocommerce-shipping-fields select:focus {
  outline: none;
  border-color: hsl(var(--color-primary));
  box-shadow: 0 0 0 3px hsl(var(--color-primary) / 0.1);
}

/* ===== PLACE ORDER BUTTON ===== */
body.page-template-page-product-landing #place_order {
  width: 100%;
  padding: 16px 32px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-full);
  background: hsl(var(--color-primary));
  color: white;
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
}

body.page-template-page-product-landing #place_order:hover {
  background: hsl(var(--color-primary-dark));
  transform: translateY(-2px);
  box-shadow: 0 4px 12px hsl(var(--color-primary) / 0.3);
}

body.page-template-page-product-landing #place_order:active {
  transform: translateY(0);
}

/* Loading state for place order button */
body.page-template-page-product-landing #place_order:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* ===== PAYMENT METHOD STYLING ===== */
body.page-template-page-product-landing .woocommerce-checkout #payment {
  background-color: hsl(var(--color-background-muted));
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}

body.page-template-page-product-landing .woocommerce-checkout #payment ul.payment_methods {
  border: none;
  padding: 0;
}

body.page-template-page-product-landing .woocommerce-checkout #payment .payment_box {
  background-color: hsl(var(--color-card));
  border-radius: var(--radius-md);
  padding: var(--spacing-md);
  margin-top: var(--spacing-sm);
}

/* ===== ORDER REVIEW SECTION ===== */
body.page-template-page-product-landing .woocommerce-checkout-review-order {
  background-color: hsl(var(--color-background-muted));
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
}

body.page-template-page-product-landing .woocommerce-checkout-review-order-table {
  width: 100%;
  border-collapse: collapse;
}

body.page-template-page-product-landing .woocommerce-checkout-review-order-table th,
body.page-template-page-product-landing .woocommerce-checkout-review-order-table td {
  padding: var(--spacing-sm);
  border-bottom: 1px solid hsl(var(--color-border));
}

body.page-template-page-product-landing .woocommerce-checkout-review-order-table tfoot th,
body.page-template-page-product-landing .woocommerce-checkout-review-order-table tfoot td {
  border-top: 2px solid hsl(var(--color-foreground-muted));
  font-weight: 600;
}

/* ===== MOBILE RESPONSIVENESS ===== */
@media (max-width: 768px) {
  body.page-template-page-product-landing .checkout-wrapper {
    padding: var(--spacing-md);
  }

  /* Prevent iOS zoom on input focus */
  body.page-template-page-product-landing input,
  body.page-template-page-product-landing select,
  body.page-template-page-product-landing textarea {
    font-size: 16px;
  }

  body.page-template-page-product-landing #place_order {
    padding: 14px 24px;
  }
}

/* ===== VALIDATION & ERROR STATES ===== */
body.page-template-page-product-landing .woocommerce-invalid input,
body.page-template-page-product-landing .woocommerce-invalid select,
body.page-template-page-product-landing .woocommerce-invalid textarea {
  border-color: hsl(var(--color-error));
}

body.page-template-page-product-landing .woocommerce-error,
body.page-template-page-product-landing .woocommerce-message {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

body.page-template-page-product-landing .woocommerce-error {
  background-color: hsl(var(--color-error) / 0.1);
  border-left: 4px solid hsl(var(--color-error));
  color: hsl(var(--color-error));
}

body.page-template-page-product-landing .woocommerce-message {
  background-color: hsl(var(--color-success) / 0.1);
  border-left: 4px solid hsl(var(--color-success));
  color: hsl(var(--color-success));
}

/* ===== LABEL STYLING ===== */
body.page-template-page-product-landing .woocommerce-billing-fields label,
body.page-template-page-product-landing .woocommerce-shipping-fields label {
  font-weight: 600;
  font-size: var(--font-size-sm);
  color: hsl(var(--color-foreground));
  margin-bottom: var(--spacing-xs);
  display: block;
}

body.page-template-page-product-landing .woocommerce-billing-fields .required,
body.page-template-page-product-landing .woocommerce-shipping-fields .required {
  color: hsl(var(--color-error));
  text-decoration: none;
}

/* ===== CRITICAL !important OVERRIDES (Only 5) ===== */
/* These are necessary to override WooCommerce inline styles and plugin conflicts */

/* 1. Force hide coupon toggle (WooCommerce inline style override) */
body.page-template-page-product-landing .woocommerce-form-coupon-toggle {
  display: none !important;
}

/* 2. Force hide account fields (theme conflict override) */
body.page-template-page-product-landing .woocommerce-account-fields {
  display: none !important;
}

/* 3. Force place order button width (WooCommerce default override) */
body.page-template-page-product-landing #place_order {
  width: 100% !important;
}

/* 4. Force admin bar hide (WordPress core override) */
body.page-template-page-product-landing #wpadminbar {
  display: none !important;
}

/* 5. Force html margin top reset (WordPress core admin bar override) */
body.page-template-page-product-landing html {
  margin-top: 0 !important;
}

/* ===== WOOCOMMERCE BLOCKS CHECKOUT STYLING ===== */
/* Fixes for block-based checkout (wp-block-woocommerce-*) */

/* HIDE DUPLICATE ORDER SUMMARY (WooCommerce renders block twice) */
/* Keep the first block, hide the fill-wrapper duplicate */
.landing-page .wc-block-checkout__sidebar,
.landing-page .wc-block-sidebar,
body.page-template-page-product-landing .wc-block-checkout__sidebar,
.landing-page .checkout-order-summary-block-fill-wrapper,
body.page-template-page-product-landing .checkout-order-summary-block-fill-wrapper {
  display: none !important;
}

/* MAIN FIX: Force single-column stacked layout (not side-by-side) */
.landing-page .wp-block-woocommerce-checkout,
.landing-page .wc-block-checkout {
  display: flex !important;
  flex-direction: column !important;
  gap: var(--spacing-xl, 32px);
}

/* Override WooCommerce's 2-column grid */
.landing-page .wc-block-checkout__main,
.landing-page .wp-block-woocommerce-checkout-fields-block {
  width: 100% !important;
  max-width: 100% !important;
  flex: none !important;
}

/* Show only the explicit order summary block (sidebar is hidden above) */
.landing-page .wp-block-woocommerce-checkout-order-summary-block {
  width: 100% !important;
  max-width: 100% !important;
  flex: none !important;
  order: -1; /* Order summary on TOP */
}

/* Remove any grid layouts forcing side-by-side */
.landing-page .wc-block-checkout__form,
.landing-page .wp-block-woocommerce-checkout-fields-block {
  display: block !important;
}

/* Order Summary Container */
.landing-page .wp-block-woocommerce-checkout-order-summary-block {
  background-color: hsl(var(--color-background-muted, 0 0% 97%));
  border-radius: var(--radius-lg, 12px);
  padding: var(--spacing-lg, 24px);
  margin-bottom: var(--spacing-lg, 24px);
}

/* Order Summary Title Row */
.landing-page .wc-block-components-checkout-order-summary__title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: var(--spacing-md, 16px);
  border-bottom: 1px solid hsl(var(--color-border, 0 0% 90%));
  margin-bottom: var(--spacing-md, 16px);
}

.landing-page .wc-block-components-checkout-order-summary__title-text {
  font-size: var(--font-size-xl, 1.25rem);
  font-weight: 600;
  margin: 0;
}

/* Order Summary Item - FIX BUNCHED COLUMNS */
.landing-page .wc-block-components-order-summary-item {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: var(--spacing-md, 16px);
  align-items: start;
  padding: var(--spacing-md, 16px) 0;
  border-bottom: 1px solid hsl(var(--color-border, 0 0% 90%));
}

.landing-page .wc-block-components-order-summary-item:last-child {
  border-bottom: none;
}

/* Product Image Column */
.landing-page .wc-block-components-order-summary-item__image {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.landing-page .wc-block-components-order-summary-item__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md, 8px);
  border: 1px solid hsl(var(--color-border, 0 0% 90%));
}

/* Quantity Badge */
.landing-page .wc-block-components-order-summary-item__quantity {
  position: absolute;
  top: -8px;
  right: -8px;
  background-color: hsl(var(--color-primary, 0 0% 20%));
  color: white;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
}

/* Product Description Column */
.landing-page .wc-block-components-order-summary-item__description {
  flex: 1;
  min-width: 0;
}

.landing-page .wc-block-components-order-summary-item__description .wc-block-components-product-name {
  font-size: var(--font-size-base, 1rem);
  font-weight: 600;
  margin: 0 0 var(--spacing-xs, 4px) 0;
  color: hsl(var(--color-foreground, 0 0% 10%));
}

.landing-page .wc-block-components-order-summary-item__individual-prices {
  font-size: var(--font-size-sm, 0.875rem);
  color: hsl(var(--color-foreground-muted, 0 0% 40%));
}

/* Product Metadata */
.landing-page .wc-block-components-product-metadata {
  font-size: var(--font-size-sm, 0.875rem);
  color: hsl(var(--color-foreground-muted, 0 0% 40%));
  margin-top: var(--spacing-xs, 4px);
}

/* Price Column */
.landing-page .wc-block-components-order-summary-item__total-price {
  font-size: var(--font-size-base, 1rem);
  font-weight: 600;
  color: hsl(var(--color-foreground, 0 0% 10%));
  text-align: right;
  white-space: nowrap;
}

/* Totals Wrapper Items */
.landing-page .wc-block-components-totals-wrapper {
  padding: var(--spacing-sm, 8px) 0;
}

.landing-page .wc-block-components-totals-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-xs, 4px) 0;
}

.landing-page .wc-block-components-totals-item__label {
  font-size: var(--font-size-base, 1rem);
  color: hsl(var(--color-foreground-muted, 0 0% 40%));
}

.landing-page .wc-block-components-totals-item__value {
  font-size: var(--font-size-base, 1rem);
  font-weight: 500;
  color: hsl(var(--color-foreground, 0 0% 10%));
}

/* Footer Total (Grand Total) */
.landing-page .wc-block-components-totals-footer-item {
  padding-top: var(--spacing-md, 16px);
  margin-top: var(--spacing-sm, 8px);
  border-top: 2px solid hsl(var(--color-foreground, 0 0% 10%));
}

.landing-page .wc-block-components-totals-footer-item .wc-block-components-totals-item__label {
  font-size: var(--font-size-lg, 1.125rem);
  font-weight: 600;
  color: hsl(var(--color-foreground, 0 0% 10%));
}

.landing-page .wc-block-components-totals-footer-item .wc-block-components-totals-item__value {
  font-size: var(--font-size-xl, 1.25rem);
  font-weight: 700;
  color: hsl(var(--color-primary, 0 0% 20%));
}

/* Coupon Panel */
.landing-page .wc-block-components-totals-coupon {
  background: none;
  border: none;
}

.landing-page .wc-block-components-panel__button {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs, 4px);
  font-size: var(--font-size-sm, 0.875rem);
  color: hsl(var(--color-primary, 0 0% 20%));
  cursor: pointer;
  padding: var(--spacing-xs, 4px) 0;
}

.landing-page .wc-block-components-panel__button:hover {
  color: hsl(var(--color-primary-dark, 0 0% 15%));
}

/* Shipping Display */
.landing-page .wc-block-components-totals-shipping .wc-block-components-totals-item__value strong {
  color: hsl(var(--color-success, 120 50% 40%));
}

/* Mobile Responsive for Order Summary */
@media (max-width: 480px) {
  .landing-page .wc-block-components-order-summary-item {
    grid-template-columns: 48px 1fr;
    grid-template-rows: auto auto;
  }

  .landing-page .wc-block-components-order-summary-item__image {
    width: 48px;
    height: 48px;
    grid-row: span 2;
  }

  .landing-page .wc-block-components-order-summary-item__total-price {
    grid-column: 2;
    text-align: left;
    margin-top: var(--spacing-xs, 4px);
  }
}
