/**
 * WM Dynamic Woo – Frontend-styling
 * Ladda enbart på WooCommerce-sidor (hanteras i price-logic.php).
 */

/* ── Wrapper ────────────────────────────────────────────────────────────────── */
.wmdw-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
    line-height: 1.4;
}

.wmdw-wrap .wmdw-regular,
.wmdw-wrap .wmdw-current {
    display: block;
}

.wc-block-components-product-price:has(.wmdw-wrap),
.wc-block-components-product-price:has(.wmdw-regular) {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* ── Aktuellt pris (inköpspris för kunden) ──────────────────────────────────── */
.wmdw-current {
    font-weight: 700;
    text-decoration: none;
    color: #a81000;
    font-size: var(--wp--preset--font-size--size-4);
}

/* ── Ordinarie pris (alltid överkryssat) ────────────────────────────────────── */
.wmdw-regular {
    color: #999;
    text-decoration: line-through;
    font-size: var(--wp--preset--font-size--size-2);
}

/* ── Etiketter (rollnamn) ───────────────────────────────────────────────────── */
.wmdw-badge {
    display: inline-block;
    width: 100%;
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #555;
    margin-bottom: 1px;
}

/* Rollspecifik badge – litet färgat "chip" */
.wmdw-wrap--role .wmdw-badge {
    display: inline-block;
    width: auto;
    padding: 1px 7px;
    border-radius: 3px;
    background: #2c3e50;
    color: #fff;
    font-size: 0.65em;
    vertical-align: middle;
    margin-right: 4px;
}

/* ── Kundvagn & kassa – linjera upp snyggt i tabellen ───────────────────────── */
td.product-price .wmdw-wrap,
td.product-subtotal .wmdw-wrap {
    flex-direction: column;
    gap: 1px;
}

/* ── Responsiv justering för mobil ─────────────────────────────────────────── */
@media (max-width: 600px) {
    .wmdw-current {
        font-size: var(--wp--preset--font-size--size-3);
    }
}

/* ── Customer Wishlist ──────────────────────────────────────────────────────── */
li.product,
.wc-block-grid__product,
.wmdw-has-wishlist {
    position: relative;
}

.wmdw-wishlist-heart {
    position: absolute;
    top: 5px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    z-index: 5;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: #555;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    transition: color 0.15s ease, transform 0.15s ease;
}

.wmdw-wishlist-heart:hover,
.wmdw-wishlist-heart:focus-visible {
    color: #c0392b;
    transform: translateX(-50%) scale(1.05);
    outline: none;
}

.wmdw-wishlist-heart.is-active {
    color: #c0392b;
}

.wmdw-wishlist-heart:disabled {
    opacity: 0.6;
    cursor: wait;
}

.wmdw-heart-icon {
    width: 20px;
    height: 20px;
    display: block;
}

.wmdw-wishlist-heart.is-active .wmdw-heart-icon path {
    fill: currentColor;
}

.wmdw-wishlist-empty {
    margin: 1rem 0 2rem;
}

.wmdw-wishlist-page .products {
    margin-top: 1rem;
}

body.woocommerce-account .woocommerce-MyAccount-content {
    float: none;
    width: 100%;
}

body.woocommerce-cart .wp-block-post-title {
    display: none;
}

body.wmdw-account-wishlist .wmdw-wishlist-page ul.products li.product {
    align-items: center;
    display: flex;
    flex-direction: column;
}

body.wmdw-account-wishlist .woocommerce ul.products li.product .button {
    display: inline-block;
    margin: 0;
    font-size: 13px;
    padding: 2px 4px;
}

/* ── Header shopping cart ───────────────────────────────────────────────────── */
.wmdw-shopping-cart-link[hidden] {
    display: none !important;
}

.wmdw-shopping-cart-link {
    display: inline-grid;
    place-items: center;
    padding: 0 10px;
    transition: background 0.6s, color 0.4s;
}

.wmdw-shopping-cart-icon,
.wmdw-shopping-cart-count {
    grid-area: 1 / 1;
}

.wmdw-shopping-cart-icon {
    width: 43px;
    height: 43px;
}

.wmdw-shopping-cart-count {
    padding: 3px 5px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: bolder;
    line-height: 10px;
    margin: 0 0 6px 6px;
}

.wmdw-shopping-cart-count.is-empty {
    visibility: hidden;
}

/* ── WM-Menu logo payoff (styling — inte i wm-menu) ───────────────────────── */
.wm-menu-logo-top__payoff {
    margin: 0;
}

@media (max-width: 1000px) {
    .wm-menu-logo-at-top .wm-menu-logo-top__payoff {
        display: none !important;
    }
}

/* ── Butikskatalog ─────────────────────────────────────────────────────────── */
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .woocommerce-result-count,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .woocommerce.wc-block-product-results-count,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-results-count {
    display: none !important;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .woocommerce-ordering,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .woocommerce-ordering select,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wmdw-shop-category-filter {
    font-size: var(--wp--preset--font-size--size-1);
}

.wmdw-shop-toolbar {
    align-items: center;
    display: flex;
    justify-content: space-around;
    padding: 4px;
    position: sticky;
    top: 0;
    z-index: 5;
}

.wmdw-shop-toolbar .wc-block-catalog-sorting {
    margin: 0;
}

.wmdw-shop-category-filter-wrap {
    display: flex;
    align-items: center;
}

.wmdw-shop-category-filter {
    cursor: pointer;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template.is-flex-container,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) ul[data-block-name="woocommerce/product-template"] {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 1024px) {
    :is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template.is-flex-container,
    :is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) ul[data-block-name="woocommerce/product-template"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 782px) {
    :is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template.is-flex-container,
    :is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) ul[data-block-name="woocommerce/product-template"] {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    :is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template.is-flex-container,
    :is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) ul[data-block-name="woocommerce/product-template"] {
        grid-template-columns: minmax(0, 1fr);
    }
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template.is-flex-container > .wc-block-product {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    background-color: var(--wp--preset--color--light-1);
    padding: 10px;
    border-radius: 6px;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wc-block-product > :not(:last-child) {
    margin: 0;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wp-block-post-title {
    line-height: 1;
    text-align: center;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wp-block-woocommerce-product-price {
    margin: 0;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wc-block-components-product-price:has(.wmdw-wrap),
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wc-block-components-product-price:has(.wmdw-regular) {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wmdw-wrap {
    align-items: center;
    text-align: center;
    width: 100%;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wc-block-components-product-price del,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wc-block-components-product-price .wmdw-regular,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wc-block-components-product-price ins,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wc-block-components-product-price .wmdw-current {
    display: block;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wp-block-woocommerce-product-button,
:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wp-block-button.wc-block-components-product-button {
    margin-top: auto;
    padding-top: 2px;
}

:is(body.woocommerce-shop, body.tax-product_cat, body.tax-product_tag, body.wmdw-product-catalog) .wc-block-product-template .wp-block-woocommerce-product-button .wp-element-button {
    font-size: 13px;
    line-height: 28px;
    padding: 2px 6px;
    border-radius: 4px;
}

/* ── Multi-buy (antal + lägg i varukorgen) ─────────────────────────────────── */
body.wmdw-product-catalog .wp-block-woocommerce-product-button {
    width: 100%;
}

body.wmdw-product-catalog .wmdw-loop-cart {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
}

body.wmdw-product-catalog .wmdw-loop-cart .quantity {
    margin-top: -3px;
}

body.wmdw-product-catalog .wmdw-loop-cart .qty {
    width: 45px;
    text-align: end;
    font-size: 11px;
    border-radius: 4px;
    border: 1px solid;
    line-height: 28px;
}

/* WooCommerce lägger till "Visa varukorg" efter ajax – dölj i butiksrutnätet */
body.wmdw-product-catalog .added_to_cart,
body.wmdw-product-catalog a.added_to_cart.wc-forward {
    display: none !important;
}

/* ── Enskild produkt ─────────────────────────────────────────────────────────── */
body.single-product .wmdw-wrap {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    font-size: var(--wp--preset--font-size--size-3);
}

body.single-product .wp-block-woocommerce-product-price {
    margin-block-start: 0;
}

body.single-product .wc-block-add-to-cart-form form {
    padding: 0;
}

body.single-product .wc-block-add-to-cart-form .single_add_to_cart_button {
    font-size: var(--wp--preset--font-size--size-2);
    padding: 4px 8px;
    border-radius: 6px;
}

body.single-product .wp-block-woocommerce-product-meta {
    font-size: var(--wp--preset--font-size--size-1);
}

/* ── EAN-streckkod ───────────────────────────────────────────────────────────── */
.wmdw-ean {
    margin-block-start: 0;
}

.wmdw-ean-barcode {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    max-width: 170px;
}

.wmdw-ean-barcode svg {
    display: block;
    width: 100%;
    height: auto;
}

.wmdw-ean-number {
    font-size: var(--wp--preset--font-size--size-1);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}
