/**
 * All of the CSS for your public-facing functionality should be
 * included in this file.
 */

/* Right-align numeric columns in the calculator results table */
.materials-calc-results table .product-price,
.materials-calc-results table .product-quantity,
.materials-calc-results table .product-subtotal {
    text-align: right;
}

/* Base card background and remove default row borders */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-standalone-product-row td,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row td {
    background: #f6f6f6 !important;
    border: 0 !important;
}

/* Remove the theme header separator above the first cart card */
.woocommerce-cart .woocommerce-cart-form__contents thead th {
    border-bottom: 0 !important;
}

/* Shared vertical spacing for standalone rows and grouped rows */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-standalone-product-row td,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row td,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td {
    padding-bottom: 22px !important;
    padding-top: 22px !important;
}

/* Narrow and pad the remove column */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-standalone-product-row td:first-child,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row td:first-child,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td:first-child {
    padding-left: 14px !important;
    padding-right: 8px !important;
    width: 42px;
}

/* Keep some breathing room at the far right edge */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-standalone-product-row td:last-child,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row td:last-child,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td:last-child {
    padding-right: 18px !important;
}

/* Add a little extra right padding to the grouped product column */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row td.product-name {
    padding-right: 24px !important;
}

/* Align standalone and group-header remove cells to the vertical middle */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-standalone-product-row td.product-remove,
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td.product-remove {
    vertical-align: middle;
}

/* Real spacer rows between whole cards */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-card-gap td {
    background: transparent !important;
    border: 0 !important;
    height: 14px;
    padding: 0 !important;
}

/* Round standalone cards on all four outer corners */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-standalone-product-row td:first-child {
    border-bottom-left-radius: 15px;
    border-top-left-radius: 15px;
}

.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-standalone-product-row td:last-child {
    border-bottom-right-radius: 15px;
    border-top-right-radius: 15px;
}

/* Group header is its own faux row */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td {
    background: #dcdcdc !important;
    border: 0 !important;
    padding-bottom: 16px !important;
    padding-top: 16px !important;
}

/* Round the top corners of grouped cards on the header row */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td:first-child {
    border-top-left-radius: 15px;
}

.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td:last-child {
    border-top-right-radius: 15px;
}

/* Style the single group remove link like the normal Woo remove control */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td.product-remove .remove {
    color: #596457 !important;
    display: inline-flex !important;
    font-size: 0 !important;
    font-weight: 400 !important;
    height: 24px !important;
    line-height: 1 !important;
    width: 24px !important;
}

/* Darken the group remove icon on hover */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td.product-remove .remove:hover {
    color: #1f2a1f !important;
}

/* Give the group header cell breathing room */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-card-header td.ad-materials-calc-group-card-header__content {
    padding-left: 0 !important;
    text-align: left !important;
}

/* Group header content now lives in its own table row */
.woocommerce-cart .ad-materials-calc-group-header {
    margin: 0;
    text-align: left;
}

/* Main project title styling */
.woocommerce-cart .ad-materials-calc-group-header__title {
    color: #1d261d;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -.01em;
    line-height: 1.45;
    max-width: 720px;
    text-align: left;
}

/* Smaller subtitle beneath the project title */
.woocommerce-cart .ad-materials-calc-group-header__meta {
    color: #667267;
    font-size: 12px;
    line-height: 1.5;
    margin-top: 7px;
    text-align: left;
}

/* Highlight the group discount beneath the regular meta */
.woocommerce-cart .ad-materials-calc-group-header__discount {
    color: #b42318;
    display: inline;
}

/* Keep calculator discount rows visually consistent */
.materials-calc-results .ad-materials-calc-results-discount-label {
    color: #b42318;
}

.materials-calc-results__error-output {
    margin: 0;
    white-space: pre-wrap;
}

.materials-calc-debug-output {
    margin-top: 24px;
}

.materials-calc-debug-output__answers {
    margin: 0 0 16px;
    white-space: pre-wrap;
}

.materials-calc-debug-output__clause {
    margin-bottom: 14px;
}

.materials-calc-debug-output__title {
    margin-top: 20px;
}

.materials-calc-debug-output__details {
    margin: 10px 0 0;
    white-space: pre-wrap;
}

.ad-materials-calc-results-sku {
    font-size: 12px;
    opacity: .75;
}

.ad-materials-calc-results-summary-label {
    text-align: right;
}

/* Calculator result notes below the add-to-cart button */
.ad-materials-calc-results-note {
    color: #444;
    font-size: 14px;
    line-height: 1.5;
    margin-top: 25px;
}

.ad-materials-calc-results-note__prefix {
    color: var(--wd-primary-color);
    font-weight: 600;
}

.ad-materials-calc-results-note__text {
    color: inherit;
}

.ad-materials-calc-results-notice {
    background: #fafafa;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-top: 25px;
    padding: 12px;
}

.materials-calc-add-to-cart {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.woocommerce-cart .cart-totals-inner .checkout-button.ad-materials-calc-share-cart-button {
    background-color: #8a8f93 !important;
    border-color: #8a8f93 !important;
    color: #fff !important;
    margin-top: 10px;
}

.woocommerce-cart .cart-totals-inner .checkout-button.ad-materials-calc-share-cart-button:hover,
.woocommerce-cart .cart-totals-inner .checkout-button.ad-materials-calc-share-cart-button:focus {
    background-color: #5f656a !important;
    border-color: #5f656a !important;
    color: #fff !important;
}

.materials-calc-share-modal[hidden] {
    display: none;
}

.materials-calc-share-modal {
    align-items: center;
    bottom: 0;
    display: flex;
    justify-content: center;
    left: 0;
    padding: 20px;
    position: fixed;
    right: 0;
    top: 0;
    z-index: 99999;
}

.materials-calc-share-modal__backdrop {
    background: rgba(0, 0, 0, .55);
    bottom: 0;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
}

.materials-calc-share-modal__dialog {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
    max-width: 560px;
    padding: 34px 28px 28px;
    position: relative;
    width: 100%;
}

button.materials-calc-share-modal__close {
    background: transparent !important;
    color: #777 !important;
    cursor: pointer;
    font-size: 28px !important;
    height: 32px !important;
    min-height: 0 !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    position: absolute !important;
    right: 18px !important;
    top: 12px !important;
    width: 32px !important;
    z-index: 1;
}

.materials-calc-share-modal__dialog h3 {
    margin: 10px 0 15px 0;
    font-weight: 600 !important;
}

.materials-calc-share-modal__description {
    color: #555;
    margin-bottom: 16px;
}

.materials-calc-share-modal__link-row {
    display: flex;
    gap: 8px;
}

.materials-calc-share-modal__link {
    flex: 1;
    min-width: 0;
}

.materials-calc-share-modal__status {
    color: var(--wd-primary-color);
    font-size: 13px;
    margin-top: 10px;
    min-height: 18px;
}

/* Joint filler note inside grouped cart/order metadata */
.woocommerce-cart .ad-materials-calc-group-header__joint-filler-note {
    color: #667267;
    display: inline;
}

/* Indent grouped product content under the header row */
.woocommerce-cart .ad-materials-calc-product-cell-inner--grouped {
    padding-left: 18px;
}

/* Round the bottom corners of grouped cards on the last grouped row */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row-last td:first-child {
    border-bottom-left-radius: 15px;
}

.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row-last td:last-child {
    border-bottom-right-radius: 15px;
}

/* Hide extra-options edit links for grouped products */
.woocommerce-cart .woocommerce-cart-form__contents tr.ad-materials-calc-group-product-row .tm-cart-edit-options {
    display: none !important;
}

/* Keep the action row outside the card background styling */
.woocommerce-cart .woocommerce-cart-form__contents tr.wd-cart-action-row td {
    background: transparent !important;
}

@media (max-width: 768px) {

    /* Slightly reduce the title size on mobile */
    .woocommerce-cart .ad-materials-calc-group-header__title {
        font-size: 14px;
    }

    /* Keep grouped rows only slightly indented on mobile */
    .woocommerce-cart .ad-materials-calc-product-cell-inner--grouped {
        padding-left: 10px;
    }

    .materials-calc-results table.shop_table_responsive,
    .materials-calc-results table.shop_table_responsive tbody {
        border: 0;
        display: block;
        width: 100%;
    }

    .materials-calc-results table.shop_table_responsive thead {
        display: none;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row {
        background: #f6f6f6;
        display: grid;
        grid-template-areas:
            "thumbnail name"
            "price price"
            "quantity quantity"
            "subtotal subtotal";
        column-gap: 12px;
        grid-template-columns: 96px minmax(0, 1fr);
        margin-bottom: 14px;
        width: 100%;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td {
        background: #f6f6f6;
        border: 0;
        box-sizing: border-box;
        display: block;
        width: auto;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-thumbnail {
        grid-area: thumbnail;
        padding: 18px 0 14px 14px;
        text-align: left;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-thumbnail img {
        height: auto !important;
        max-width: 80px !important;
        min-width: 80px !important;
        width: 80px !important;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-name {
        grid-area: name;
        padding: 18px 14px 14px 0;
        text-align: left;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-price,
    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-quantity,
    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-subtotal {
        align-items: center;
        border-top: 4px solid #fff;
        display: flex;
        justify-content: space-between;
        padding: 14px;
        text-align: right;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-price {
        grid-area: price;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-quantity {
        grid-area: quantity;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-subtotal {
        grid-area: subtotal;
    }

    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-price::before,
    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-quantity::before,
    .materials-calc-results tr.ad-materials-calc-results-product-row td.product-subtotal::before {
        color: #667267;
        content: attr(data-title);
        font-weight: 400;
        padding-right: 16px;
        text-align: left;
    }

    .materials-calc-results tr.wd-cart-action-row {
        align-items: center;
        border-top: 1px solid #eee;
        display: flex;
        justify-content: space-between;
        padding: 12px 14px;
    }

    .materials-calc-results tr.wd-cart-action-row td {
        border: 0;
        display: block;
        padding: 0;
        width: auto;
    }

    .materials-calc-results tr.wd-cart-action-row .ad-materials-calc-results-summary-label {
        text-align: left;
    }

    .materials-calc-results tr.wd-cart-action-row .product-subtotal {
        text-align: right;
    }
}