/* MIM RC51: isolierte Commerce-Oberfläche. */
body.mim-commerce-ui {
    --mim-black: #0b0b0b;
    --mim-card-dark: #151515;
    --mim-yellow: #ffff33;
    --mim-white: #fff;
    --mim-muted: #8f8f8f;
    --mim-surface: #f7f7f5;
    --mim-border: #dedede;
    --mim-danger: #b42318;
    --mim-success: #237a3b;
    background: var(--mim-white);
}

body.mim-commerce-ui .site-content > .ast-container,
body.mim-commerce-ui .entry-content > .woocommerce {
    width: 100%;
    max-width: 1180px;
    margin-inline: auto;
}

body.mim-commerce-ui .woocommerce {
    color: var(--mim-black);
}

body.mim-commerce-ui .woocommerce h1,
body.mim-commerce-ui .woocommerce h2,
body.mim-commerce-ui .woocommerce h3,
body.mim-commerce-ui .cart_totals > h2,
body.mim-commerce-ui #order_review_heading {
    color: var(--mim-black);
    line-height: 1.08;
    text-transform: uppercase;
    letter-spacing: .02em;
}

body.mim-commerce-ui .woocommerce button.button,
body.mim-commerce-ui .woocommerce a.button,
body.mim-commerce-ui .woocommerce input.button,
body.mim-commerce-ui #place_order,
body.mim-commerce-ui .checkout-button {
    min-height: 50px;
    padding: 13px 22px;
    border: 2px solid var(--mim-black);
    border-radius: 8px;
    background: var(--mim-yellow);
    color: var(--mim-black);
    font-weight: 800;
    line-height: 1.2;
    text-transform: uppercase;
    box-shadow: none;
}

body.mim-commerce-ui .woocommerce button.button:hover,
body.mim-commerce-ui .woocommerce a.button:hover,
body.mim-commerce-ui .woocommerce input.button:hover,
body.mim-commerce-ui #place_order:hover,
body.mim-commerce-ui .checkout-button:hover {
    background: var(--mim-black);
    color: var(--mim-white);
}

body.mim-commerce-ui :where(a, button, input, select, textarea):focus-visible {
    outline: 3px solid var(--mim-yellow);
    outline-offset: 3px;
}

body.mim-commerce-ui .woocommerce button.button:disabled,
body.mim-commerce-ui .woocommerce button.button.disabled {
    border-color: #aaa;
    background: #ddd;
    color: #666;
    opacity: 1;
}

body.mim-commerce-ui .woocommerce-message,
body.mim-commerce-ui .woocommerce-info,
body.mim-commerce-ui .woocommerce-error {
    margin: 0 0 24px;
    padding: 18px 20px 18px 48px;
    border: 1px solid var(--mim-border);
    border-radius: 10px;
    background: var(--mim-surface);
    color: var(--mim-black);
}

body.mim-commerce-ui .woocommerce-message { border-left: 5px solid var(--mim-success); }
body.mim-commerce-ui .woocommerce-info { border-left: 5px solid var(--mim-yellow); }
body.mim-commerce-ui .woocommerce-error { border-left: 5px solid var(--mim-danger); }

/* Warenkorb */
body.woocommerce-cart.mim-commerce-ui .woocommerce-cart-form {
    float: left;
    width: calc(66.666% - 16px);
}

body.woocommerce-cart.mim-commerce-ui .cart-collaterals {
    float: right;
    width: calc(33.333% - 16px);
}

body.woocommerce-cart.mim-commerce-ui .cart-collaterals .cart_totals {
    position: sticky;
    top: 118px;
    width: 100%;
    padding: 28px;
    border: 1px solid var(--mim-border);
    border-radius: 12px;
    background: var(--mim-surface);
}

body.woocommerce-cart.mim-commerce-ui table.shop_table {
    border: 0;
    border-collapse: separate;
    border-spacing: 0 14px;
    background: transparent;
}

body.woocommerce-cart.mim-commerce-ui table.shop_table thead th {
    padding: 0 14px 8px;
    border: 0;
    color: var(--mim-muted);
    font-size: .82rem;
    text-transform: uppercase;
}

body.woocommerce-cart.mim-commerce-ui table.shop_table tbody tr.cart_item {
    background: var(--mim-surface);
    box-shadow: 0 0 0 1px var(--mim-border);
}

body.woocommerce-cart.mim-commerce-ui table.shop_table tbody tr.cart_item td {
    padding: 18px 12px;
    border: 0;
    vertical-align: middle;
}

body.woocommerce-cart.mim-commerce-ui td.product-thumbnail img {
    width: 104px;
    height: 104px;
    border-radius: 10px;
    object-fit: cover;
}

body.woocommerce-cart.mim-commerce-ui td.product-name a {
    color: var(--mim-black);
    font-weight: 800;
}

body.woocommerce-cart.mim-commerce-ui .quantity {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
}

body.woocommerce-cart.mim-commerce-ui .quantity .qty {
    min-height: 44px;
    border: 1px solid var(--mim-border);
    border-radius: 7px;
}

body.woocommerce-cart.mim-commerce-ui td.product-remove a.remove {
    display: inline-grid;
    width: 44px;
    height: 44px;
    place-items: center;
    color: var(--mim-danger) !important;
}

body.woocommerce-cart.mim-commerce-ui .cart_totals table {
    border: 0;
    border-collapse: collapse;
}

body.woocommerce-cart.mim-commerce-ui .cart_totals th,
body.woocommerce-cart.mim-commerce-ui .cart_totals td {
    padding: 15px 0;
    border-bottom: 1px solid var(--mim-border);
}

body.woocommerce-cart.mim-commerce-ui .wc-proceed-to-checkout .checkout-button {
    width: 100%;
    margin: 12px 0 0;
    text-align: center;
}

body.woocommerce-cart.mim-commerce-ui tr:not(.cart_item) td.actions {
    padding: 20px 0 0;
    border: 0;
}

/* MIM Codebereich */
body.mim-commerce-ui .mim-code-box {
    margin: 20px 0;
    padding: 18px;
    border: 1px solid var(--mim-border);
    border-radius: 10px;
    background: var(--mim-white);
}

body.mim-commerce-ui .mim-code-box__heading { display: block; margin-bottom: 4px; }
body.mim-commerce-ui .mim-code-box__description { margin: 0 0 12px; color: var(--mim-muted); }
body.mim-commerce-ui .mim-code-box__toggle { display: none; }
body.mim-commerce-ui .mim-code-box form {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 8px 0;
}
body.mim-commerce-ui .mim-code-box input[name="mim_code"] { min-width: 0; min-height: 48px; flex: 1; }

/* Checkout */
body.woocommerce-checkout.mim-commerce-ui form.checkout {
    display: grid;
    grid-template-columns: minmax(0, 3fr) minmax(340px, 2fr);
    column-gap: 28px;
    row-gap: 0;
    align-items: start;
}

body.woocommerce-checkout.mim-commerce-ui #customer_details {
    grid-column: 1;
    grid-row: 1 / span 2;
    width: auto;
    padding: 30px;
    border: 1px solid var(--mim-border);
    border-radius: 12px;
    background: var(--mim-white);
}

body.woocommerce-checkout.mim-commerce-ui #customer_details .col-1,
body.woocommerce-checkout.mim-commerce-ui #customer_details .col-2 {
    float: none;
    width: 100%;
}

body.woocommerce-checkout.mim-commerce-ui #order_review_heading,
body.woocommerce-checkout.mim-commerce-ui #order_review {
    float: none;
    width: auto;
    grid-column: 2;
}

body.woocommerce-checkout.mim-commerce-ui #order_review_heading { grid-row: 1; }
body.woocommerce-checkout.mim-commerce-ui #order_review { grid-row: 2; }

body.woocommerce-checkout.mim-commerce-ui #order_review_heading {
    margin: 0 0 -12px;
    padding: 28px 28px 0;
    border: 1px solid var(--mim-border);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: var(--mim-surface);
}

body.woocommerce-checkout.mim-commerce-ui #order_review {
    position: sticky;
    top: 118px;
    padding: 22px 28px 28px;
    border: 1px solid var(--mim-border);
    border-top: 0;
    border-radius: 0 0 12px 12px;
    background: var(--mim-surface);
}

/* Einige Theme-/Checkout-Kombinationen geben den Bestellkopf doppelt aus:
 * einmal direkt im Checkout-Formular und einmal innerhalb der Bestellübersicht.
 * In diesem klar erkannten Fall bleibt nur der innere, inhaltlich passende Kopf sichtbar. */
body.woocommerce-checkout.mim-commerce-ui.mim-has-nested-review-heading form.checkout > #order_review_heading {
    display: none;
}

body.woocommerce-checkout.mim-commerce-ui.mim-has-nested-review-heading #order_review {
    grid-row: 1 / span 2;
    padding-top: 28px;
    border-top: 1px solid var(--mim-border);
    border-radius: 12px;
}

body.woocommerce-checkout.mim-commerce-ui.mim-has-nested-review-heading #order_review > #order_review_heading {
    margin: 0 0 20px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
}

body.woocommerce-checkout.mim-commerce-ui .form-row { margin-bottom: 16px; }
body.woocommerce-checkout.mim-commerce-ui .form-row label { margin-bottom: 7px; font-weight: 700; }
body.woocommerce-checkout.mim-commerce-ui .input-text,
body.woocommerce-checkout.mim-commerce-ui select,
body.woocommerce-checkout.mim-commerce-ui textarea,
body.woocommerce-checkout.mim-commerce-ui .select2-selection {
    width: 100%;
    min-height: 48px;
    border: 1px solid #bdbdbd;
    border-radius: 8px;
    background: var(--mim-white);
}

body.woocommerce-checkout.mim-commerce-ui #order_review table.shop_table {
    margin: 0 0 22px;
    border: 0;
    border-collapse: collapse;
}

body.woocommerce-checkout.mim-commerce-ui #order_review table.shop_table th,
body.woocommerce-checkout.mim-commerce-ui #order_review table.shop_table td {
    padding: 13px 4px;
    border-bottom: 1px solid var(--mim-border);
}

body.woocommerce-checkout.mim-commerce-ui #payment {
    margin-top: 18px;
    border-radius: 10px;
    background: transparent;
}

body.woocommerce-checkout.mim-commerce-ui #payment ul.payment_methods {
    padding: 0;
    border: 0;
}

body.woocommerce-checkout.mim-commerce-ui #payment ul.payment_methods > li {
    margin: 0 0 12px;
    padding: 15px;
    border: 2px solid var(--mim-border);
    border-radius: 10px;
    background: var(--mim-white);
}

body.woocommerce-checkout.mim-commerce-ui #payment ul.payment_methods > li:has(input[type="radio"]:checked) {
    border-color: var(--mim-yellow);
    box-shadow: inset 5px 0 0 var(--mim-yellow);
}

body.woocommerce-checkout.mim-commerce-ui #payment .payment_box {
    margin: 14px 0 0;
    padding: 14px;
    border-radius: 8px;
    background: var(--mim-surface);
}

body.woocommerce-checkout.mim-commerce-ui #payment .place-order {
    padding: 18px 0 0;
}

body.woocommerce-checkout.mim-commerce-ui #place_order {
    width: 100%;
    min-height: 56px;
    margin-top: 12px;
}

body.woocommerce-checkout.mim-commerce-ui .woocommerce-terms-and-conditions-wrapper,
body.woocommerce-checkout.mim-commerce-ui .wc-gzd-checkbox-placeholder,
body.woocommerce-checkout.mim-commerce-ui .place-order .form-row {
    font-size: .95rem;
    line-height: 1.5;
}

/* Bestellbestätigung */
body.woocommerce-order-received.mim-commerce-ui .woocommerce-order {
    padding: 28px;
    border: 1px solid var(--mim-border);
    border-radius: 12px;
    background: var(--mim-surface);
}

@media (max-width: 921px) {
    body.mim-commerce-ui .site-content > .ast-container,
    body.mim-commerce-ui .entry-content > .woocommerce { padding-inline: 20px; }

    body.woocommerce-cart.mim-commerce-ui .woocommerce-cart-form,
    body.woocommerce-cart.mim-commerce-ui .cart-collaterals { float: none; width: 100%; }
    body.woocommerce-cart.mim-commerce-ui .cart-collaterals .cart_totals { position: static; }

    body.woocommerce-checkout.mim-commerce-ui form.checkout { display: block; }
    body.woocommerce-checkout.mim-commerce-ui #customer_details,
    body.woocommerce-checkout.mim-commerce-ui #order_review { margin-bottom: 24px; }
    body.woocommerce-checkout.mim-commerce-ui #order_review { position: static; }
}

@media (max-width: 600px) {
    body.mim-commerce-ui .site-content > .ast-container,
    body.mim-commerce-ui .entry-content > .woocommerce { padding-inline: 16px; }

    body.woocommerce-cart.mim-commerce-ui table.shop_table thead { display: none; }
    body.woocommerce-cart.mim-commerce-ui table.shop_table,
    body.woocommerce-cart.mim-commerce-ui table.shop_table tbody,
    body.woocommerce-cart.mim-commerce-ui table.shop_table tr.cart_item { display: block; width: 100%; }
    body.woocommerce-cart.mim-commerce-ui table.shop_table tr.cart_item {
        position: relative;
        min-height: 116px;
        margin-bottom: 16px;
        padding: 14px 14px 14px 108px;
        border-radius: 10px;
    }
    body.woocommerce-cart.mim-commerce-ui table.shop_table tr.cart_item td {
        display: block;
        width: 100%;
        padding: 4px 0;
        text-align: left !important;
        background: transparent;
    }
    body.woocommerce-cart.mim-commerce-ui table.shop_table tr.cart_item td::before { display: none; }
    body.woocommerce-cart.mim-commerce-ui td.product-thumbnail {
        position: absolute;
        top: 14px;
        left: 14px;
        width: 80px !important;
        padding: 0 !important;
    }
    body.woocommerce-cart.mim-commerce-ui td.product-thumbnail img { width: 80px; height: 80px; }
    body.woocommerce-cart.mim-commerce-ui td.product-remove {
        position: absolute;
        right: 4px;
        bottom: 4px;
        width: 44px !important;
    }
    body.woocommerce-cart.mim-commerce-ui td.product-price,
    body.woocommerce-cart.mim-commerce-ui td.product-quantity,
    body.woocommerce-cart.mim-commerce-ui td.product-subtotal { display: inline-block !important; width: auto !important; margin-right: 12px; }
    body.woocommerce-cart.mim-commerce-ui tr:not(.cart_item) td.actions .coupon { width: 100%; }
    body.woocommerce-cart.mim-commerce-ui tr:not(.cart_item) td.actions .coupon input,
    body.woocommerce-cart.mim-commerce-ui tr:not(.cart_item) td.actions .coupon button { width: 100% !important; margin: 0 0 12px !important; }

    body.mim-commerce-ui .mim-code-box__heading,
    body.mim-commerce-ui .mim-code-box__description { display: none; }
    body.mim-commerce-ui .mim-code-box__toggle {
        display: block;
        width: 100%;
        min-height: 48px;
        padding: 10px 0;
        border: 0;
        background: transparent;
        color: var(--mim-black);
        font-weight: 800;
        text-align: left;
    }
    body.mim-commerce-ui .mim-code-box__content { display: none; }
    body.mim-commerce-ui .mim-code-box.is-open .mim-code-box__content { display: block; }
    body.mim-commerce-ui .mim-code-box form { display: block; }
    body.mim-commerce-ui .mim-code-box input[name="mim_code"],
    body.mim-commerce-ui .mim-code-box button.button { width: 100%; margin: 0 0 10px; }

    body.woocommerce-checkout.mim-commerce-ui #customer_details,
    body.woocommerce-checkout.mim-commerce-ui #order_review,
    body.woocommerce-order-received.mim-commerce-ui .woocommerce-order { padding: 16px; border-radius: 10px; }
    body.woocommerce-checkout.mim-commerce-ui #order_review_heading { padding: 16px 16px 0; }
    body.woocommerce-checkout.mim-commerce-ui.mim-has-nested-review-heading #order_review > #order_review_heading {
        margin-bottom: 16px;
        padding: 0;
    }
    body.woocommerce-checkout.mim-commerce-ui .form-row,
    body.woocommerce-checkout.mim-commerce-ui .form-row-first,
    body.woocommerce-checkout.mim-commerce-ui .form-row-last { float: none; width: 100%; }
    body.woocommerce-checkout.mim-commerce-ui #payment ul.payment_methods > li { padding: 14px; }
    body.mim-commerce-ui .woocommerce button.button,
    body.mim-commerce-ui .woocommerce a.button,
    body.mim-commerce-ui .woocommerce input.button { width: 100%; min-height: 52px; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
    body.mim-commerce-ui *, body.mim-commerce-ui *::before, body.mim-commerce-ui *::after {
        scroll-behavior: auto !important;
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
