/*
 * Cart v2 (includes/woocommerce/cart-v2.php), shown to everyone on the cart page.
 * Every rule is scoped to body.por-cart-v2, added by that file.
 */

/* Title "Panier (3)": left, compact ------------------------------------------ */

body.por-cart-v2 h1.page-title {
    text-align: left;
}

body.por-cart-v2 .por-cart-v2-count {
    margin-left: .3em;
    color: var(--gray-400, #8c96a3);
    font-weight: 500;
}

@media (max-width: 768px) {
    body.por-cart-v2 h1.page-title {
        font-size: 24px;
        line-height: 1.2;
        margin-bottom: 12px;
    }
}

/* Items --------------------------------------------------------------------- */

body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-item__image img {
    width: 64px;
    max-width: none;
    height: 84px;
    object-fit: contain;
    background: #f4f4f2;
    border-radius: 10px;
}

body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-components-product-name {
    margin-right: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-transform: none;
    letter-spacing: 0;
}

body.por-cart-v2 .wc-block-cart-item__wrap {
    flex-wrap: wrap;
    gap: 6px 12px;
}

/* "En stock · expédié sous 24 h" (data-por-stock, set by cart-v2.js) */
body.por-cart-v2 .wc-block-cart-item__wrap[data-por-stock]::after {
    content: attr(data-por-stock);
    order: 1;
    flex-basis: 100%;
    padding-left: 14px;
    font-size: 12px;
    line-height: 1.4;
    color: #1f7a45;
    background: radial-gradient(circle, #2e9d5b 3px, transparent 3.5px) left center / 8px 8px no-repeat;
}

/* Quantity −/+ and the "Supprimer" text link: 44px tap targets */
body.por-cart-v2 .wc-block-cart-item__quantity {
    order: 2;
    flex-basis: 100%;
    flex-wrap: wrap;
    gap: 4px 16px;
}

/* Quantity: 112×40 visible (1 + 36 + 38 + 36 + 1). The −/+ tap areas reach 44×46 with an
   invisible ::before that grows outwards only, so −, the number and + never overlap. */
body.por-cart-v2 .wc-block-components-quantity-selector {
    box-sizing: border-box;
    width: auto;
    min-width: 0;
    height: 40px;
    margin: 0;
    overflow: visible;
    border-radius: 10px;
}

body.por-cart-v2 .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button {
    position: relative;
    width: 36px;
    min-width: 36px;
    height: 38px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
}

body.por-cart-v2 .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button::before {
    content: "";
    position: absolute;
    top: -4px;
    bottom: -4px;
    left: 0;
    right: 0;
}

body.por-cart-v2 .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button--minus::before {
    left: -8px;
}

body.por-cart-v2 .wc-block-components-quantity-selector .wc-block-components-quantity-selector__button--plus::before {
    right: -8px;
}

body.por-cart-v2 .wc-block-components-quantity-selector input.wc-block-components-quantity-selector__input {
    width: 38px;
    min-width: 38px;
    height: 38px;
    font-size: 15px;
    font-weight: 500;
}

body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link {
    position: static;
    display: inline-flex;
    align-items: center;
    width: auto;
    height: 44px;
    min-width: 44px;
    margin: 0;
    padding: 0 4px;
    font-size: 14px;
    line-height: 1;
    color: var(--gray-600, #4b5563);
    text-decoration: underline;
    text-underline-offset: 3px;
    background: none;
    border: 0;
    cursor: pointer;
}

body.por-cart-v2 .wc-block-cart-item__remove-link svg {
    display: none;
}

body.por-cart-v2 .wc-block-cart-item__remove-link::before {
    content: var(--por-cart-remove, "×");
}

/* Line total + unit price "€139,00 × 2" (data-por-unit, set by cart-v2.js) */
body.por-cart-v2 .wc-block-cart-item__total[data-por-unit]::after {
    content: attr(data-por-unit);
    display: block;
    margin-top: 4px;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.3;
    text-align: right;
    white-space: nowrap;
    color: var(--gray-400, #8c96a3);
}

/* The price carries a 10px right margin: line it up with the unit price under it (every row, so totals stay in one column). */
body.por-cart-v2 .wc-block-cart-item__total .wc-block-components-product-price {
    margin-right: 0;
}

/* Desktop: the total cell is a flex row, which put the unit price beside the total. */
body.por-cart-v2 .wc-block-cart-item__total[data-por-unit] {
    flex-direction: column;
    align-items: flex-end;
}

/*
 * Mobile row, by media query (Woo adds .is-mobile only after measuring the block, and
 * until then its base 80px + 132px + total grid is wider than a 360px screen):
 *   [image] name                       ×
 *           ● in stock
 *           [− 1 +]            €112,10
 *                         €56,05 × 2
 */
@media (max-width: 768px) {
    /* The admin bar's off-screen "Duplicate Post" label (left: 388px) widened the page on
       phones, cutting the fixed header and checkout bar. clip, not hidden: submenus still drop down. */
    body.por-cart-v2 #wpadminbar {
        overflow-x: clip;
    }

    /* Card right under the header. The theme's header is fixed at top: 50px, and the admin
       bar (46px) pushes the page down under it: a 58px gray band instead of 12px. Take back
       44px (empty breadcrumb block 20px, section top padding 20px, 4px): 14px left. */
    body.por-cart-v2.admin-bar .section-page {
        padding-top: 0;
    }

    body.por-cart-v2.admin-bar .section-page .breadcrumb-blok {
        display: none;
    }

    body.por-cart-v2.admin-bar .section-page article {
        margin-top: -4px;
    }

    /* Same inset on both sides of the card (theme: 16px, 8px up to 390px), and the totals
       on the same lines as the items (the totals card had its own 20px sides). */
    body.por-cart-v2.woocommerce-cart .section-page article {
        padding-left: 20px;
        padding-right: 20px;
    }

    body.por-cart-v2 .wc-block-components-sidebar-layout .wc-block-components-sidebar {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    body.por-cart-v2 .wc-block-components-sidebar-layout .wc-block-components-main {
        padding: 0;
    }

    body.por-cart-v2 table.wc-block-cart-items,
    body.por-cart-v2 table.wc-block-cart-items tbody {
        display: block;
        width: 100%;
        margin: 0;
    }

    body.por-cart-v2 table.wc-block-cart-items thead {
        display: none;
    }

    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row {
        --por-row-top: 16px;
        display: grid;
        grid-template-columns: 64px minmax(0, 1fr);
        column-gap: 12px !important;
        position: relative;
        padding: var(--por-row-top) 0 16px;
    }

    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row:first-child {
        --por-row-top: 4px;
    }

    body.por-cart-v2 table.wc-block-cart-items td.wc-block-cart-item__image {
        grid-column: 1;
        grid-row: 1;
        padding: 0;
    }

    body.por-cart-v2 table.wc-block-cart-items td.wc-block-cart-item__product {
        grid-column: 2;
        grid-row: 1;
        min-width: 0;
        padding: 0 !important;
    }

    /* Room for the × on the first line of the name. */
    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-components-product-name {
        padding-right: 28px;
        overflow-wrap: anywhere;
    }

    /* Woo's own remove button, shown as a × in the row's top right corner: 18px icon,
       44×44 tap area centred on the name's first line (20px), far from the "+". */
    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__quantity .wc-block-cart-item__remove-link {
        position: absolute;
        top: calc(var(--por-row-top) - 12px);
        right: -13px;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        padding: 0;
        color: var(--gray-400, #8c96a3);
        text-decoration: none;
        border-radius: 50%;
    }

    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__remove-link::before {
        content: "";
        width: 18px;
        height: 18px;
        background: currentColor;
        -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
        mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 6l12 12M18 6L6 18' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
    }

    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__remove-link:hover,
    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__remove-link:focus-visible {
        color: var(--gray-600, #4b5563);
    }

    body.por-cart-v2 table.wc-block-cart-items .wc-block-cart-items__row .wc-block-cart-item__remove-link:focus-visible {
        outline: 2px solid var(--black-blue, #0b1f3a);
        outline-offset: -6px;
    }

    /* Line total on the counter's line, right side: the counter is the row's last line (16px padding). */
    body.por-cart-v2 table.wc-block-cart-items td.wc-block-cart-item__total {
        position: absolute;
        right: 0;
        bottom: 16px;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-end;
        height: 40px;
        padding: 0 !important;
        text-align: right;
    }

    body.por-cart-v2 .wc-block-cart-items__row .wc-block-components-product-price {
        justify-content: flex-end;
        font-size: 16px;
    }

    body.por-cart-v2 .wc-block-cart-item__total[data-por-unit]::after {
        margin-top: 2px;
    }

    body.por-cart-v2 .wc-block-cart-item__wrap[data-por-stock]::after {
        white-space: nowrap;
    }

    /* Sticky checkout bar: viewport edges, notch-safe padding, no fixed width. */
    body.por-cart-v2 .wc-block-cart__submit-container--sticky {
        left: 0;
        right: 0;
        width: auto;
        max-width: 100%;
        box-sizing: border-box;
        padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    }

    /* Same inset on both sides: never wider than the bar. */
    body.por-cart-v2 .wc-block-cart__submit-container--sticky .wc-block-cart__submit-button {
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
    }

    /* Totals right after the last item, with the same spacing as between items (16px row
       padding + 16px): no layout gap, no extra space on top of the totals card. No room is
       kept for the sticky bar: it hides once the summary's own button has been passed
       (cart-v2.js, body.por-cart-v2-past), so it never covers the end of the page. */
    body.por-cart-v2 .wc-block-components-sidebar-layout {
        row-gap: 0;
    }

    body.por-cart-v2 .wc-block-components-sidebar-layout .wc-block-components-sidebar {
        padding-top: 0 !important;
    }

    body.por-cart-v2.por-cart-v2-past .wc-block-cart__submit-container--sticky {
        display: none;
    }

    /* Estimated delivery line in the sticky bar (cart-v2.js), over the button: one line, 12.5px. */
    body.por-cart-v2 .wc-block-cart__submit-container--sticky .por-cart-v2-eta {
        display: flex;
    }
}

/* Free shipping progress --------------------------------------------------- */

body.por-cart-v2 .por-cart-v2-progress {
    margin: 0 0 16px;
    padding: 14px 16px;
    background: #fff;
    border-radius: 16px;
}

body.por-cart-v2 .por-cart-v2-progress__text {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
    color: var(--black-blue, #0b1f3a);
}

body.por-cart-v2 .por-cart-v2-progress__bar {
    height: 6px;
    overflow: hidden;
    background: #ecebe6;
    border-radius: 6px;
}

body.por-cart-v2 .por-cart-v2-progress__bar span {
    display: block;
    height: 100%;
    background: #b08d57;
    border-radius: inherit;
    transition: width .3s ease;
}

body.por-cart-v2 .por-cart-v2-progress.is-done .por-cart-v2-progress__text {
    color: #1f7a45;
}

body.por-cart-v2 .por-cart-v2-progress.is-done .por-cart-v2-progress__bar span {
    background: #2e9d5b;
}

/* Estimated delivery (under the totals) ---------------------------------------- */

body.por-cart-v2 .por-cart-v2-delivery {
    padding: 10px 0 2px;
    font-size: 13px;
    line-height: 1.4;
    color: var(--gray-600, #4b5563);
}

/* Express payment without buttons: no empty block, no lonely "OU".
   Collapsed, not display:none, so a wallet button that appears later is still measured. */
body.por-cart-v2 .wc-block-cart__payment-options.por-cart-v2-no-express,
body.por-cart-v2 .wc-block-components-express-payment__event-buttons > li.por-cart-v2-empty {
    height: 0;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
}

/* Checkout button with the total on the right ------------------------------------ */

body.por-cart-v2 .wc-block-components-button.wc-block-cart__submit-button[data-por-total] {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding-left: 20px;
    padding-right: 20px;
}

body.por-cart-v2 .wc-block-cart__submit-button[data-por-total] .wc-block-components-button__text {
    flex: 0 1 auto;
    text-align: left;
}

@media (max-width: 768px) {
    body.por-cart-v2 .wc-block-components-button.wc-block-cart__submit-button[data-por-total] {
        font-size: 15px;
    }
}

body.por-cart-v2 .wc-block-cart__submit-button[data-por-total]::after {
    content: attr(data-por-total);
    flex: none;
    font-weight: 700;
    white-space: nowrap;
}

/* Trust badges and payment logos -------------------------------------------- */

body.por-cart-v2 .por-cart-v2-trust {
    margin-top: 16px;
}

body.por-cart-v2 .por-cart-v2-trust ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

body.por-cart-v2 .por-cart-v2-trust__badges {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

body.por-cart-v2 .por-cart-v2-trust__badges li {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    line-height: 1.3;
    text-align: center;
    color: var(--gray-600, #4b5563);
}

body.por-cart-v2 .por-cart-v2-trust__badges svg {
    color: var(--black-blue, #0b1f3a);
}

body.por-cart-v2 .por-cart-v2-trust__pay {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin-top: 14px !important;
}

body.por-cart-v2 .por-cart-v2-trust__pay li {
    display: flex;
    align-items: center;
    height: 26px;
    padding: 0 4px;
    background: #fff;
    border: 1px solid #e5e4df;
    border-radius: 5px;
}

body.por-cart-v2 .por-cart-v2-trust__pay img {
    display: block;
    width: auto;
    height: 18px;
}

body.por-cart-v2 .por-cart-v2-trust__pay li.is-text {
    padding: 0 8px;
    font-size: 11px;
    color: var(--gray-600, #4b5563);
}

/* Estimated delivery in the sticky bar: hidden unless the bar is sticky (mobile rule above). */
body.por-cart-v2 .por-cart-v2-eta {
    display: none;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0 4px 8px;
    font-size: 12.5px;
    line-height: 16px;
    color: var(--gray-600, #4b5563);
}

body.por-cart-v2 .por-cart-v2-eta svg {
    flex: none;
    color: var(--black-blue, #0b1f3a);
}

body.por-cart-v2 .por-cart-v2-eta span {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* 16px on phones up to 390px (some report 390.4px), 20px from 450px. */
@media (max-width: 400px) {
    body.por-cart-v2.woocommerce-cart .section-page article {
        padding-left: 16px;
        padding-right: 16px;
    }
}
