/*
 * KingSoft / Osapa 2.2.4 migration — Phase 16
 * Final pre-upgrade cleanup: checkout invoice field, checkout/cart summaries,
 * taxonomy directories, category fallback icon and restored contact CTA.
 */

/* --------------------------------------------------------------------------
 * VAT invoice NIP field. The element is rendered once by PHP and positioned
 * directly below the optional invoice checkbox by phase16-checkout-ui.js.
 * ----------------------------------------------------------------------- */
.woocommerce-checkout .kingsoft-invoice-nip-mount {
    display: none;
    width: 100%;
    margin: 12px 0 0;
}

.woocommerce-checkout .kingsoft-invoice-nip-mount.is-active {
    display: block !important;
}

.woocommerce-checkout .kingsoft-invoice-nip-mount[hidden].is-active {
    display: block !important;
}

.woocommerce-checkout .kingsoft-invoice-nip-mount .form-row {
    width: 100% !important;
    margin: 0 !important;
}

.woocommerce-checkout .kingsoft-invoice-nip-mount label {
    display: block !important;
    margin: 0 0 8px !important;
    color: #111 !important;
    font-weight: 700 !important;
}

.woocommerce-checkout .kingsoft-invoice-nip-mount label .required,
.woocommerce-checkout .kingsoft-invoice-nip-mount .kingsoft-required-star {
    color: #ea0028 !important;
}

.woocommerce-checkout .kingsoft-invoice-nip-mount input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* --------------------------------------------------------------------------
 * Cart: delivery is intentionally chosen only on Checkout. Remove the cart
 * shipping block entirely so the customer does not choose the same thing twice.
 * PHP also disables cart-page shipping calculation so the total is not stale.
 * ----------------------------------------------------------------------- */
.woocommerce-cart .cart_totals tr.shipping,
.woocommerce-cart .cart_totals tr.woocommerce-shipping-totals,
.woocommerce-cart .woocommerce-shipping-calculator,
.woocommerce-cart .shipping-calculator-button,
.woocommerce-cart .shipping-calculator-form {
    display: none !important;
}

/* --------------------------------------------------------------------------
 * Checkout order summary: every summary block spans the full review width.
 * Borders belong to the outer row, not individual cells, which removes the
 * broken vertical/partial lines visible in the old layout.
 * ----------------------------------------------------------------------- */
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr {
    width: 100% !important;
    max-width: none !important;
    box-sizing: border-box !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 140px !important;
    align-items: stretch !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    border: 1px solid #e3e3e3 !important;
    border-top: 0 !important;
    background: #fff !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal > th,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal > td,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total > th,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total > td {
    display: flex !important;
    align-items: center !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 14px 18px !important;
    border: 0 !important;
    box-sizing: border-box !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal > th,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total > th {
    justify-content: flex-start !important;
    text-align: left !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal > td,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total > td {
    justify-content: flex-end !important;
    text-align: right !important;
    white-space: nowrap !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals.shipping,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot tr.shipping {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 1px solid #e3e3e3 !important;
    border-top: 0 !important;
    background: #fff !important;
    box-sizing: border-box !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals.shipping > th,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot tr.shipping > th,
.woocommerce-checkout .woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals.shipping > td,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot tr.shipping > td {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
    border: 0 !important;
    box-sizing: border-box !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals.shipping > th,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot tr.shipping > th {
    padding: 15px 18px 6px !important;
    text-align: left !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table tr.woocommerce-shipping-totals.shipping > td,
.woocommerce-checkout .woocommerce-checkout-review-order-table tfoot tr.shipping > td {
    padding: 4px 18px 16px !important;
    text-align: left !important;
}

.woocommerce-checkout .woocommerce-checkout-review-order-table #shipping_method {
    width: 100% !important;
    max-width: 100% !important;
}

/* InPost prompt belongs above the selector. */
.woocommerce-checkout .kingsoft-paczkomat-map-link {
    display: block !important;
    width: 100% !important;
    margin: 10px 0 7px !important;
    color: #ea0028 !important;
    font-weight: 700 !important;
    line-height: 1.3 !important;
    text-align: left !important;
}

.woocommerce-checkout .kingsoft-paczkomat-map-link:hover,
.woocommerce-checkout .kingsoft-paczkomat-map-link:focus-visible {
    color: #111b4c !important;
}

/* --------------------------------------------------------------------------
 * Taxonomy directory pages: real click destinations for Marki samochodów and
 * Producenci części.
 * ----------------------------------------------------------------------- */
.kingsoft-tax-directory {
    max-width: 1200px;
    margin: 0 auto;
    padding: 35px 15px 65px;
    box-sizing: border-box;
}

.kingsoft-tax-directory > h2 {
    margin: 0 0 28px !important;
    text-align: center;
}

.kingsoft-tax-directory-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0 20px;
    width: 100%;
}

.kingsoft-tax-directory-item {
    display: flex;
    align-items: center;
    min-height: 62px;
    padding: 14px 0;
    border-bottom: 1px solid #e5e5e5;
    color: #111;
    font-family: "Montserrat", "Open Sans", Arial, sans-serif;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.25;
    text-decoration: none !important;
}

.kingsoft-tax-directory-item:hover,
.kingsoft-tax-directory-item:focus-visible {
    color: #ea0028;
}

/* --------------------------------------------------------------------------
 * Missing category thumbnail fallback. Matches the black line-icon language.
 * ----------------------------------------------------------------------- */
.kingsoft-category-fallback-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    color: #111;
}

.kingsoft-category-fallback-icon svg {
    display: block;
    width: 54px;
    height: 54px;
}

.ivn-home-category-card-image .kingsoft-category-fallback-icon,
.kingsoft-all-categories-image .kingsoft-category-fallback-icon {
    width: 100%;
    height: 100%;
    min-height: 86px;
}

.ivn-home-category-card-image .kingsoft-category-fallback-icon svg,
.kingsoft-all-categories-image .kingsoft-category-fallback-icon svg {
    width: 72px;
    height: 72px;
}

.ivn-category-all .kingsoft-all-categories-image {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 115px;
}

.ivn-category-all .kingsoft-all-categories-image img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* --------------------------------------------------------------------------
 * Restored Contact call-to-action in the footer contact column.
 * ----------------------------------------------------------------------- */
.kingsoft-footer-contact-cta {
    margin: 14px 0 0 !important;
}

.kingsoft-footer-contact-cta a {
    display: inline-block;
    padding: 9px 18px;
    border: 1px solid #ea0028;
    background: #ea0028;
    color: #fff !important;
    font-family: "Montserrat", "Open Sans", Arial, sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    text-decoration: none !important;
}

.kingsoft-footer-contact-cta a:hover,
.kingsoft-footer-contact-cta a:focus-visible {
    border-color: #fff;
    background: #fff;
    color: #111b4c !important;
}

@media (max-width: 991px) {
    .kingsoft-tax-directory-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal,
    .woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total {
        grid-template-columns: minmax(0, 1fr) 115px !important;
    }

    .woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal > th,
    .woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.cart-subtotal > td,
    .woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total > th,
    .woocommerce-checkout .woocommerce-checkout-review-order-table tfoot > tr.order-total > td {
        padding: 13px 14px !important;
    }

    .kingsoft-tax-directory {
        padding-top: 25px;
        padding-bottom: 45px;
    }

    .kingsoft-tax-directory-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0 16px;
    }

    .kingsoft-tax-directory-item {
        min-height: 54px;
        font-size: 14px;
    }
}

@media (max-width: 420px) {
    .kingsoft-tax-directory-grid {
        grid-template-columns: 1fr;
    }
}
