.woopage-wrapper {
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.woopage-grid {
    display: grid;
    gap: 24px;
    /* Columns are handled by inline styles or widget settings */
}

.woopage-product-card {
    background: #fff;
    border: 1px solid transparent;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.woopage-product-card:hover {
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
    transform: translateY(-5px);
}

.woopage-product-image {
    position: relative;
    margin-bottom: 0;
    overflow: hidden;
    aspect-ratio: 1 / 1; /* Ensure square or consistent aspect ratio */
}

.woopage-product-image a {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
}

.woopage-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease, opacity 0.3s ease;
}

.woopage-product-card:hover .woopage-product-image img {
    transform: scale(1.05);
}

/* Image Swap */
.woopage-secondary-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.woopage-product-card:hover .woopage-secondary-image {
    opacity: 1;
}

.woopage-product-card:hover .woopage-main-image {
    opacity: 0; /* Optional: hide main image if secondary is opaque */
}

/* Badges */
.onsale {
    position: absolute;
    top: 12px;
    left: 12px;
    background-color: #ff4757;
    color: #fff;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    line-height: 1;
}

.out-of-stock-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background-color: #747d8c;
    color: #fff;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 20px;
    z-index: 5;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    line-height: 1;
}

.woopage-product-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.woopage-product-title {
    margin: 0 0 8px;
    font-size: 16px;
    line-height: 1.4;
    font-weight: 600;
}

.woopage-product-title a {
    color: #2f3542;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.woopage-product-title a:hover {
    color: #3742fa;
}

.woopage-product-price {
    font-weight: 700;
    color: #2f3542;
    margin-bottom: 16px;
    font-size: 18px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.woopage-product-price del {
    color: #a4b0be;
    font-weight: 400;
    font-size: 0.85em;
    text-decoration: line-through;
}

.woopage-product-price ins {
    text-decoration: none;
    color: #ff4757;
}

.woopage-product-footer {
    margin-top: auto;
}

.button.add_to_cart_button {
    width: 100%;
    text-align: center;
    background-color: #2f3542;
    color: #fff;
    padding: 12px 20px;
    border-radius: 30px; /* Pill shape */
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-block;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    cursor: pointer;
}

.button.add_to_cart_button:hover {
    background-color: #3742fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(55, 66, 250, 0.3);
}

.button.loading {
    opacity: 0.7;
    cursor: wait;
    position: relative;
}

.button.loading:after {
    content: '';
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.5);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translateY(-50%) rotate(360deg); }
}

/* Pagination - Improved */
.woopage-pagination {
    margin-top: 40px;
    text-align: center;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.woopage-pagination .page-numbers {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 2px solid #dfe4ea;
    color: #57606f;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    font-size: 14px;
    
    /* Layout Robustness */
    vertical-align: middle;
    white-space: nowrap;
    box-sizing: border-box;
    line-height: 1;
    position: relative;
    overflow: hidden;
}

.woopage-pagination .page-numbers::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(55, 66, 250, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.3s, height 0.3s;
}

.woopage-pagination .page-numbers:hover::before {
    width: 100%;
    height: 100%;
}

.woopage-pagination .page-numbers:hover {
    color: #3742fa;
    border-color: #3742fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(55, 66, 250, 0.2);
}

.woopage-pagination .page-numbers.current {
    background-color: #3742fa;
    color: #fff;
    border-color: #3742fa;
    box-shadow: 0 4px 12px rgba(55, 66, 250, 0.3);
    cursor: default;
    pointer-events: none;
}

.woopage-pagination .page-numbers.current::before {
    display: none;
}

.woopage-pagination .page-numbers.dots {
    border: none;
    cursor: default;
    pointer-events: none;
    min-width: auto;
    padding: 0 8px;
}

.woopage-pagination .page-numbers.dots:hover {
    transform: none;
    box-shadow: none;
}

.woopage-pagination .page-numbers.loading {
    opacity: 0.6;
    cursor: wait;
    pointer-events: none;
    position: relative;
}

.woopage-pagination .page-numbers.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(55, 66, 250, 0.3);
    border-top-color: #3742fa;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.woopage-pagination .next,
.woopage-pagination .prev {
    width: auto;
    min-width: 40px;
    padding: 0 16px;
    border-radius: 8px;
    font-weight: 700;
}

.woopage-pagination .next:hover,
.woopage-pagination .prev:hover {
    background-color: #3742fa;
    color: #fff;
}

.woopage-pagination .next.disabled,
.woopage-pagination .prev.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Responsive Pagination */
@media (max-width: 768px) {
    .woopage-pagination {
        gap: 4px;
    }
    
    .woopage-pagination .page-numbers {
        min-width: 36px;
        height: 36px;
        padding: 0 8px;
        font-size: 13px;
    }
    
    .woopage-pagination .page-numbers.dots {
        display: none; /* Hide dots on mobile for cleaner look */
    }
}

/* AJAX Loading State */
.woopage-loading {
    pointer-events: none;
    position: relative;
}

.woopage-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 10;
}

/* Error State */
.woopage-error {
    padding: 20px;
    text-align: center;
    background: #f8d7da;
    color: #721c24;
    border-radius: 8px;
    border: 1px solid #f5c6cb;
    margin: 20px 0;
}

.woopage-error strong {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

.woopage-error small {
    display: block;
    font-size: 14px;
    opacity: 0.8;
}

/* Skeleton Loading */
@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

.woopage-skeleton-card {
    background: #fff;
    border: 1px solid transparent;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.woopage-skeleton-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
}

.woopage-skeleton-content {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.woopage-skeleton-line {
    height: 14px;
    border-radius: 4px;
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 1000px 100%;
    animation: shimmer 2s infinite linear;
    width: 100%;
}

.woopage-skeleton-line.title { height: 20px; width: 80%; margin-bottom: 5px; }
.woopage-skeleton-line.price { height: 18px; width: 40%; margin-bottom: 10px; }
.woopage-skeleton-line.button { height: 40px; width: 100%; border-radius: 30px; margin-top: auto; }

/* Toast Notification */
.woopage-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #fff;
    color: #333;
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 15px;
    border-left: 4px solid #2ecc71;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.woopage-toast.show {
    transform: translateY(0);
    opacity: 1;
}

.woopage-toast-icon {
    color: #2ecc71;
    font-size: 20px;
}

.woopage-toast-message {
    font-weight: 500;
}

/* Responsive */
@media (max-width: 768px) {
    .woopage-grid {
        gap: 15px;
    }
    
    .woopage-product-card {
        border-radius: 8px;
    }
    
    .woopage-product-content {
        padding: 12px;
    }
    
    .button.add_to_cart_button {
        padding: 10px 15px;
        font-size: 13px;
    }

    .woopage-toast {
        left: 20px;
        right: 20px;
        bottom: 20px;
        text-align: center;
        justify-content: center;
    }
}

/* Swiper Overrides */
.woopage-swiper .swiper-button-next,
.woopage-swiper .swiper-button-prev {
    color: #2f3542;
    background: rgba(255,255,255,0.8);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.woopage-swiper .swiper-button-next:after,
.woopage-swiper .swiper-button-prev:after {
    font-size: 18px;
    font-weight: bold;
}

.woopage-swiper .swiper-pagination-bullet-active {
    background: #2f3542;
}