/* ==========================================================================
   RAKESH MASALA — SHOPIFY-STYLE CHECKOUT
   Targets: WooCommerce generated markup + custom rk-* template classes
   ========================================================================== */

/* ── TOKENS ─────────────────────────────────────────────────────────────── */
:root {
  --brand: #AD2517;
  --brand-dark: #8c1c10;
  --brand-tint: #fbf3f2;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --muted: #8a8a8a;
  --line: #d9d9d9;
  --line-soft: #e8e8e8;
  --panel: #f7f7f7;
  --danger: #d72c0d;
  --radius: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── BASE ───────────────────────────────────────────────────────────────── */
.woocommerce-checkout {
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ── PAGE GRID ──────────────────────────────────────────────────────────── */
.rk-checkout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 100vh;
  align-items: start;
}

/* LEFT — forms */
.rk-checkout-left {
  display: flex;
  justify-content: flex-end;
  padding: 44px 44px 70px 24px;
  background: #fff;
}

/* Constrain all children to 470px, right-aligned (Shopify style) */
.rk-checkout-left > * {
  width: 100%;
  max-width: 470px;
}

/* RIGHT — order summary */
.rk-checkout-right {
  background: var(--panel);
  border-left: 1px solid var(--line-soft);
  padding: 44px 44px 70px 44px;
  min-height: 100vh;
}

.woocommerce-checkout-review-order {
  position: sticky;
  top: 44px;
  max-width: 420px;
}

/* ── SECTION HEADINGS ───────────────────────────────────────────────────── */
.rk-checkout-left h3,
.rk-shipping-methods-wrapper h3,
.rk-payment-wrapper h3,
.woocommerce-billing-fields h3,
.woocommerce-shipping-fields h3 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.3px;
  margin: 28px 0 14px;
  line-height: 1.2;
  color: var(--ink);
}

.woocommerce-billing-fields > h3:first-child {
  margin-top: 0;
}

.rk-payment-wrapper .rk-payment-subtitle {
  font-size: 12px;
  color: var(--muted);
  margin: -8px 0 14px;
}

#order_review_heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 20px;
}

/* ── FORM FIELDS — Floating Label ───────────────────────────────────────── */
/* WooCommerce renders:
   <p class="form-row"> <label> <span.woocommerce-input-wrapper> <input> </span> </p>
   JS in functions.php adds .has-val and .focused on the <p> element            */

.woocommerce-checkout .form-row {
  position: relative;
  margin-bottom: 12px;
  padding: 0;
  float: none !important;
  clear: none;
}

.woocommerce-checkout .form-row .woocommerce-input-wrapper {
  display: block;
  position: relative;
}

/* Inputs */
.woocommerce-checkout .form-row input.input-text,
.woocommerce-checkout .form-row select,
.woocommerce-checkout .form-row textarea {
  width: 100%;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 20px 13px 6px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
  box-shadow: none;
  outline: none;
  display: block;
}

.woocommerce-checkout .form-row textarea {
  height: 100px;
  resize: vertical;
}

.woocommerce-checkout .form-row select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  cursor: pointer;
}

/* Focus */
.woocommerce-checkout .form-row input.input-text:focus,
.woocommerce-checkout .form-row select:focus,
.woocommerce-checkout .form-row textarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
  outline: none;
}

/* ── FLOATING LABEL ─────────────────────────────────────────────────────── */
.woocommerce-checkout .form-row:not(.form-row-checkbox):not(.create-account) > label:not(.checkbox):not(.woocommerce-form__label-for-checkbox) {
  position: absolute;
  left: 13px;
  top: 7px;
  font-size: 11px;
  line-height: 1;
  color: var(--muted);
  pointer-events: none;
  transition: top .14s ease, font-size .14s ease, color .14s ease;
  margin: 0;
  font-weight: 400;
  z-index: 2;
  white-space: nowrap;
}

/* Hide required asterisk */
.woocommerce-checkout .form-row > label .required {
  opacity: 0;
  font-size: 0;
  width: 0;
  display: inline-block;
}

/* Empty + unfocused → label drops to centre (acts as placeholder) */
.woocommerce-checkout .form-row:not(.has-val):not(.focused):not(.form-row-checkbox):not(.create-account) > label:not(.checkbox):not(.woocommerce-form__label-for-checkbox) {
  top: 17px;
  font-size: 14px;
  color: #737373;
}

/* Hide native input placeholder when empty & unfocused so it doesn't collide with the dropped label */
.woocommerce-checkout .form-row:not(.has-val):not(.focused) input::placeholder,
.woocommerce-checkout .form-row:not(.has-val):not(.focused) textarea::placeholder {
  color: transparent !important;
}

/* When focused and empty, allow placeholder to be visible */
.woocommerce-checkout .form-row.focused input::placeholder,
.woocommerce-checkout .form-row.focused textarea::placeholder {
  color: #a0a0a0 !important;
}

/* Selects always keep label at top */
.woocommerce-checkout .form-row:has(select) > label {
  top: 7px !important;
  font-size: 11px !important;
  color: var(--muted) !important;
}

/* Error state */
.woocommerce-checkout .woocommerce-invalid input.input-text,
.woocommerce-checkout .woocommerce-invalid select,
.woocommerce-checkout .woocommerce-invalid textarea {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 1px var(--danger) !important;
}

/* ── MULTI-COLUMN FIELD ROWS ────────────────────────────────────────────── */
.woocommerce-billing-fields__field-wrapper,
.woocommerce-shipping-fields__field-wrapper {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.woocommerce-billing-fields__field-wrapper .form-row,
.woocommerce-shipping-fields__field-wrapper .form-row {
  margin-bottom: 0;
  float: none !important;
  clear: none !important;
  width: auto !important;
}

/* Full-width */
.woocommerce-billing-fields__field-wrapper .form-row-wide,
.woocommerce-shipping-fields__field-wrapper .form-row-wide {
  flex: 0 0 100%;
}

/* Half-width (first name + last name) */
.woocommerce-billing-fields__field-wrapper .form-row-first,
.woocommerce-billing-fields__field-wrapper .form-row-last,
.woocommerce-shipping-fields__field-wrapper .form-row-first,
.woocommerce-shipping-fields__field-wrapper .form-row-last {
  flex: 1 1 calc(50% - 6px);
  min-width: 0;
}

/* Three-column: city / state / postcode */
#billing_city_field,
#billing_state_field,
#billing_postcode_field,
#shipping_city_field,
#shipping_state_field,
#shipping_postcode_field {
  flex: 1 1 calc(33.33% - 8px) !important;
  min-width: 80px;
}

/* Question mark icon for Email and Phone */
.woocommerce-checkout #billing_email,
.woocommerce-checkout #billing_phone {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 18px auto !important;
  padding-right: 42px !important;
}

/* Custom Dropdown Caret for Select */
.woocommerce-checkout .form-row select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='7' viewBox='0 0 11 7' fill='none'%3E%3Cpath d='M1 1.2L5.5 5.5L10 1.2' stroke='%236A6A6A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 14px center !important;
  background-size: 11px auto !important;
  padding-top: 18px !important;
  padding-bottom: 6px !important;
  padding-left: 13px !important;
  padding-right: 36px !important;
}

/* ── CHECKBOXES ─────────────────────────────────────────────────────────── */
.rk-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--ink);
  cursor: pointer;
  margin: 10px 0 18px;
  user-select: none;
  font-weight: 400;
  width: 100%;
}

.rk-checkbox-row input[type="checkbox"] {
  width: 18px !important;
  height: 18px !important;
  accent-color: #222;
  margin: 0 !important;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.rk-save-info-row {
  margin-top: 12px;
  margin-bottom: 24px;
}

#ship-to-different-address {
  display: none !important;
}

.woocommerce-checkout .woocommerce-form__label-for-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  margin: 8px 0;
  user-select: none;
  position: static;
  font-weight: 400;
}

.woocommerce-checkout .woocommerce-form__input-checkbox {
  width: 17px !important;
  height: 17px !important;
  accent-color: var(--brand);
  margin: 0 !important;
  flex-shrink: 0;
  cursor: pointer;
}

/* ── SHIPPING METHOD OPTIONS ────────────────────────────────────────────── */
.rk-shipping-methods-wrapper {
  margin-bottom: 30px;
}

#shipping_method {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

#shipping_method li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 15px;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  position: relative;
  transition: background .15s;
  margin: 0;
}

#shipping_method li:last-child { border-bottom: none; }
#shipping_method li:hover { background: #fafafa; }

#shipping_method input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

/* Reset WooCommerce label positioning for shipping method labels */
#shipping_method label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0;
  position: static !important;
  top: auto !important;
  left: auto !important;
  pointer-events: auto;
  transition: none;
  z-index: auto;
  white-space: normal;
}

#shipping_method li:has(input:checked) {
  background: var(--brand-tint);
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

/* ── PAYMENT METHOD OPTIONS ─────────────────────────────────────────────── */
.rk-payment-wrapper {
  margin-bottom: 30px;
}

.wc_payment_methods {
  list-style: none;
  padding: 0;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.wc_payment_methods li {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 15px;
  background: #fff;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  position: relative;
  transition: background .15s;
  margin: 0;
  flex-wrap: wrap;
}

.wc_payment_methods li:last-child { border-bottom: none; }
.wc_payment_methods li:hover { background: #fafafa; }

.wc_payment_methods input[type="radio"] {
  width: 17px;
  height: 17px;
  accent-color: var(--brand);
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}

/* Reset WooCommerce label positioning for payment labels */
.wc_payment_methods label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  margin: 0;
  position: static !important;
  top: auto !important;
  left: auto !important;
  pointer-events: auto;
  transition: none;
  z-index: auto;
}

.wc_payment_methods label img {
  display: inline-block;
  max-height: 22px;
  width: auto;
  margin-left: 8px;
  vertical-align: middle;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,.08);
}

.wc_payment_methods li:has(input:checked) {
  background: var(--brand-tint);
  outline: 2px solid var(--brand);
  outline-offset: -2px;
}

.payment_box {
  width: 100%;
  background: #f4f4f4;
  border-radius: var(--radius);
  padding: 13px 15px;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 10px;
  border: none !important;
  box-shadow: none !important;
}
.payment_box::before { display: none !important; }

/* ── PAY NOW BUTTON ─────────────────────────────────────────────────────── */
#place_order {
  display: block;
  width: 100%;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 17px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  margin-top: 26px;
  transition: background .2s;
  letter-spacing: .2px;
}

#place_order:hover { background: var(--brand-dark); }
#place_order:disabled { background: #c9c9c9; cursor: not-allowed; }

/* ── ORDER SUMMARY — RIGHT PANEL ────────────────────────────────────────── */
.woocommerce-checkout-review-order-table {
  width: 100%;
  border: none;
  border-collapse: collapse;
  margin: 0 0 8px;
}

.woocommerce-checkout-review-order-table th,
.woocommerce-checkout-review-order-table td {
  border: none;
  padding: 0;
  background: transparent;
  vertical-align: middle;
}

.woocommerce-checkout-review-order-table thead { display: none; }

.woocommerce-checkout-review-order-table .cart_item td.product-name {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  padding-bottom: 18px;
  color: var(--ink);
}

.woocommerce-checkout-review-order-table .cart_item td.product-total {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  padding-bottom: 18px;
  white-space: nowrap;
  vertical-align: middle;
}

/* Product image + qty badge */
.rk-checkout-img-wrap {
  position: relative;
  display: inline-flex;
  vertical-align: middle;
  margin-right: 10px;
  flex-shrink: 0;
}

.rk-checkout-img-wrap img {
  width: 47px;
  height: 47px;
  object-fit: cover;
  border: 1px solid #e0e0e0;
  border-radius: var(--radius);
  background: #fff;
  display: block;
}

.rk-checkout-qty {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: #4a4a4a;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
  border-radius: 50%;
  z-index: 1;
}

/* ── TOTALS TABLE ───────────────────────────────────────────────────────── */
.woocommerce-checkout-review-order-table tfoot tr { border: none; }

.woocommerce-checkout-review-order-table tfoot .cart-subtotal th,
.woocommerce-checkout-review-order-table tfoot .cart-subtotal td {
  border-top: 1px solid #e0e0e0;
  padding-top: 14px;
}

.woocommerce-checkout-review-order-table tfoot th,
.woocommerce-checkout-review-order-table tfoot td {
  padding: 5px 0;
  font-size: 13px;
  border: none;
}

.woocommerce-checkout-review-order-table tfoot th {
  color: var(--ink-soft);
  font-weight: 400;
  text-align: left;
}

.woocommerce-checkout-review-order-table tfoot td {
  font-weight: 500;
  color: var(--ink);
  text-align: right;
}

.woocommerce-checkout-review-order-table tfoot .cart-discount th,
.woocommerce-checkout-review-order-table tfoot .cart-discount td {
  color: #1e8449;
}

.woocommerce-checkout-review-order-table tfoot .order-total th {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.woocommerce-checkout-review-order-table tfoot .order-total td {
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
  text-align: right;
}

.woocommerce-checkout-review-order-table tfoot .order-total .amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

/* ── COUPON FORM ────────────────────────────────────────────────────────── */
.woocommerce-form-coupon-toggle { display: none !important; }

form.checkout_coupon {
  display: flex;
  gap: 8px;
  margin: 18px 0;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
}

form.checkout_coupon .form-row-first {
  flex: 1 !important;
  float: none !important;
  width: auto !important;
  margin: 0;
  padding: 0;
  min-width: 0;
}

form.checkout_coupon .form-row-last {
  float: none !important;
  width: auto !important;
  margin: 0;
  padding: 0;
}

form.checkout_coupon input.input-text {
  width: 100%;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 13px !important;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  box-shadow: none;
}

form.checkout_coupon input.input-text:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
  outline: none;
}

form.checkout_coupon .button {
  height: 46px;
  padding: 0 22px;
  background: #e8e8e8;
  color: #6a6a6a;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}

form.checkout_coupon .button:hover {
  background: #dcdcdc;
  color: var(--ink);
}

/* ── NOTICES ────────────────────────────────────────────────────────────── */
.woocommerce-NoticeGroup { margin-bottom: 18px; }

/* ── MOBILE ─────────────────────────────────────────────────────────────── */
@media (max-width: 899px) {
  .rk-checkout-grid { grid-template-columns: 1fr; }

  .rk-checkout-right {
    order: -1;
    border-left: none;
    border-bottom: 1px solid var(--line-soft);
    min-height: 0;
    padding: 24px 20px;
  }

  .woocommerce-checkout-review-order { position: static; max-width: none; }

  .rk-checkout-left {
    padding: 28px 20px 60px;
    justify-content: center;
  }

  .rk-checkout-left > * { max-width: none; }

  .woocommerce-billing-fields__field-wrapper .form-row-first,
  .woocommerce-billing-fields__field-wrapper .form-row-last,
  .woocommerce-shipping-fields__field-wrapper .form-row-first,
  .woocommerce-shipping-fields__field-wrapper .form-row-last,
  #billing_city_field,
  #billing_state_field,
  #billing_postcode_field,
  #shipping_city_field,
  #shipping_state_field,
  #shipping_postcode_field {
    flex: 0 0 100% !important;
  }
}
/* Email field in Contact section — always full-width */
.rk-contact-fields .form-row { flex: 0 0 100% !important; }
