/* ppproductcompare - Product Comparison Module */

/* ===== Compare Button (base) ===== */
.ppcompare-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    border: none;
    background: none;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}
.ppcompare-btn:hover {
    color: var(--color-primary, #2563eb);
}
.ppcompare-btn--active {
    color: var(--color-primary, #2563eb);
}

/* ===== Product page: icon matches heart/favorite button ===== */
.ppcompare-btn--product {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    min-width: 48px;
    background-color: transparent;
    border: 1px solid var(--color-border, #d1d5db);
    border-radius: var(--border-radius-md, 8px);
    color: #374151;
}
.ppcompare-btn--product:hover {
    border-color: var(--color-primary, #2563eb);
    color: var(--color-primary, #2563eb);
}
.ppcompare-btn--product.ppcompare-btn--active {
    border-color: var(--color-primary, #2563eb);
    background: var(--color-primary, #2563eb);
    color: #fff;
}
.ppcompare-btn--product.ppcompare-btn--active:hover {
    opacity: 0.85;
}

/* ===== Listing: positioned below favorite icon ===== */
.ppcompare-btn--listing {
    position: absolute;
    top: 48px;
    right: 12px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    z-index: 5;
    color: var(--color-text-primary, #374151);
}
.ppcompare-btn--listing:hover {
    background-color: rgba(255, 255, 255, 0.8);
    transform: scale(1.1);
    color: var(--color-primary, #2563eb);
}
.ppcompare-btn--listing.ppcompare-btn--active {
    color: var(--color-primary, #2563eb);
    background: none;
}
.ppcompare-btn--listing .ppcompare-btn__icon {
    width: 18px;
    height: 18px;
}
.ppcompare-btn--listing .ppcompare-btn__tooltip {
    left: auto;
    right: calc(100% + 8px);
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
}
.ppcompare-btn--listing .ppcompare-btn__tooltip::after {
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-left-color: #1f2937;
    border-top-color: transparent;
}

/* ===== Icon ===== */
.ppcompare-btn__icon {
    flex-shrink: 0;
}

/* ===== Tooltip on hover ===== */
.ppcompare-btn__tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: #1f2937;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: 6px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    z-index: 10;
}
.ppcompare-btn__tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}
.ppcompare-btn:hover .ppcompare-btn__tooltip {
    opacity: 1;
    visibility: visible;
}

/* ===== Header Icon ===== */
.ppcompare-header {
    position: relative;
    display: inline-flex;
    align-items: center;
    color: inherit;
    text-decoration: none;
    padding: 4px;
}
.ppcompare-header:hover {
    opacity: 0.8;
}
.ppcompare-header__count {
    position: absolute;
    top: -4px;
    right: -8px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--color-primary, #2563eb);
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.ppcompare-header__count--hidden {
    opacity: 0;
    transform: scale(0);
}

/* ===== Toast notification (after adding to compare) — matches ppwishlist toast ===== */
.ppcompare-toast-container {
    position: fixed;
    bottom: 0;
    right: 0;
    padding: 1rem;
    z-index: 1100;
}
.ppcompare-toast {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    max-width: 400px;
}
.ppcompare-toast--visible {
    opacity: 1;
    transform: translateY(0);
}
.ppcompare-toast__inner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    width: 100%;
}
.ppcompare-toast__icon {
    flex-shrink: 0;
    color: var(--color-primary, #2563eb);
}
.ppcompare-toast__message {
    flex: 1;
    font-size: 14px;
    color: #374151;
    line-height: 1.4;
}
.ppcompare-toast__message a {
    color: var(--color-primary, #2563eb);
    font-weight: 500;
    text-decoration: none;
}
.ppcompare-toast__message a:hover {
    text-decoration: underline;
}
.ppcompare-toast__close {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #9ca3af;
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s ease;
    line-height: 1;
}
.ppcompare-toast__close:hover {
    color: #374151;
}

/* ===== Compare Page ===== */
.ppcompare-page {
    padding: 0 0 40px;
}
.ppcompare-page__nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.ppcompare-page__back-link,
.ppcompare-page__category-link {
    color: var(--color-primary, #2563eb);
    text-decoration: none;
    font-size: 14px;
}
.ppcompare-page__back-link:hover,
.ppcompare-page__category-link:hover {
    text-decoration: underline;
}
.ppcompare-page__empty {
    text-align: center;
    padding: 60px 20px;
    color: #6b7280;
}
.ppcompare-page__empty svg {
    margin-bottom: 16px;
}
.ppcompare-page__empty p {
    margin: 4px 0;
}

/* ===== Overview - Category Blocks ===== */
.ppcompare-overview {
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.ppcompare-category__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}
.ppcompare-category__name {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #111827;
}
.ppcompare-category__name-link {
    color: inherit;
    text-decoration: none;
}
.ppcompare-category__name-link:hover {
    color: var(--color-primary, #2563eb);
}
.ppcompare-category__count {
    font-weight: 400;
    color: #6b7280;
    font-size: 16px;
}
.ppcompare-category__actions {
    display: flex;
    gap: 12px;
    align-items: center;
}
.ppcompare-category__compare-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 20px;
    background: var(--color-primary, #2563eb);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}
.ppcompare-category__compare-btn:hover {
    background: var(--color-primary-hover, #1d4ed8);
    color: #fff;
}
.ppcompare-category__clear {
    padding: 8px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    color: #6b7280;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}
.ppcompare-category__clear:hover {
    border-color: #ef4444;
    color: #ef4444;
}
.ppcompare-category__products {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

/* ===== Product Card (overview) ===== */
.ppcompare-product {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
    transition: box-shadow 0.2s ease;
}
.ppcompare-product:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.ppcompare-product__image-link {
    display: block;
    margin-bottom: 12px;
}
.ppcompare-product__image {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    object-fit: contain;
    border-radius: 4px;
}
.ppcompare-product__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex-grow: 1;
}
.ppcompare-product__name {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    text-decoration: none;
    line-height: 1.3;
}
.ppcompare-product__name:hover {
    color: var(--color-primary, #2563eb);
}
.ppcompare-product__price {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
}
.ppcompare-product__remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: #f3f4f6;
    color: #6b7280;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}
.ppcompare-product__remove:hover {
    background: #fecaca;
    color: #dc2626;
}

/* ===== Comparison Table ===== */
.ppcompare-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
}
.ppcompare-table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    table-layout: fixed;
}
.ppcompare-table__label-col {
    width: 160px;
    background: #f9fafb;
}
.ppcompare-table__product-col {
    /* Equal width: remaining space divided equally among product columns */
}
.ppcompare-table__product-header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 16px;
    text-align: center;
}
.ppcompare-table__remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    border-radius: 50%;
    background: #fff;
    color: #6b7280;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}
.ppcompare-table__remove:hover {
    border-color: #ef4444;
    background: #fef2f2;
    color: #dc2626;
}
.ppcompare-table__image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border-radius: 4px;
}
.ppcompare-table__product-name {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    line-height: 1.3;
}
.ppcompare-table__product-name:hover {
    color: var(--color-primary, #2563eb);
}
.ppcompare-table td,
.ppcompare-table th {
    border-bottom: 1px solid #e5e7eb;
}
.ppcompare-table__label {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
    background: #f9fafb;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: top;
}
.ppcompare-table__value {
    padding: 12px 16px;
    font-size: 14px;
    color: #374151;
    vertical-align: top;
    text-align: center;
}
.ppcompare-table__value--price {
    font-weight: 700;
    font-size: 16px;
    color: #111827;
}
.ppcompare-table__value--description {
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}
.ppcompare-table__value--description table {
    width: 100% !important;
    table-layout: fixed;
    word-wrap: break-word;
    border-collapse: collapse;
}
.ppcompare-table__value--description td,
.ppcompare-table__value--description th {
    width: auto !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 4px 6px;
    font-size: 12px;
}
.ppcompare-table__value--description * {
    max-width: 100% !important;
}
.ppcompare-table tbody tr:last-child td,
.ppcompare-table tbody tr:last-child th {
    border-bottom: none;
}
.ppcompare-table tbody tr:nth-child(even) td {
    background: #fafafa;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .ppcompare-category__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .ppcompare-category__products {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .ppcompare-table__label-col {
        width: 120px;
        min-width: 100px;
    }
    .ppcompare-table__label {
        font-size: 12px;
        padding: 10px 12px;
    }
    .ppcompare-table__value {
        padding: 10px 12px;
        font-size: 13px;
    }
    .ppcompare-table__image {
        width: 80px;
        height: 80px;
    }
    .ppcompare-btn--listing {
        top: 38px;
        right: 8px;
        width: 28px;
        height: 28px;
    }
    .ppcompare-btn--listing .ppcompare-btn__icon {
        width: 16px;
        height: 16px;
    }
    .ppcompare-btn__tooltip {
        display: none;
    }
}
