/* =========================================================================
   CROSO Cart Redesign
   Targets WooCommerce + Patara theme cart page (quote mode, no prices)
   ========================================================================= */

/* --- Hide unused price-related elements --------------------------------- */
.woocommerce-cart-form__contents th:nth-child(3), /* "Price" header */
.woocommerce-cart-form__contents td[data-title="Price"],
.woocommerce-cart-form__contents td[data-title="Prix"],
.woocommerce-cart-form__contents th:last-child, /* "Subtotal" header */
.woocommerce-cart-form__contents td[data-title="Subtotal"],
.woocommerce-cart-form__contents td[data-title="Sous-total"] {
    display: none !important;
}

/* Hide the empty cart totals sidebar in quote mode */
.cart-collaterals .cart_totals,
.cart-collaterals .cross-sells {
    display: none !important;
}

/* --- Reclaim full page width on cart page ------------------------------ */
/* The cart is rendered inside an Elementor widget with "Width = Initial" which caps the visible width.
   We force any widget containing the cart form to fill its Elementor section. */
html body.woocommerce-cart .elementor-widget__width-initial,
html body.woocommerce-cart .elementor-element.elementor-widget,
html body.woocommerce-cart .elementor-widget-shortcode {
    flex: 1 1 100% !important;
    -ms-flex: 1 1 100% !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Patara also wraps the cart in <div class="row"><div class="col-md-8">…</div><div class="col-md-4">…</div></div>.
   Force the cart column to full width with very high specificity to beat Bootstrap/Patara rules. */
html body.woocommerce.woocommerce-cart .row > .col-md-8,
html body.woocommerce.woocommerce-cart .row > div[class*="col-md-8"],
html body.woocommerce-cart .row > .col-md-8 {
    flex: 0 0 100% !important;
    -ms-flex: 0 0 100% !important;
    max-width: 100% !important;
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
html body.woocommerce-cart .row > .col-md-4,
html body.woocommerce.woocommerce-cart .row > div[class*="col-md-4"] {
    display: none !important;
}
html body.woocommerce-cart .row {
    display: block !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* --- Layout: card-based, full width with light side padding ------------ */
.woocommerce-cart-form {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
}

.woocommerce-cart-form__contents,
.woocommerce-cart-form__contents tbody,
.woocommerce-cart-form__contents tr,
.woocommerce-cart-form__contents td,
.woocommerce-cart-form__contents th {
    display: block;
    width: 100%;
    border: none !important;
    background: transparent;
}

/* Hide the header row entirely (we use card labels) */
.woocommerce-cart-form__contents tr.info-title {
    display: none !important;
}

.woocommerce-cart-form__contents tr.woocommerce-cart-form__cart-item {
    background: #fff;
    border: 1px solid #eaeaea !important;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    margin-bottom: 16px;
    padding: 18px 18px 14px;
    position: relative;
    display: grid;
    grid-template-columns: 110px 1fr;
    grid-template-areas:
        "img name"
        "img meta"
        "qty qty"
        "remove remove";
    column-gap: 16px;
    row-gap: 10px;
}

/* --- Image cell --------------------------------------------------------- */
.woocommerce-cart-form__contents td.cd-product-img {
    grid-area: img;
    display: block !important;
    padding: 0;
    align-self: start;
}
.woocommerce-cart-form__contents td.cd-product-img img {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
    background: #fafafa;
}

/* --- Product name + meta cell ------------------------------------------- */
.woocommerce-cart-form__contents td[data-title="Product"],
.woocommerce-cart-form__contents td[data-title="Produit"] {
    grid-area: name / name / meta / meta;
    padding: 0;
}

.woocommerce-cart-form__contents p.product-name {
    margin: 0 0 6px;
    font-size: 1.05em;
    font-weight: 600;
    color: #1a1a1a;
    line-height: 1.3;
    word-break: normal;
    white-space: normal;
}
.woocommerce-cart-form__contents p.product-name a {
    color: inherit;
    text-decoration: none;
}
.woocommerce-cart-form__contents p.product-name a:hover {
    color: #005a80;
}

/* Cart item meta (Fixation, Sécurité, etc.) — list output by wc_get_formatted_cart_item_data */
.woocommerce-cart-form__contents dl.variation,
.woocommerce-cart-form__contents .variation {
    margin: 8px 0 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 8px;
    padding: 0;
}

.woocommerce-cart-form__contents dl.variation dt,
.woocommerce-cart-form__contents dl.variation dd {
    display: block;
    margin: 0;
    padding: 0;
    background: transparent;
    border: none;
    width: auto;
    float: none;
    clear: none;
    font-weight: normal;
}

.woocommerce-cart-form__contents dl.variation > .wc-item-meta-label,
.woocommerce-cart-form__contents dl.variation > dt {
    grid-column: span 1;
    align-self: end;
    font-size: 0.72em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    font-weight: 600;
    padding-bottom: 2px;
}
.woocommerce-cart-form__contents dl.variation > dd p {
    margin: 0 0 8px;
    padding: 8px 12px;
    background: #f4f7fa;
    border-radius: 6px;
    color: #1a1a1a;
    font-size: 0.92em;
    line-height: 1.35;
}

/* Each meta pair on a column on wider screens: stack each label above its value */
.woocommerce-cart-form__contents dl.variation {
    grid-template-columns: 1fr 1fr;
}

/* Reference badge */
.crf-cart-ref-badge {
    display: inline-block;
    background: #005a80;
    color: #fff;
    padding: 3px 10px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 0.85em;
    letter-spacing: 0.02em;
}

/* --- Quantity cell ------------------------------------------------------ */
.woocommerce-cart-form__contents td[data-title="Quantity"],
.woocommerce-cart-form__contents td[data-title="Quantité"] {
    grid-area: qty;
    padding: 10px 0 0;
    border-top: 1px solid #f0f0f0 !important;
    display: flex !important;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}
.woocommerce-cart-form__contents td[data-title="Quantity"]::before,
.woocommerce-cart-form__contents td[data-title="Quantité"]::before {
    content: "Quantité";
    font-size: 0.85em;
    color: #6b7280;
    font-weight: 500;
    margin-right: auto;
}
.woocommerce-cart-form__contents .quantity input.qty,
.woocommerce-cart-form__contents .quantity input[type="number"] {
    width: 64px;
    height: 38px;
    padding: 6px 8px;
    text-align: center;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    background: #fff;
    font-size: 0.95em;
}

/* --- Remove "X" — float top-right of card ------------------------------- */
.woocommerce-cart-form__contents .product-remove,
.woocommerce-cart-form__contents td.product-remove {
    grid-area: remove;
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 0;
    background: transparent !important;
    border: none !important;
}
.woocommerce-cart-form__contents .product-remove a.remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    line-height: 1;
    color: #999;
    background: #f5f5f5 !important;
    border-radius: 50%;
    font-size: 1.1em;
    font-weight: 400;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.woocommerce-cart-form__contents .product-remove a.remove:hover {
    background: #ffe0e0 !important;
    color: #b91c1c;
}

/* --- Page heading (theme outputs "LISTE DES PRODUITS SELECTIONNÉS / Votre demande") */
.woocommerce-cart > h2,
.woocommerce-cart .page-heading,
.woocommerce .page-heading {
    margin-bottom: 24px;
    text-align: center;
}

/* --- Action buttons row ------------------------------------------------- */
.woocommerce-cart-form .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 18px;
    padding: 0;
    background: transparent;
}
.woocommerce-cart-form .actions::before,
.woocommerce-cart-form .actions::after {
    display: none;
}
.woocommerce-cart-form .actions .coupon {
    display: none; /* No coupons in quote mode */
}
.woocommerce-cart-form .actions button[name="update_cart"],
.woocommerce-cart-form .actions input[name="update_cart"] {
    background: #fff !important;
    color: #005a80 !important;
    border: 2px solid #005a80 !important;
    padding: 10px 22px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: background 0.15s ease;
    opacity: 1 !important;
}
.woocommerce-cart-form .actions button[name="update_cart"]:hover,
.woocommerce-cart-form .actions input[name="update_cart"]:hover {
    background: #f4f7fa !important;
}
.woocommerce-cart-form .actions button[name="update_cart"][disabled],
.woocommerce-cart-form .actions input[name="update_cart"][disabled] {
    opacity: 0.5 !important;
    cursor: not-allowed;
}

/* Proceed-to-quote button (the "Transmettre pour devis" CTA) */
.cart-collaterals .checkout-button,
.woocommerce-cart .checkout-button,
.proceed-to-checkout a.checkout-button,
.wc-proceed-to-checkout a.checkout-button {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    background: #005a80 !important;
    color: #fff !important;
    border: 2px solid #005a80 !important;
    padding: 12px 28px !important;
    border-radius: 6px !important;
    font-weight: 600 !important;
    font-size: 1em !important;
    text-decoration: none !important;
    transition: background 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 90, 128, 0.18);
}
.cart-collaterals .checkout-button:hover,
.woocommerce-cart .checkout-button:hover,
.proceed-to-checkout a.checkout-button:hover,
.wc-proceed-to-checkout a.checkout-button:hover {
    background: #00405d !important;
    border-color: #00405d !important;
}

/* Make the proceed-to-checkout container visible at full width on quote mode */
.cart-collaterals {
    margin-top: 22px !important;
    display: flex;
    justify-content: flex-end;
}
.cart-collaterals .wc-proceed-to-checkout {
    padding: 0 !important;
}

/* --- Empty cart polish -------------------------------------------------- */
.woocommerce-cart .cart-empty,
.woocommerce-cart .return-to-shop {
    text-align: center;
}

/* --- Responsive --------------------------------------------------------- */
@media (min-width: 768px) {
    .woocommerce-cart-form__contents tr.woocommerce-cart-form__cart-item {
        grid-template-columns: 140px 1fr;
        grid-template-areas:
            "img name"
            "img meta"
            "img qty";
        padding: 22px 22px 18px;
        column-gap: 22px;
    }
    .woocommerce-cart-form__contents td.cd-product-img img {
        width: 140px;
        height: 140px;
    }
    .woocommerce-cart-form__contents td[data-title="Quantity"],
    .woocommerce-cart-form__contents td[data-title="Quantité"] {
        margin-top: 6px;
    }
}

@media (max-width: 480px) {
    .woocommerce-cart-form__contents dl.variation {
        grid-template-columns: 1fr;
    }
    .woocommerce-cart-form__contents tr.woocommerce-cart-form__cart-item {
        grid-template-columns: 84px 1fr;
        padding: 14px 14px 12px;
    }
    .woocommerce-cart-form__contents td.cd-product-img img {
        width: 84px;
        height: 84px;
    }
}
