/*
 * Compare page — dense side-by-side product comparison.
 */

body.mme-compare-page {
    --mme-cmp-accent: var(--wd-primary-color, var(--color-primary, #c4a35a));
    --mme-cmp-border: #e5e7eb;
    --mme-cmp-muted: #6b7280;
    --mme-cmp-text: #111827;
    --mme-cmp-surface: #fff;
    --mme-cmp-row: #f9fafb;
    --mme-cmp-label-w: 160px;
    background: #f3f4f6;
}

body.mme-compare-page .main-page-wrapper,
body.mme-compare-page .site-content,
body.mme-compare-page .wd-content-area,
body.mme-compare-page .entry-header,
body.mme-compare-page .page-title,
body.mme-compare-page .title-wrapper,
body.mme-compare-page .wd-page-title {
    background: transparent;
}

/* Hide theme page title — we render our own head */
body.mme-compare-page .entry-header,
body.mme-compare-page .page-title:not(.mme-compare__title),
body.mme-compare-page .wd-page-title,
body.mme-compare-page .title-wrapper {
    display: none !important;
}

body.mme-compare-page .entry-content {
    max-width: var(--wd-container-w, 1222px);
    margin-inline: auto;
    padding: 20px 16px 56px;
}

.mme-compare__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 14px;
    margin: 0 0 16px;
}

.mme-compare__title {
    margin: 0;
    color: var(--mme-cmp-text);
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.mme-compare__meta {
    margin: 0;
    color: var(--mme-cmp-muted);
    font-size: 0.875rem;
    font-weight: 600;
}

/* Kill Woodmart category chrome if it ever leaks through */
body.mme-compare-page .wd-compare-header {
    display: none !important;
}

/* Table shell */
body.mme-compare-page .mme-compare .wd-compare-table,
body.mme-compare-page .entry-content > .wd-compare-table {
    display: block !important;
    width: 100%;
    margin: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--mme-cmp-border);
    border-radius: 12px;
    background: var(--mme-cmp-surface);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
    line-height: inherit;
    word-break: break-word;
    /* Keep Woodmart vars high enough to avoid (td-col - 2) = 0 blowups */
    --wd-comp-th-w: var(--mme-cmp-label-w);
    --wd-comp-td-col: 5;
}

body.mme-compare-page .wd-compare-table tbody {
    display: block !important;
    width: 100%;
    min-width: 0;
}

body.mme-compare-page .wd-compare-table tr {
    display: flex !important;
    align-items: stretch;
    width: 100%;
    margin: 0;
    border-bottom: 1px solid var(--mme-cmp-border);
}

body.mme-compare-page .wd-compare-table tr:last-child {
    border-bottom: 0;
}

body.mme-compare-page .wd-compare-table tr:nth-child(even):not(.compare-basic) {
    background: var(--mme-cmp-row);
}

body.mme-compare-page .wd-compare-table :is(th, td) {
    display: flex !important;
    flex-direction: column;
    justify-content: flex-start;
    gap: 8px;
    padding: 14px 16px !important;
    border: 0 !important;
    border-inline-end: 1px solid var(--mme-cmp-border) !important;
    box-sizing: border-box;
}

body.mme-compare-page .wd-compare-table :is(th, td):last-child {
    border-inline-end: 0 !important;
}

/* Attribute label column */
body.mme-compare-page .wd-compare-table th {
    flex: 0 0 var(--mme-cmp-label-w) !important;
    width: var(--mme-cmp-label-w) !important;
    max-width: var(--mme-cmp-label-w) !important;
    min-width: var(--mme-cmp-label-w) !important;
    justify-content: center;
    color: var(--mme-cmp-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    background: #f3f4f6;
}

body.mme-compare-page .wd-compare-table .compare-basic th {
    background: #f3f4f6;
}

/* Product columns — equal share; override Woodmart flex/max-width math */
body.mme-compare-page .wd-compare-table td {
    flex: 1 1 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    color: var(--mme-cmp-text);
    font-size: 0.9375rem;
    line-height: 1.45;
}

body.mme-compare-page .wd-compare-table td > * {
    margin-bottom: 0;
}

body.mme-compare-page .wd-compare-table td:before {
    content: attr(data-title);
    display: none;
    margin-bottom: 8px;
    color: var(--mme-cmp-muted);
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Product card column (basic row) */
body.mme-compare-page .wd-compare-table .compare-basic td {
    align-items: stretch;
    padding: 16px !important;
    background: #fff;
}

body.mme-compare-page .wd-compare-table .compare-basic th {
    justify-content: flex-start;
    padding-top: 22px !important;
    background: #f3f4f6;
}

body.mme-compare-page .wd-compare-table .compare-basic th::after {
    content: 'Product';
}

body.mme-compare-page .wd-compare-remove-action {
    align-self: flex-start;
    margin: 0 0 8px;
}

body.mme-compare-page .wd-compare-remove {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 8px;
    border: 1px solid var(--mme-cmp-border);
    border-radius: 6px;
    background: #fff;
    color: var(--mme-cmp-muted) !important;
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none !important;
    transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

body.mme-compare-page .wd-compare-remove:hover,
body.mme-compare-page .wd-compare-remove:focus-visible {
    color: #b42318 !important;
    border-color: #f3c0c0;
    background: #fef2f2;
}

body.mme-compare-page .wd-compare-table .product-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 180px;
    height: 180px;
    margin: 0 auto 12px;
    aspect-ratio: auto;
    border: 1px solid var(--mme-cmp-border);
    border-radius: 10px;
    overflow: hidden;
    background: #f8f9fb;
}

body.mme-compare-page .wd-compare-table .product-image img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
    border-radius: 0;
}

body.mme-compare-page .wd-compare-table .wd-entities-title,
body.mme-compare-page .wd-compare-table .compare-basic a.wd-entities-title {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.7em;
    color: var(--mme-cmp-text) !important;
    font-size: 0.9375rem;
    font-weight: 700;
    line-height: 1.35;
    text-decoration: none !important;
    text-align: start;
    transition: color 0.15s ease;
}

body.mme-compare-page .wd-compare-table .wd-entities-title:hover,
body.mme-compare-page .wd-compare-table .wd-entities-title:focus-visible {
    color: var(--mme-cmp-accent) !important;
}

body.mme-compare-page .wd-compare-table .star-rating {
    margin-top: 2px;
}

body.mme-compare-page .wd-compare-table .price,
body.mme-compare-page .wd-compare-table .amount {
    color: var(--mme-cmp-text);
    font-size: 1.05rem;
    font-weight: 700;
}

body.mme-compare-page .wd-compare-table :is(.button, .added_to_cart, .product_type_simple, .product_type_variable) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: none;
    min-height: 40px !important;
    margin-top: 4px;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    background-color: var(--mme-cmp-accent) !important;
    box-shadow: none !important;
    color: #fff !important;
    font-size: 0.8125rem !important;
    font-weight: 700 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}

body.mme-compare-page .wd-compare-table :is(.button, .added_to_cart):hover,
body.mme-compare-page .wd-compare-table :is(.button, .added_to_cart):focus-visible {
    filter: brightness(0.96);
}

body.mme-compare-page .wd-compare-brand img {
    max-width: min(100%, 100px);
    height: auto;
}

/* Spec rows denser */
body.mme-compare-page .wd-compare-table tr:not(.compare-basic) td {
    font-size: 0.875rem;
}

body.mme-compare-page .wd-compare-table .compare-description td,
body.mme-compare-page .wd-compare-table .compare-description .compare-value {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--mme-cmp-muted);
    text-align: start;
    align-items: flex-start;
}

body.mme-compare-page .wd-compare-table .compare-availability .stock {
    margin: 0;
    font-weight: 600;
}

body.mme-compare-page .wd-compare-table .compare-mme-brand td,
body.mme-compare-page .wd-compare-table .compare-mme-categories td,
body.mme-compare-page .wd-compare-table .compare-product_brand td {
    font-weight: 600;
    color: var(--mme-cmp-text);
}

/* Empty state */
body.mme-compare-page .wd-empty-compare {
    margin: 12px auto 0;
    padding: 48px 24px;
    max-width: 480px;
    border: 1px solid var(--mme-cmp-border);
    border-radius: 14px;
    background: var(--mme-cmp-surface);
    box-shadow: 0 4px 18px rgba(15, 23, 42, 0.05);
    text-align: center;
}

body.mme-compare-page .wd-empty-compare .wd-empty-block-title {
    margin: 0 0 8px;
    color: var(--mme-cmp-text);
    font-size: 1.25rem;
    font-weight: 700;
}

body.mme-compare-page .wd-empty-compare .wd-empty-block-text {
    margin: 0 0 20px;
    color: var(--mme-cmp-muted);
    font-size: 0.9375rem;
    line-height: 1.55;
}

body.mme-compare-page .wd-empty-compare .wd-empty-block-btn {
    min-height: 44px;
    padding: 0 20px;
    border-radius: 8px;
    background: var(--mme-cmp-accent) !important;
    box-shadow: none !important;
    font-weight: 700;
    text-transform: none;
}

body.mme-compare-page .wd-loader-overlay {
    border-radius: 12px;
}

@media (max-width: 768.98px) {
    body.mme-compare-page {
        --mme-cmp-label-w: 0px;
    }

    body.mme-compare-page .entry-content {
        padding: 14px 12px 40px;
    }

    body.mme-compare-page .mme-compare__title {
        font-size: 1.25rem;
    }

    body.mme-compare-page .wd-compare-table tbody {
        min-width: calc(var(--mme-cmp-cols, 2) * 240px);
    }

    body.mme-compare-page .wd-compare-table th {
        display: none !important;
    }

    body.mme-compare-page .wd-compare-table td {
        flex: 0 0 75% !important;
        min-width: 240px !important;
        max-width: none !important;
    }

    body.mme-compare-page .wd-compare-table td:before {
        display: block;
    }

    body.mme-compare-page .wd-compare-table .compare-basic td:before {
        display: none;
    }

    body.mme-compare-page .wd-compare-table .product-image {
        max-width: 180px;
    }
}

@media (min-width: 769px) {
    body.mme-compare-page .mme-compare[data-mme-compare-count="1"] .wd-compare-table td {
        flex: 0 1 360px !important;
        max-width: 360px !important;
    }
}
