/**
 * Product Groups - Frontend Styles
 *
 * Classic style (Default) maintains 100% pixel-perfect fidelity with original v1.2 styles.
 * Modern style is available as an opt-in via Plugin Settings.
 *
 * @package ProductGroups
 */

/* ==========================================================================
   Base & Classic Styles (Original v1.2 Layout - Default)
   ========================================================================== */

.pg-shortcode-list {
    width: 100%;
    margin: 20px auto;
    direction: rtl;
}

.pg-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
    direction: rtl;
    box-sizing: border-box;
}

.pg-product-grid * {
    box-sizing: border-box;
}

.pg-product-grid:has(> :nth-child(1):nth-last-child(3)),
.pg-product-grid:has(> :nth-child(3):nth-last-child(1)) {
    grid-template-columns: repeat(3, minmax(250px, 1fr));
}

.pg-product-item {
    background: #ffffff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    border: none;
}

.pg-product-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.pg-product-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 2px solid #f5f5f5;
}

img.pg-product-image {
    box-shadow: none !important;
    border-bottom: none;
}

.pg-product-title,
h3.pg-product-title {
    font-size: 1.1rem;
    margin: 15px 15px 10px;
    color: #333333;
    text-align: center;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pg-product-price,
p.pg-product-price {
    margin: 0 15px 15px;
    text-align: center;
    color: #555555;
    font-size: 0.95rem;
}

.pg-product-price del {
    color: #999999;
    margin-left: 8px;
}

.pg-product-price strong {
    color: #FC6668;
    font-weight: 700;
}

.pg-button {
    display: block;
    background: linear-gradient(135deg, #9777cd 0%, #FC6668 100%);
    color: #ffffff !important;
    text-align: center;
    padding: 10px;
    margin: 0 15px 15px;
    border-radius: 5px;
    text-decoration: none !important;
    font-weight: bold;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.pg-button:hover {
    background: linear-gradient(135deg, #8666bd 0%, #eb5558 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(151, 119, 205, 0.3);
    color: #ffffff !important;
}

/* Classic Responsive adjustments */
@media (max-width: 768px) {
    .pg-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
        gap: 15px;
    }

    .pg-product-image {
        height: 160px;
    }
}

@media (max-width: 480px) {
    .pg-product-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .pg-product-title {
        font-size: 1rem;
    }

    .pg-button {
        padding: 8px;
        font-size: 0.9rem;
    }
}

@media screen and (max-width: 480px) {
    .pg-product-grid:has(> :nth-child(1):nth-last-child(3)),
    .pg-product-grid:has(> :nth-child(3):nth-last-child(1)) {
        grid-template-columns: 1fr;
    }
}

@media screen and (min-width: 481px) and (max-width: 767px) {
    .pg-product-grid:has(> :nth-child(1):nth-last-child(3)),
    .pg-product-grid:has(> :nth-child(3):nth-last-child(1)) {
        grid-template-columns: repeat(2, minmax(150px, 1fr));
    }
}

@media screen and (min-width: 768px) {
    .pg-product-grid:has(> .pg-product-item:only-child) {
        max-width: 50%;
        margin: 0 auto;
        justify-content: center;
    }
}

/* ==========================================================================
   Modern Animated Card Style (Opt-in via Settings)
   ========================================================================== */

.pg-style-modern .pg-product-grid {
    gap: 24px;
    padding: 10px 0;
}

.pg-style-modern .pg-item-modern {
    border-radius: 14px;
    border: 1px solid #f0f0f2;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.pg-style-modern .pg-item-modern:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12), 0 4px 8px rgba(0, 0, 0, 0.05);
    border-color: rgba(239, 64, 86, 0.25);
}

.pg-style-modern .pg-product-image-wrap {
    position: relative;
    width: 100%;
    height: 210px;
    overflow: hidden;
    background: #fafafa;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #f5f5f7;
}

.pg-style-modern .pg-product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 12px;
    transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    border-bottom: none !important;
}

.pg-style-modern .pg-item-modern:hover .pg-product-image {
    transform: scale(1.06);
}

.pg-style-modern .pg-discount-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    line-height: 1.4;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    animation: pgPulseBadge 3s infinite;
}

@keyframes pgPulseBadge {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.04);
    }
}

.pg-style-modern .pg-product-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 16px;
    text-align: center;
}

.pg-style-modern .pg-product-title {
    font-size: 0.98rem;
    font-weight: 600;
    margin: 0 0 12px;
    color: #2c3338;
    line-height: 1.55;
    min-height: 4.5em;
}

.pg-style-modern .pg-product-price {
    margin: auto 0 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
}

.pg-style-modern .pg-product-price strong {
    color: #ef4056;
    font-weight: 800;
    font-size: 1.05rem;
}

.pg-style-modern .pg-out-of-stock {
    color: #646970;
    background: #f0f0f1;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    display: inline-block;
}

.pg-style-modern .pg-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, #7952b3 0%, #ef4056 100%);
    padding: 12px 18px;
    border-radius: 10px;
    font-size: 0.94rem;
    margin: 0 16px 16px;
    box-shadow: 0 4px 12px rgba(239, 64, 86, 0.25);
    position: relative;
    overflow: hidden;
}

.pg-style-modern .pg-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.25), transparent);
    transform: skewX(-20deg);
    transition: left 0.6s ease;
}

.pg-style-modern .pg-button:hover::before {
    left: 140%;
}

.pg-style-modern .pg-button:hover {
    background: linear-gradient(135deg, #673ab7 0%, #dc2626 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(239, 64, 86, 0.4);
}

.pg-style-modern .pg-btn-icon {
    flex-shrink: 0;
    transition: transform 0.25s ease;
}

.pg-style-modern .pg-button:hover .pg-btn-icon {
    transform: translateX(-3px);
}

.pg-no-products,
.pg-fetch-error {
    text-align: center;
    padding: 24px 16px;
    margin: 20px auto;
    max-width: 600px;
    color: #64748b;
    font-size: 14px;
    line-height: 1.6;
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    direction: rtl;
}

.pg-fetch-error {
    color: #475569;
    background: #fff8f8;
    border-color: #fecaca;
}
