/* Product WP Frontend Styles */

/* Grid Layout */
.product-wp-grid {
    display: grid;
    gap: 1rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.product-wp-grid.cols-2 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.product-wp-grid.cols-3 {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.product-wp-grid.cols-4 {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.product-wp-grid.cols-5 {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

/* Product Card */
.product-wp-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    transition: box-shadow 0.3s ease;
    text-decoration: none;
    color: inherit;
}

.product-wp-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Product Image */
.product-wp-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
}

.product-wp-image.size-small {
    width: 60px;
    height: 60px;
}

.product-wp-image.size-medium {
    width: 80px;
    height: 80px;
}

.product-wp-image.size-large {
    width: 100px;
    height: 100px;
}

.product-wp-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Product Content */
.product-wp-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.product-wp-title {
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
    margin: 0;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-wp-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #212529;
    margin: 0.25rem 0;
}

.product-wp-stock {
    font-size: 0.875rem;
    color: #6c757d;
    margin-left: 0.5rem;
}

.product-wp-merchant {
    font-size: 0.8125rem;
    color: #495057;
    margin: 0.25rem 0;
    font-weight: 500;
}

.product-wp-source {
    font-size: 0.75rem;
    color: #6c757d;
    text-transform: capitalize;
}

.product-wp-button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
    margin-top: 0.5rem;
    align-self: flex-start;
}

.product-wp-button:hover {
    background: #0b5ed7;
    color: #fff;
}

.product-wp-button::before {
    content: '›';
    font-size: 1.25rem;
    font-weight: 700;
}

/* List Layout */
.product-wp-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.product-wp-list .product-wp-card {
    padding: 0.875rem 1rem;
}

/* Carousel Layout */
.product-wp-carousel {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    padding: 0.5rem 0;
}

.product-wp-carousel .product-wp-card {
    flex: 0 0 320px;
    scroll-snap-align: start;
    flex-direction: column;
    text-align: center;
}

.product-wp-carousel .product-wp-image {
    width: 120px;
    height: 120px;
    margin: 0 auto;
}

.product-wp-carousel .product-wp-content {
    align-items: center;
}

.product-wp-carousel .product-wp-button {
    align-self: center;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .product-wp-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem;
    }

    .product-wp-card {
        padding: 0.875rem;
        gap: 0.875rem;
    }

    .product-wp-image.size-medium,
    .product-wp-image.size-large {
        width: 70px;
        height: 70px;
    }

    .product-wp-title {
        font-size: 0.9375rem;
    }

    .product-wp-price {
        font-size: 1rem;
    }

    .product-wp-button {
        padding: 0.4375rem 0.875rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .product-wp-card {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .product-wp-image {
        width: 60px !important;
        height: 60px !important;
    }

    .product-wp-title {
        font-size: 0.875rem;
    }

    .product-wp-button {
        width: 100%;
        justify-content: center;
    }
}

/* Empty State */
.product-wp-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

/* Single Product Styles */

/* Card Style */
.product-wp-single-card {
    display: flex;
    flex-direction: column;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.product-wp-single-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.product-wp-single-image {
    width: 100%;
    height: 280px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-wp-single-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-wp-single-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.product-wp-single-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
    margin: 0;
    line-height: 1.3;
}

.product-wp-single-description {
    font-size: 0.9375rem;
    color: #6c757d;
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-wp-single-price {
    font-size: 1.5rem;
    font-weight: 700;
    color: #212529;
}

.product-wp-single-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 1.5rem;
    background: #d63638;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.product-wp-single-button:hover {
    background: #b32d2e;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(214, 54, 56, 0.3);
}

/* Inline Style */
.product-wp-single-inline {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
    margin-bottom: 10px;
}

.product-wp-single-inline:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-wp-single-inline-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 6px;
    object-fit: cover;
    background: #f8f9fa;
}

.product-wp-single-inline-image.size-small {
    width: 60px;
    height: 60px;
}

.product-wp-single-inline-image.size-medium {
    width: 80px;
    height: 80px;
}

.product-wp-single-inline-image.size-large {
    width: 100px;
    height: 100px;
}

.product-wp-single-inline-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.product-wp-single-inline-title {
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
}

.product-wp-single-inline-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #d63638;
}

.product-wp-single-inline-button {
    flex-shrink: 0;
    padding: 0.625rem 1.25rem;
    margin-top: 0;
}

/* Banner Style */
.product-wp-single-banner {
    position: relative;
    min-height: 400px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 12px;
    overflow: hidden;
}

.product-wp-single-banner-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.7));
    display: flex;
    align-items: flex-end;
    padding: 2rem;
}

.product-wp-single-banner-content {
    color: #fff;
    max-width: 600px;
}

.product-wp-single-banner-title {
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    margin: 0 0 1rem 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.product-wp-single-banner-description {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    margin: 0 0 1rem 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-wp-single-banner-price {
    font-size: 1.75rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.product-wp-single-banner-button {
    background: #fff;
    color: #212529;
}

.product-wp-single-banner-button:hover {
    background: #f8f9fa;
    color: #212529;
}

/* Mobile Responsive for Single Products */
@media (max-width: 768px) {
    .product-wp-single-card {
        max-width: 100%;
    }

    .product-wp-single-image {
        height: 220px;
    }

    .product-wp-single-title {
        font-size: 1.125rem;
    }

    .product-wp-single-description {
        font-size: 0.875rem;
    }

    .product-wp-single-price {
        font-size: 1.25rem;
    }

    .product-wp-single-inline {
        flex-direction: column;
        text-align: center;
    }

    .product-wp-single-inline-image {
        width: 120px !important;
        height: 120px !important;
    }

    .product-wp-single-inline-button {
        width: 100%;
    }

    .product-wp-single-banner {
        min-height: 300px;
    }

    .product-wp-single-banner-overlay {
        padding: 1.5rem;
    }

    .product-wp-single-banner-title {
        font-size: 1.5rem;
    }

    .product-wp-single-banner-price {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .product-wp-single-content {
        padding: 1rem;
    }

    .product-wp-single-button {
        width: 100%;
    }

    .product-wp-single-banner {
        min-height: 250px;
    }

    .product-wp-single-banner-overlay {
        padding: 1rem;
    }
}

/* Top Heavy Layout */
.product-wp-top-heavy {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 2rem;
}

/* Header */
.product-wp-top-heavy-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.product-wp-top-heavy-image {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 6px;
    overflow: hidden;
}

.product-wp-top-heavy-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-wp-top-heavy-title h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #212529;
    margin: 0;
    line-height: 1.3;
}

/* List Rows */
.product-wp-top-heavy-list {
    display: flex;
    flex-direction: column;
}

.product-wp-top-heavy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid #f1f3f5;
    transition: background 0.2s ease;
}

.product-wp-top-heavy-row:last-child {
    border-bottom: none;
}

.product-wp-top-heavy-row:hover {
    background: #f8f9fa;
}

.product-wp-top-heavy-merchant {
    flex-shrink: 0;
    width: 120px;
    display: flex;
    align-items: center;
}

.product-wp-top-heavy-merchant img {
    max-width: 100%;
    max-height: 40px;
    object-fit: contain;
    display: block;
}

.product-wp-top-heavy-merchant-text {
    font-weight: 600;
    color: #495057;
    font-size: 0.9rem;
}

.product-wp-top-heavy-row-title {
    flex: 1;
    font-size: 0.9375rem;
    color: #495057;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 1rem;
}

.product-wp-top-heavy-price-action {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.product-wp-top-heavy-price {
    font-size: 1.125rem;
    font-weight: 700;
    color: #212529;
    text-align: right;
    min-width: 80px;
}

.product-wp-top-heavy-row .product-wp-button {
    margin: 0;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .product-wp-top-heavy-header {
        flex-direction: column;
        text-align: center;
        padding: 1rem;
    }

    .product-wp-top-heavy-row {
        flex-wrap: wrap;
        padding: 1rem;
        gap: 0.75rem;
    }

    .product-wp-top-heavy-merchant {
        width: auto;
        min-width: 80px;
    }

    .product-wp-top-heavy-row-title {
        width: 100%;
        /* order: 3; Removed to restore natural DOM order (Merchant -> Title -> Price) */
        padding: 0;
        white-space: normal;
        margin-top: 0.5rem;
        margin-bottom: 0.5rem;
    }

    .product-wp-top-heavy-price-action {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        /* Align price/button to right */
        margin-left: 0;
    }
}

/* Toplist Styles */
.product-wp-toplist-container {
    margin-bottom: 2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}


.product-wp-toplist-table {
    width: 100%;
    /* min-width: 800px;  Removed fixed width */
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.product-wp-toplist-table th {
    background: #f8f9fa;
    color: #495057;
    font-weight: 600;
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid #e9ecef;
    white-space: nowrap;
}

.product-wp-toplist-table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid #f1f3f5;
    color: #212529;
}

.product-wp-toplist-table tr:last-child td {
    border-bottom: none;
}

/* Column Widths - Desktop */
.pwp-col-category {
    width: 15%;
    font-weight: 600;
}

.pwp-col-product {
    width: 25%;
}

.pwp-col-score {
    width: 8%;
    text-align: center;
}

.pwp-col-price {
    width: 12%;
    font-weight: 700;
    white-space: nowrap;
}

.pwp-col-review {
    width: 15%;
    text-align: center;
}

.pwp-review-link {
    color: inherit;
    text-decoration: underline;
    font-size: 0.9rem;
}

.pwp-col-action {
    width: 25%;
    text-align: right;
}

/* Specific Elements */
.pwp-score-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #e9ecef;
    color: #495057;
    font-weight: 700;
    border-radius: 4px;
    font-size: 0.875rem;
    white-space: nowrap;
}

.pwp-action-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}

.pwp-merchant-logo {
    max-height: 30px;
    max-width: 100px;
    width: auto;
    object-fit: contain;
}

.pwp-merchant-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
    white-space: nowrap;
}

.product-wp-toplist-table .product-wp-button {
    margin: 0;
    white-space: nowrap;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .product-wp-toplist-table thead {
        display: none;
    }

    .product-wp-toplist-table tbody {
        display: block;
        width: 100%;
    }

    .product-wp-toplist-table tr {
        display: grid;
        grid-template-columns: auto 1fr auto;
        /* Category Product Score */
        grid-template-rows: auto auto auto;
        gap: 8px;
        padding: 1rem;
        border-bottom: 1px solid #e9ecef;
        align-items: center;
    }

    .product-wp-toplist-table td {
        display: block;
        padding: 0;
        border: none;
    }

    /* Map columns to grid */
    .pwp-col-category {
        grid-column: 1;
        grid-row: 1;
        font-size: 0.9rem;
        color: #6c757d;
        font-weight: 600;
        width: auto;
    }

    /* Add a dash separator visually if needed, or just relying on spacing */
    .pwp-col-category::after {
        content: "-";
        margin-left: 5px;
        margin-right: 5px;
    }

    .pwp-col-product {
        grid-column: 2;
        grid-row: 1;
        font-weight: 700;
        font-size: 1rem;
        width: auto;
        overflow: hidden;
        /* Ensure content doesn't overflow grid */
    }

    .pwp-product-wrapper {
        min-width: 0;
        /* Enable flex item shrinking */
    }

    .pwp-product-title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }

    .pwp-col-score {
        grid-column: 3;
        grid-row: 1;
        width: auto;
        text-align: right;
    }

    .pwp-col-price {
        grid-column: 1 / -1;
        grid-row: 3;
        display: block;
        width: 100%;
        text-align: left;
        font-weight: 700;
        margin-top: 0.5rem;
    }

    .pwp-col-review {
        display: none;
    }

    .pwp-col-action {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        margin-top: 0.5rem;
    }

    .pwp-action-wrapper {
        justify-content: space-between;
        /* Logo left, Button right */
        width: 100%;
    }

    /* Adjust button for mobile */
    .product-wp-toplist-table .product-wp-button {
        width: auto;
        /* Allow natural width or set to full if preferred */
        font-size: 0.9rem;
        padding: 0.5rem 1rem;
    }
}

/* Product Wrapper and Thumb (Global) */
.pwp-product-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.pwp-product-thumb {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 4px;
    background-color: #f8f9fa;
    /* Placeholder bg */
}



.pwp-col-product {
    font-size: 1rem;
    font-weight: 600;
}

.pwp-col-score {
    text-align: left !important;
}

.pwp-action-wrapper {
    justify-content: space-between;
    margin-top: 0.5rem;
    gap: 0.5rem;
}

.pwp-merchant-logo {
    max-height: 25px;
}

.product-wp-toplist-table .product-wp-button {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}