/* استایل‌های پیشرفته برای گالری محصولات */
.apg-elementor-widget {
    direction: rtl;
    font-family: 'Vazir', Tahoma, sans-serif;
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    align-items: start;
}

/* فیلترهای سمت راست - طراحی سایدبار */
.apg-filters-container {
    background: var(--apg-filter-bg, #1A499A);
    padding: 25px 20px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.apg-filter-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.apg-filter-group label {
    font-weight: 700;
    color: white;
    font-size: 14px;
    margin-bottom: 5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.apg-filter-group select,
.apg-filter-group input {
    padding: 12px 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    transition: all 0.3s ease;
    font-family: inherit;
    font-size: 14px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    width: 100%;
}

.apg-filter-group select:focus,
.apg-filter-group input:focus {
    border-color: #ffd700;
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.2);
    background: white;
    transform: translateY(-2px);
}

.apg-price-inputs {
    display: flex;
    align-items: center;
    gap: 10px;
}

.apg-price-inputs span {
    color: white;
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.apg-price-inputs input {
    flex: 1;
    text-align: center;
}

/* دکمه‌های فیلتر در سایدبار */
.apg-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 10px;
}

.apg-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    font-size: 14px;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.apg-btn:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.apg-btn:hover:before {
    left: 100%;
}

.apg-btn.primary {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: 2px solid #ff6b6b;
}

.apg-btn.primary:hover {
    background: linear-gradient(135deg, #ee5a24, #ff6b6b);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(255, 107, 107, 0.4);
}

.apg-btn.secondary {
    background: linear-gradient(135deg, #74b9ff, #0984e3);
    color: white;
    border: 2px solid #74b9ff;
}

.apg-btn.secondary:hover {
    background: linear-gradient(135deg, #0984e3, #74b9ff);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(116, 185, 255, 0.4);
}

/* استایل برای select های زیبا */
.apg-filter-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23666' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 16px center;
    background-size: 12px;
    padding-left: 40px;
}

/* آیکون‌ها در دکمه‌ها */
.apg-btn i {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.apg-btn:hover i {
    transform: scale(1.1);
}

/* بخش محصولات */
.apg-products-container {
    grid-column: 2;
}

/* بقیه استایل‌های محصولات بدون تغییر */
.apg-products-grid {
    display: grid;
    gap: 25px;
    margin-bottom: 30px;
}

.apg-columns-1 { grid-template-columns: 1fr; }
.apg-columns-2 { grid-template-columns: repeat(2, 1fr); }
.apg-columns-3 { grid-template-columns: repeat(3, 1fr); }
.apg-columns-4 { grid-template-columns: repeat(4, 1fr); }
.apg-columns-5 { grid-template-columns: repeat(5, 1fr); }
.apg-columns-6 { grid-template-columns: repeat(6, 1fr); }

/* کارت محصول */
.apg-product-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 20px;
    position: relative;
    transition: all 0.4s ease;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.apg-product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    border-color: #cbd5e0;
}

/* بدج‌ها */
.apg-product-badges {
    position: absolute;
    top: 15px;
    left: 15px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.apg-badge {
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.apg-badge.sale {
    background: #e53e3e;
    color: white;
}

.apg-badge.out-of-stock {
    background: #718096;
    color: white;
}

/* تصویر محصول */
.apg-product-image {
    position: relative;
    margin-bottom: 15px;
    border-radius: 12px;
    overflow: hidden;
}

.apg-product-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.apg-product-card:hover .apg-product-image img {
    transform: scale(1.05);
}

.apg-product-actions {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
    display: flex;
    gap: 10px;
    transition: all 0.3s ease;
}

.apg-product-card:hover .apg-product-actions {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.apg-product-actions a {
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #4a5568;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    font-size: 14px;
}

.apg-product-actions a:hover {
    background: #4299e1;
    color: white;
    transform: scale(1.1);
}

/* اطلاعات محصول */
.apg-product-info {
    text-align: center;
}

.apg-product-title {
    margin-bottom: 8px;
}

.apg-product-title a {
    color: #2d3748;
    text-decoration: none;
    font-weight: 700;
    font-size: 16px;
    line-height: 1.4;
    transition: color 0.3s ease;
}

.apg-product-title a:hover {
    color: #4299e1;
}

.apg-product-rating {
    margin-bottom: 10px;
    color: #f6ad55;
}

.apg-product-rating .star-rating {
    display: inline-block;
}

.apg-product-price {
    font-size: 18px;
    font-weight: 800;
    color: #e53e3e;
    margin-bottom: 8px;
}

.apg-product-excerpt {
    color: #718096;
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.apg-product-meta {
    font-size: 12px;
    color: #a0aec0;
}

/* صفحه‌بندی */
.apg-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
}

.apg-page-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    color: #4a5568;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

.apg-page-item:hover,
.apg-page-item.active {
    background: #4299e1;
    border-color: #4299e1;
    color: white;
}

.apg-page-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* نوتیفیکیشن */
.apg-notification {
    position: fixed;
    top: 20px;
    left: 20px;
    background: #48bb78;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 10000;
    transform: translateX(-100%);
    opacity: 0;
    transition: all 0.3s ease;
}

.apg-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.apg-notification-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* وضعیت‌های مختلف */
.apg-loading {
    text-align: center;
    padding: 40px;
    color: #718096;
    grid-column: 1 / -1;
}

.apg-no-products {
    text-align: center;
    padding: 60px 20px;
    color: #a0aec0;
    grid-column: 1 / -1;
    font-size: 16px;
}

/* استایل‌های جدید برای افزودن به سبد خرید */
.apg-add-to-cart.loading,
.apg-select-options.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

.apg-add-to-cart.loading i,
.apg-select-options.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.apg-product-type {
    display: block;
    font-size: 11px;
    color: #718096;
    margin-top: 5px;
}

/* بهبود استایل برای محصولات غیرساده */
.apg-select-options {
    background: #f56565 !important;
}

.apg-select-options:hover {
    background: #e53e3e !important;
}

/* نمایش وضعیت محصولات متغیر */
.apg-product-card.variable .apg-add-to-cart {
    display: none !important;
}

.apg-product-card.variable .apg-select-options {
    display: flex !important;
}

/* استایل برای محصولات گروهی */
.apg-product-card.grouped .apg-add-to-cart {
    display: none !important;
}

.apg-product-card.grouped .apg-select-options {
    display: flex !important;
}

/* استایل برای محصولات ناموجود */
.apg-product-card.out-of-stock .apg-add-to-cart,
.apg-product-card.out-of-stock .apg-select-options {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* استایل‌های مربوط به ووکامرس */
.woocommerce .star-rating {
    color: #f6ad55;
    font-size: 14px;
}

.woocommerce .star-rating:before {
    content: '\f005\f005\f005\f005\f005';
    font-family: 'Font Awesome 6 Free';
    font-weight: 400;
    opacity: 0.25;
}

.woocommerce .star-rating span {
    display: block;
    overflow: hidden;
    position: absolute;
    top: 0;
    right: 0;
}

.woocommerce .star-rating span:before {
    content: '\f005\f005\f005\f005\f005';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #f6ad55;
}

/* استایل برای دکمه‌های غیرفعال */
.apg-add-to-cart:disabled,
.apg-select-options:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* استایل برای محصولات در حال لود */
.apg-product-card.loading {
    opacity: 0.7;
    pointer-events: none;
}

.apg-product-card.loading .apg-product-actions {
    display: none;
}

/* بهبود نمایش قیمت */
.apg-product-price del {
    color: #a0aec0;
    font-size: 14px;
    margin-left: 5px;
}

.apg-product-price ins {
    text-decoration: none;
    background: transparent;
}

/* استایل برای حالت موفقیت */
.apg-add-to-cart.added {
    background: #48bb78 !important;
    color: white !important;
}

.apg-add-to-cart.added i {
    transform: scale(1.2);
}

/* محصولات ویژه */
.apg-badge.featured {
    background: #9f7aea;
    color: white;
}

/* محصولات قابل پیش‌خرید */
.apg-badge.onbackorder {
    background: #ed8936;
    color: white;
}

.apg-backorder-notice {
    background: #fffaf0;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    padding: 8px;
    margin-top: 10px;
    text-align: center;
}

.apg-backorder-notice small {
    color: #c05621;
    font-size: 11px;
}

/* استایل برای محصولات خارجی */
.apg-product-card.external .apg-add-to-cart {
    background: #38a169 !important;
}

.apg-product-card.external .apg-add-to-cart:hover {
    background: #2f855a !important;
}

/* استایل برای دکمه غیرفعال */
.apg-out-of-stock {
    width: 40px;
    height: 40px;
    background: #a0aec0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    cursor: not-allowed;
    opacity: 0.6;
}

/* اطلاعات محصولات متغیر */
.apg-variation-info {
    margin-top: 8px;
    padding: 6px 10px;
    background: #f7fafc;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.apg-variation-info small {
    color: #4a5568;
    font-weight: 600;
}

/* وزن محصول */
.apg-weight {
    display: block;
    margin-top: 4px;
    font-size: 11px;
}

/* بهبود نمایش امتیاز */
.star-rating {
    display: inline-block;
    position: relative;
    font-family: 'Font Awesome 6 Free';
    font-size: 14px;
}

.star-rating:before {
    content: '\f005\f005\f005\f005\f005';
    color: #e2e8f0;
    font-weight: 400;
}

.star-rating span:before {
    content: '\f005\f005\f005\f005\f005';
    color: #f6ad55;
    font-weight: 900;
    position: absolute;
    top: 0;
    right: 0;
}

/* استایل برای حالت‌های مختلف محصول */
.apg-product-card.not-in-stock {
    opacity: 0.8;
}

.apg-product-card.not-in-stock .apg-product-image img {
    filter: grayscale(0.3);
}

/* انیمیشن برای افزودن به سبد خرید */
@keyframes addToCartSuccess {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.apg-add-to-cart.added i {
    animation: addToCartSuccess 0.5s ease;
    color: #48bb78;
}

/* رسپانسیو برای حالت سایدبار */
@media (max-width: 992px) {
    .apg-elementor-widget {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .apg-filters-container {
        position: static;
        max-height: none;
        order: -1;
    }
    
    .apg-products-container {
        grid-column: 1;
    }
    
    .apg-columns-6,
    .apg-columns-5,
    .apg-columns-4 { 
        grid-template-columns: repeat(3, 1fr); 
    }
}

@media (max-width: 768px) {
    .apg-columns-6,
    .apg-columns-5,
    .apg-columns-4,
    .apg-columns-3 { 
        grid-template-columns: repeat(2, 1fr); 
    }
    
    .apg-product-actions {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
        position: static;
        transform: none;
        justify-content: center;
        margin-top: 10px;
        background: rgba(255, 255, 255, 0.9);
        padding: 10px;
        border-radius: 10px;
    }
    
    .apg-filter-actions {
        flex-direction: row;
    }
    
    .apg-btn {
        width: auto;
        flex: 1;
    }
}

@media (max-width: 576px) {
    .apg-columns-6,
    .apg-columns-5,
    .apg-columns-4,
    .apg-columns-3,
    .apg-columns-2 { 
        grid-template-columns: 1fr; 
    }
    
    .apg-filters-container {
        padding: 20px 15px;
    }
    
    .apg-product-image img {
        height: 180px;
    }
    
    .apg-filter-actions {
        flex-direction: column;
    }
    
    .apg-btn {
        width: 100%;
    }
}

/* استایل برای فونت آیکون‌ها */
.fas, .far, .fab {
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
}

.far {
    font-weight: 400;
}

/* استایل‌های بهبود یافته برای المنتور */
.elementor-widget-apg_product_gallery {
    direction: rtl;
}

/* استایل برای حالت خطا */
.apg-add-to-cart.error {
    background: #e53e3e !important;
    color: white !important;
}

/* استایل برای نوتیفیکیشن خطا */
.apg-notification.error {
    background: #e53e3e;
}

.apg-notification.warning {
    background: #ed8936;
}

/* بهبود نمایش در حالت‌های مختلف */
.apg-product-card:not(.in-stock) .apg-add-to-cart,
.apg-product-card:not(.in-stock) .apg-select-options {
    opacity: 0.5;
    cursor: not-allowed;
}
/* کلاس‌های جدید برای لایه‌بندی */
.apg-sidebar-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    align-items: start;
}

.apg-top-layout {
    display: block;
}

.apg-top-layout .apg-filters-container {
    margin-bottom: 30px;
}

/* برای سازگاری با شورت‌کد قدیمی */
.apg-shortcode-gallery:not(.apg-sidebar-layout):not(.apg-top-layout) {
    display: block;
}