/* ── Checkout page: field cards left, sticky order summary right ─────────── */

/* No text selection on the page — repeated clicks on clickable rows read as a selection
 * gesture. Form fields stay exempt. */
.checkout-page {
    user-select: none;
    -webkit-user-select: none;
}

.checkout-page input,
.checkout-page textarea,
.checkout-page select {
    user-select: text;
    -webkit-user-select: text;
}

/* Layout */

/* WC's checkout.js prepends the error box as the form's first child — flex + `order`
 * push it below the columns without patching the script. */
.woocommerce-checkout form.checkout {
    display:        flex;
    flex-direction: column;
    /* Bottom spacing lives here so it applies after whatever is last (columns or notice). */
    padding-bottom: var(--space-2xl);
}

.woocommerce-checkout form.checkout > .checkout-page__columns {
    order: 1;
}

.woocommerce-checkout form.checkout > .woocommerce-NoticeGroup-checkout {
    order:      2;
    margin-top: var(--space-lg);
}

.checkout-page__columns {
    display:               grid;
    grid-template-columns: minmax(0, 1fr) 34%;
    gap:                   var(--space-xl);
    align-items:           start;
}

.checkout-page__sidebar {
    position: sticky;
    top:      calc(var(--header-height) + var(--space-lg));
}

/* Card spacing via gap — avoids margin-collapse and a :last-child override. */
.checkout-page__main {
    display:        flex;
    flex-direction: column;
    gap:            var(--space-lg);
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.checkout-card {
    border:        1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding:       var(--space-lg);
    margin-bottom: 0;
}

.checkout-card__title {
    font-size: var(--fs-h4);
    margin:    0 0 var(--space-md);
}

.checkout-card--summary {
    background: #fff;
    border:     1px solid var(--color-border);
    margin:     0;
}

/* ── Form fields ────────────────────────────────────────────────────────── */
/* Generic form styling lives in main.css; only checkout-specific bits stay here. */

/* Hide WC's automatic "(optional)" suffix on the no-call checkbox. */
.checkout-page .checkout-no-call .optional {
    display: none;
}

.checkout-page .checkout-no-call {
    margin-top: var(--space-sm);
}

/* Kill WC core's red outline on an invalid #terms checkbox — it doubled our own bordered box. */
.checkout-page .woocommerce-invalid #terms {
    outline: none;
}

.checkout-page .checkout-no-call label.checkbox {
    display:     flex;
    align-items: flex-start;
    gap:         10px;
    font-size:   var(--fs-body);
    color:       var(--color-text);
    cursor:      pointer;
    /* user-select:none is set page-wide (top of file) */
}

/* "Інший отримувач" (inc/checkout.php). Deliberately NOT WC's
 * #ship-to-different-address-checkbox id — wc-ukr-shipping keys off that exact id. */
.checkout-page .checkout-ship-different .optional {
    display: none;
}

.checkout-page .checkout-ship-different {
    margin-top: var(--space-sm);
}

.checkout-page .checkout-ship-different label.checkbox {
    display:     flex;
    align-items: flex-start;
    gap:         10px;
    font-size:   var(--fs-body);
    color:       var(--color-text);
    cursor:      pointer;
}

.checkout-page .shipping_address.checkout-fields {
    display: none;
    margin-top: var(--space-md);
}

.checkout-page .shipping_address.checkout-fields.is-visible {
    display: grid;
}

/* recipient_fields() are required=false (enforced conditionally), so WC appends "(optional)". */
.checkout-page .shipping_address .optional {
    display: none;
}

/* ── Shipping card ──────────────────────────────────────────────────────── */
.checkout-shipping__methods {
    display:    flex;
    flex-wrap:  wrap;
    gap:        var(--space-sm);
    list-style: none;
    margin:     0;
    padding:    0;
}

.checkout-shipping__method {
    flex:          1 1 220px;
    padding:       12px var(--space-md);
    border:        1px solid var(--color-border);
    border-radius: var(--radius);
    transition:    border-color var(--transition), background var(--transition);
}

.checkout-shipping__method.is-selected,
.checkout-shipping__method:has(input:checked) {
    border-color: var(--color-secondary);
    background:   var(--color-secondary-tint);
}

/* Real input stays functional but invisible — the dot below is the visual,
 * so a lone method with no :checked state still shows filled. */
.checkout-shipping__method input[type="radio"] {
    position: absolute;
    opacity:  0;
    width:    0;
    height:   0;
}

.checkout-shipping__radio-dot {
    position:      relative;
    flex-shrink:   0;
    width:         18px;
    height:        18px;
    border:        1.5px solid var(--color-border);
    border-radius: 50%;
    transition:    border-color var(--transition);
}

.checkout-shipping__radio-dot::after {
    content:       '';
    position:      absolute;
    top:           50%;
    left:          50%;
    width:         10px;
    height:        10px;
    border-radius: 50%;
    background:    var(--color-secondary);
    transform:     translate(-50%, -50%) scale(0);
    transition:    transform var(--transition);
}

.checkout-shipping__method.is-selected .checkout-shipping__radio-dot,
.checkout-shipping__method:has(input:checked) .checkout-shipping__radio-dot {
    border-color: var(--color-secondary);
}

.checkout-shipping__method.is-selected .checkout-shipping__radio-dot::after,
.checkout-shipping__method:has(input:checked) .checkout-shipping__radio-dot::after {
    transform: translate(-50%, -50%) scale(1);
}

/* Радіо, крапка й текст — усе в одному <label>: вся картка клікабельна. */
.checkout-shipping__method-inner {
    display:     flex;
    align-items: center;
    gap:         10px;
    width:       100%;
    margin:      0;
    cursor:      pointer;
}

.checkout-shipping__method-text {
    flex:            1;
    display:         flex;
    align-items:     center;
    justify-content: space-between;
    gap:             var(--space-sm);
    font-weight:     var(--fw-medium);
}

.checkout-shipping__method .woocommerce-Price-amount {
    font-weight: var(--fw-semibold);
    white-space: nowrap;
}

.checkout-shipping__pickup {
    margin-top: var(--space-sm);
    font-size:  16px;
}

.checkout-shipping__pickup-label {
    font-weight: var(--fw-semibold);
}

.checkout-shipping__empty {
    color:  var(--color-text-muted);
    margin: 0;
}

/* Nova Poshta widget (wc-ukr-shipping) — spacing only, keep plugin styles */
.checkout-card .wcus-checkout-form,
.checkout-card [class*="wcus-"] select {
    margin-top: var(--space-sm);
}

/* ── Payment card ───────────────────────────────────────────────────────── */
/* WC core's "#payment{background...}" is an ID selector — only our own ID selector overrides it. */
#payment.woocommerce-checkout-payment {
    background:    transparent;
    border-radius: 0;
}

.checkout-page .wc_payment_methods {
    list-style: none;
    margin:     0 0 var(--space-lg);
    padding:    0;
}

/* Same "#payment" ID-specificity issue — matched with our own ID selector. */
.checkout-page .wc_payment_method {
    border:        1px solid var(--color-border);
    border-radius: var(--radius);
    overflow:      hidden;
    transition:    border-color var(--transition), background var(--transition);
}

/* Matches WC core's selector shape with one extra class so the gap actually renders. */
.woocommerce-checkout #payment ul.payment_methods li:not(:last-child) {
    margin: 0 0 16px 0;
}

.checkout-page .wc_payment_method:hover {
    border-color: var(--color-secondary-light);
}

.checkout-page .wc_payment_method > label {
    display:     flex;
    align-items: center;
    gap:         12px;
    padding:     12px var(--space-md);
    margin:      0;
    font-weight: var(--fw-medium);
    cursor:      pointer;
}

.checkout-page .wc_payment_method > input[type="radio"] {
    position: absolute;
    opacity:  0;
}

.checkout-page .wc_payment_method > label::before {
    content:       '';
    width:         18px;
    height:        18px;
    flex-shrink:   0;
    border:        2px solid var(--color-border);
    border-radius: 50%;
    transition:    border-color var(--transition), box-shadow var(--transition);
}

.checkout-page .wc_payment_method > input[type="radio"]:checked + label::before {
    border-color: var(--color-secondary);
    box-shadow:   inset 0 0 0 4px var(--color-secondary);
}

.checkout-page .wc_payment_method:has(input:checked) {
    border-color: var(--color-secondary);
    background:   var(--color-secondary-tint);
}

/* !important: gateway plugins ship inline width/height on their logos. */
.checkout-page .wc_payment_method label img {
    display:      inline-block !important;
    max-width:    72px !important;
    max-height:   20px !important;
    width:        auto !important;
    height:       auto !important;
    margin:       0 0 0 auto !important;
    padding:      0 !important;
    vertical-align: middle;
}

/* Matches WC core's ".woocommerce-checkout #payment div.payment_box" selector shape
 * (plus one class) — anything less specific loses the tie-break. */
.woocommerce-checkout #payment.woocommerce-checkout-payment div.payment_box {
    margin:            0;
    padding:           0 20px 20px 45px;
    background-color:  transparent;
    border-radius:     0;
    font-size:         var(--fs-small);
    line-height:       var(--lh-base);
    color:             var(--color-text-muted);
}

.woocommerce-checkout #payment.woocommerce-checkout-payment div.payment_box::before {
    content: none !important;
}

.checkout-page .payment_box p:last-child {
    margin-bottom: 0;
}

/* Place order */
.checkout-page .place-order {
    margin:  0;
    padding: 0;
}

.checkout-page #place_order {
    display:         flex;
    width:           100%;
    justify-content: center;
    padding:         14px 28px;
    border:          none;
    border-radius:   50px;
    background:      var(--color-primary);
    color:           #fff;
    font-family:     var(--font-body);
    font-size:       var(--fs-body);
    font-weight:     var(--fw-semibold);
    cursor:          pointer;
    transition:      background var(--transition);
}

.checkout-page #place_order:hover {
    background: var(--color-primary-light);
}

.checkout-page .woocommerce-terms-and-conditions-wrapper {
    margin-top:    0;
    padding-top:   0;
    border-top:    none;
    margin-bottom: var(--space-md);
    font-size:     var(--fs-small);
    color:         var(--color-text-muted);
}


/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .checkout-page__columns {
        grid-template-columns: minmax(0, 1fr);
        gap: var(--space-lg);
    }

    .checkout-page__sidebar {
        position: static;
        order:    -1; /* order summary above the form on small screens */
    }
}

@media (max-width: 768px) {
    .checkout-card {
        padding: var(--space-md);
    }

    .checkout-shipping__methods {
        flex-direction: column;
        flex-wrap:      nowrap;
    }

    .checkout-shipping__method {
        flex-basis: auto;
    }

    .woocommerce-checkout form.checkout {
        padding-bottom: var(--space-xl);
    }

    /* Top-align: long gateway titles wrap to 2+ lines on narrow screens. */
    .checkout-page .wc_payment_method > label {
        align-items: flex-start;
    }

    .checkout-page .wc_payment_method > label::before {
        margin-top: 1px;
    }

    .checkout-page .wc_payment_method label img {
        margin-top: 2px;
    }

    /* WC core's ID-selector padding rules matched with equal specificity to apply on mobile. */
    .woocommerce-checkout #payment.woocommerce-checkout-payment ul.payment_methods {
        padding: 0;
    }

    .woocommerce-checkout #payment.woocommerce-checkout-payment div.form-row {
        padding:    0;
        margin-top: 12px;
    }

    .woocommerce-checkout #payment.woocommerce-checkout-payment div.payment_box {
        padding-left: 32px;
    }
}

@media (max-width: 480px) {
    .checkout-page .wc_payment_method label img {
        max-width: 56px !important;
    }
}

/* ── Thank you / order received page ────────────────────────────────────── */
/* No .checkout-page class here (it lives on the form); this file also loads on order-received. */
.thankyou-page {
    padding-bottom: var(--space-2xl);
}

.thankyou-banner {
    display:        flex;
    flex-direction: column;
    align-items:    center;
    text-align:     center;
    padding:        var(--space-xl) 0 var(--space-lg);
}

.thankyou-banner__icon {
    display:         flex;
    align-items:     center;
    justify-content: center;
    width:           64px;
    height:          64px;
    margin-bottom:   var(--space-md);
    border-radius:   50%;
    background:      var(--color-success);
    color:           #fff;
}

.thankyou-banner__text {
    width:     100%;
    color:     var(--color-text-muted);
    margin:    0;
}

.checkout-card.thankyou-overview {
    margin-bottom: var(--space-xl);
}

.thankyou-overview__list {
    list-style: none;
    margin:     0;
    padding:    0;
}

.thankyou-overview__item {
    display:         flex;
    align-items:     baseline;
    justify-content: space-between;
    gap:             var(--space-sm);
    padding:         10px 0;
    border-bottom:   1px solid var(--color-border);
}

.thankyou-overview__item:last-child {
    border-bottom: none;
}

.thankyou-overview__label {
    color: var(--color-text-muted);
}

.thankyou-overview__value {
    font-weight: var(--fw-semibold);
    color:       var(--color-text);
    text-align:  right;
}

.thankyou-overview__item--total {
    padding-top: var(--space-md);
}

.thankyou-overview__item--total .thankyou-overview__label,
.thankyou-overview__item--total .thankyou-overview__value {
    font-size:   var(--fs-h6);
    font-weight: var(--fw-bold);
    color:       var(--color-text);
}

/* Default WC order-items markup, styled via CSS only (shared with My Account view-order). */
.thankyou-page .woocommerce-order-details {
    margin-top:    var(--space-lg);
    padding:       var(--space-lg);
    border:        1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.thankyou-page .woocommerce-order-details__title {
    font-size:     var(--fs-h4);
    margin:        0 0 var(--space-lg);
}

.thankyou-page table.woocommerce-table--order-details {
    width:           100%;
    border-collapse: collapse;
    font-size:       16px;
}

.thankyou-page table.woocommerce-table--order-details th,
.thankyou-page table.woocommerce-table--order-details td {
    padding:       10px var(--space-md);
    border-bottom: 1px solid var(--color-border);
    text-align:    left;
}

.thankyou-page table.woocommerce-table--order-details thead th {
    color:          var(--color-text-muted);
    font-weight:    var(--fw-semibold);
    font-size:      16px;
    letter-spacing: var(--ls-label);
    text-transform: uppercase;
}

.thankyou-page table.woocommerce-table--order-details td.product-total,
.thankyou-page table.woocommerce-table--order-details th.product-total {
    text-align: right;
}

.thankyou-page table.woocommerce-table--order-details tfoot th {
    font-weight: var(--fw-regular);
    color:       var(--color-text-muted);
}

.thankyou-page table.woocommerce-table--order-details tfoot td {
    text-align: right;
}

.thankyou-page table.woocommerce-table--order-details tfoot tr:last-child th,
.thankyou-page table.woocommerce-table--order-details tfoot tr:last-child td {
    border-bottom: none;
}

.thankyou-page__actions {
    display:         flex;
    justify-content: center;
    gap:             var(--space-md);
    margin-top:      var(--space-lg);
}

.thankyou-page__failed {
    margin-bottom: var(--space-md);
}

@media (max-width: 768px) {
    .thankyou-banner {
        padding: var(--space-lg) 0 var(--space-md);
    }

    .thankyou-banner__icon {
        width:         48px;
        height:        48px;
        margin-bottom: var(--space-sm);
    }

    .checkout-card.thankyou-overview {
        margin-bottom: var(--space-lg);
    }

    .thankyou-page .woocommerce-order-details {
        margin-top: var(--space-md);
        padding:    var(--space-md);
    }

    .thankyou-page table.woocommerce-table--order-details th,
    .thankyou-page table.woocommerce-table--order-details td {
        padding: 10px var(--space-sm);
    }

    .thankyou-page__actions {
        flex-direction: column;
        margin-top:     var(--space-md);
    }

    .thankyou-page__actions .btn {
        width: 100%;
    }

    .thankyou-overview__item {
        flex-direction: column;
        align-items:    flex-start;
        gap:            2px;
    }

    .thankyou-overview__value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .thankyou-banner__icon {
        width:  40px;
        height: 40px;
    }

    .thankyou-banner__icon svg {
        width:  24px;
        height: 24px;
    }

    .thankyou-page .woocommerce-order-details__title {
        margin-bottom: var(--space-md);
    }
}

/* Customer details (order-details-customer.php) — core has no bottom spacing of its own. */
.thankyou-page .woocommerce-customer-details .woocommerce-column__title {
    margin-bottom: var(--space-md);
}

/* Thank-you header — .page-thankyou comes from a body_class filter in inc/checkout.php. */
body.page-thankyou .page-header {
    text-align:     center;
    padding-bottom: var(--space-md);
}

body.page-thankyou .page-header__title {
    text-align:    center;
    margin-bottom: 0;
}
