/* ═══════════════════════════════════════════════════════════════
   🎨 بخش انتخاب محصولات گروهی - صفحه محصول
   ═══════════════════════════════════════════════════════════════ */

.wgc-product-section {
    background: #fff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 20px !important;
    margin: 20px 0 !important;
}

.wgc-section-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 15px !important;
}

.wgc-section-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #333 !important;
}

.wgc-add-button {
    background: #27ae60 !important;
    color: #fff !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 5px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.wgc-add-button:hover {
    background: #229954 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 8px rgba(39, 174, 96, 0.3) !important;
}

.wgc-add-button:active {
    transform: translateY(0) !important;
}

/* لیست محصولات انتخابی */
.wgc-selected-products {
    margin-top: 15px !important;
}

.wgc-product-row {
    display: flex !important;
    align-items: center !important;
    padding: 12px !important;
    background: #f9f9f9 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 5px !important;
    margin-bottom: 10px !important;
    position: relative !important;
}

.wgc-remove-button {
    background: #e74c3c !important;
    color: #fff !important;
    border: none !important;
    width: 25px !important;
    height: 25px !important;
    border-radius: 50% !important;
    font-size: 16px !important;
    cursor: pointer !important;
    margin-left: 10px !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.wgc-remove-button:hover {
    background: #c0392b !important;
    transform: rotate(90deg) !important;
}

.wgc-product-name {
    font-weight: 600 !important;
    color: #333 !important;
    margin-left: 10px !important;
}

.wgc-product-attribute {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
}

.wgc-product-attribute span {
    background: #602aeac9 !important;
    color: #fff !important;
    padding: 3px 8px !important;
    border-radius: 3px !important;
    font-size: 12px !important;
}

/* ═══════════════════════════════════════════════════════════════
   🚀 Global Loader
   ═══════════════════════════════════════════════════════════════ */

#wgc-global-loader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
}

.wgc-spinner {
    width: 50px !important;
    height: 50px !important;
    border: 4px solid rgba(255, 255, 255, 0.3) !important;
    border-top-color: #fff !important;
    border-radius: 50% !important;
    animation: spin 0.8s linear infinite !important;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   🔲 پاپ‌آپ انتخاب محصول
   ═══════════════════════════════════════════════════════════════ */

.wgc-popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    z-index: 99999 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    animation: fadeIn 0.2s ease-out !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.wgc-popup-container {
    width: 90% !important;
    max-width: 900px !important;
    max-height: 80vh !important;
    background-color: #fff !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    animation: slideIn 0.2s ease-out !important;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wgc-popup-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px 20px !important;
    border-bottom: 1px solid #eee !important;
    background: #f9f9f9 !important;
}

.wgc-popup-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #333 !important;
}

.wgc-popup-close {
    font-size: 24px !important;
    cursor: pointer !important;
    color: #999 !important;
    transition: all 0.3s ease !important;
    line-height: 1 !important;
    padding: 5px !important;
}

.wgc-popup-close:hover {
    color: #e74c3c !important;
    transform: rotate(90deg) !important;
}

/* ═══════════════════════════════════════════════════════════
   🔍 نوار جستجو
   ═══════════════════════════════════════════════════════════ */

.wgc-popup-search {
    padding: 15px 20px !important;
    background: #fff !important;
    border-bottom: 1px solid #eee !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.wgc-search-input {
    flex: 1 !important;
    padding: 10px 15px !important;
    border: 1px solid #ddd !important;
    border-radius: 5px !important;
    font-size: 14px !important;
    transition: border-color 0.3s ease !important;
}

.wgc-search-input:focus {
    outline: none !important;
    border-color: #602aeac9 !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
}

.wgc-search-button {
	border: 1px #868b88;
    padding: 10px 20px !important;
    background: #ffffff !important;
    color: rgb(75, 75, 75) !important;
    border-radius: 5px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.wgc-search-button:hover {
    background: #4d504d !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3) !important;
}

.wgc-search-button:active {
    transform: translateY(0) !important;
}

.wgc-search-loader {
    text-align: center !important;
    padding: 40px 20px !important;
    display: none !important;
}

.wgc-search-loader .wgc-spinner {
    margin: 0 auto 15px !important;
}

.wgc-search-loader p {
    color: #666 !important;
    font-size: 14px !important;
}

/* ═══════════════════════════════════════════════════════════
   📑 تب‌ها + Pagination
   ═══════════════════════════════════════════════════════════ */

.wgc-popup-tabs {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    border-bottom: 1px solid #eee !important;
    background: #fff !important;
    padding: 0 !important;
}

.wgc-tabs-wrapper {
    display: flex !important;
}

.wgc-tab {
    padding: 12px 20px !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    color: #666 !important;
    transition: all 0.3s ease !important;
    border-bottom: 3px solid transparent !important;
    background: transparent !important;
}

.wgc-tab:hover {
    color: #333 !important;
    background: #f9f9f9 !important;
}

.wgc-tab.active {
    border-bottom-color: #602aeac9 !important;
    color: #602aeac9 !important;
    background: #fff !important;
}

.wgc-pagination-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 15px !important;
    margin-left: auto !important;
}

.wgc-page-btn {
    padding: 6px 12px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    color: #333 !important;
}

.wgc-page-btn:hover:not(:disabled) {
    background: #f5f5f5 !important;
    border-color: #999 !important;
}

.wgc-page-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.wgc-page-info {
    font-size: 13px !important;
    color: #666 !important;
    white-space: nowrap !important;
}

.wgc-current-page {
    font-weight: 600 !important;
    color: #602aeac9 !important;
}

/* ═══════════════════════════════════════════════════════════
   📦 محتوای پاپ‌آپ - ✅ FIX: اسکرول در همه اندازه‌ها
   ═══════════════════════════════════════════════════════════ */

.wgc-popup-content {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px !important;
    background: #fafafa !important;
    max-height: calc(80vh - 200px) !important;
    min-height: 400px !important;
}

.wgc-tab-content {
    display: none !important;
}

.wgc-tab-content.active {
    display: block !important;
}

/* ═══════════════════════════════════════════════════════════
   🛍️ گرید محصولات
   ═══════════════════════════════════════════════════════════ */

.wgc-products-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 15px !important;
}

.wgc-product-item {
    background: #fff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 15px !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    flex-direction: column !important;
}

.wgc-product-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-2px) !important;
}

.wgc-product-image {
    margin-bottom: 12px !important;
    text-align: center !important;
    overflow: hidden !important;
    border-radius: 6px !important;
    background: #f5f5f5 !important;
}

.wgc-product-image img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    transition: opacity 0.3s ease !important;
}

.wgc-product-item img[data-src] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%) !important;
    background-size: 200% 100% !important;
    animation: shimmer 1.5s infinite !important;
    min-height: 150px !important;
    opacity: 0.6 !important;
}

.wgc-product-item img.loaded {
    opacity: 1 !important;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.wgc-product-title {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 8px !important;
    min-height: 42px !important;
    line-height: 1.4 !important;
    text-align: center !important;
}

.wgc-product-details {
    font-size: 13px !important;
    color: #666 !important;
    margin-bottom: 12px !important;
    text-align: center !important;
}

.wgc-shared-code {
    display: inline-block !important;
    padding: 2px 8px !important;
    border-radius: 3px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #fff !important;
    margin-right: 5px !important;
    background: #602aeac9 !important;
}

/* ═══════════════════════════════════════════════════════════
   🎛️ ویژگی‌ها
   ═══════════════════════════════════════════════════════════ */

.wgc-popup-attributes {
    margin: 10px 0 !important;
    min-height: 50px !important;
    text-align: right !important;
}

.wgc-attributes-wrapper {
    text-align: right !important;
}

.wgc-attribute-group {
    margin-bottom: 10px !important;
}

.wgc-attribute-label {
    display: block !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #555 !important;
    margin-bottom: 5px !important;
    text-align: right !important;
}

.wgc-attribute-select {
    width: 100% !important;
    padding: 8px 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    background-color: #fff !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    direction: rtl !important;
}

.wgc-attribute-select:focus {
    outline: none !important;
    border-color: #602aeac9 !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
}

.wgc-attribute-select:hover {
    border-color: #bbb !important;
}

.wgc-no-attr {
    font-size: 12px !important;
    color: #999 !important;
    font-style: italic !important;
}

.wgc-loading {
    font-size: 14px !important;
    color: #602aeac9 !important;
}

.wgc-error {
    font-size: 12px !important;
    color: #e74c3c !important;
}

/* ═══════════════════════════════════════════════════════════
   🔘 دکمه‌های محصول
   ═══════════════════════════════════════════════════════════ */

.wgc-product-actions {
    display: flex !important;
    gap: 8px !important;
    margin-top: auto !important;
}

.wgc-add-product {
    flex: 1 !important;
    padding: 8px 12px !important;
    background: #27ae60 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 5px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.wgc-add-product:hover {
    background: #229954 !important;
    transform: translateY(-1px) !important;
}

.wgc-add-product.wgc-added {
    background: #602aeac9 !important;
}

.wgc-product-actions a {
    padding: 8px 12px !important;
    background: #f5f5f5 !important;
    color: #333 !important;
    text-decoration: none !important;
    border-radius: 5px !important;
    font-size: 13px !important;
    transition: all 0.3s ease !important;
    text-align: center !important;
}

.wgc-product-actions a:hover {
    background: #e0e0e0 !important;
}

.wgc-no-results {
    text-align: center !important;
    padding: 40px 20px !important;
    color: #999 !important;
    font-size: 14px !important;
}

/* ═══════════════════════════════════════════════════════════
   🎨 اسکرول‌بار سفارشی
   ═══════════════════════════════════════════════════════════ */

.wgc-popup-content::-webkit-scrollbar {
    width: 8px !important;
}

.wgc-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
}

.wgc-popup-content::-webkit-scrollbar-thumb {
    background: #c1c1c1 !important;
    border-radius: 4px !important;
}

.wgc-popup-content::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1 !important;
}

/* ═══════════════════════════════════════════════════════════
   📱 Responsive
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .wgc-popup-tabs {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .wgc-tabs-wrapper {
        width: 100% !important;
    }

    .wgc-pagination-wrapper {
        margin-left: 0 !important;
        justify-content: center !important;
        border-top: 1px solid #eee !important;
        padding-top: 12px !important;
        width: 100% !important;
    }

    .wgc-products-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .wgc-product-actions {
        flex-direction: column !important;
    }

    .wgc-popup-container {
        width: 100% !important;
        max-height: 90vh !important;
        border-radius: 0 !important;
    }

    .wgc-add-button {
        font-size: 13px !important;
        padding: 9px 14px !important;
    }

    .wgc-product-name {
        font-size: 13px !important;
    }

    .wgc-product-attribute span {
        font-size: 11px !important;
        padding: 2px 6px !important;
    }
}

/* ═══════════════════════════════════════════════════════════
   🔧 فیلدهای مخفی
   ═══════════════════════════════════════════════════════════ */

#wgc-max-products,
#wgc-required-product,
#wgc-required-message {
    display: none !important;
}

/* ═══════════════════════════════════════════════════════════
   🎨 انیمیشن‌ها
   ═══════════════════════════════════════════════════════════ */

@keyframes pulseButton {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.wgc-add-button:focus {
    animation: pulseButton 0.5s ease !important;
}


/* ─────────────────────────────────────────────────────────────
   هدر بخش (عنوان + دکمه افزودن)
   ───────────────────────────────────────────────────────────── */

.wgc-product-section .wgc-section-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    margin-bottom: 15px !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid #f0f0f0 !important;
}

.wgc-product-section .wgc-section-title {
    font-size: 16px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* دکمه افزودن - با Specificity بالاتر */
.wgc-product-section button.wgc-add-button,
button.wgc-add-button {
    background: #27ae60 !important;
    background-color: #27ae60 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 8px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
    outline: none !important;
}

.wgc-product-section button.wgc-add-button:hover,
button.wgc-add-button:hover {
    background: #229954 !important;
    background-color: #229954 !important;
    color: #ffffff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 6px rgba(39, 174, 96, 0.3) !important;
}

.wgc-product-section button.wgc-add-button:active,
button.wgc-add-button:active {
    transform: translateY(0) !important;
    background: #1e8449 !important;
}

.wgc-product-section button.wgc-add-button:focus,
button.wgc-add-button:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.2) !important;
}

/* ─────────────────────────────────────────────────────────────
   لیست محصولات انتخابی
   ───────────────────────────────────────────────────────────── */

.wgc-selected-products {
    min-height: 40px !important;
}

.wgc-selected-products:empty {
    display: none !important;
}

/* ردیف هر محصول */
.wgc-product-row {
    display: flex !important;
    align-items: center !important;
    background: #fafafa !important;
    border: 1px solid #e8e8e8 !important;
    border-radius: 6px !important;
    padding: 10px 12px !important;
    margin-bottom: 8px !important;
    transition: all 0.3s ease !important;
}

.wgc-product-row:hover {
    background: #f5f5f5 !important;
    border-color: #d0d0d0 !important;
}

.wgc-product-row:last-child {
    margin-bottom: 0 !important;
}

/* دکمه حذف */
.wgc-product-row button.wgc-remove-button,
button.wgc-remove-button {
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: #fff !important;
    background-color: #fff !important;
    border: 1px solid #e74c3c !important;
    border-radius: 4px !important;
    color: #e74c3c !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    flex-shrink: 0 !important;
    margin-left: 10px !important;
    padding: 0 !important;
    line-height: 1 !important;
}

.wgc-product-row button.wgc-remove-button:hover,
button.wgc-remove-button:hover {
    background: #e74c3c !important;
    background-color: #e74c3c !important;
    color: #fff !important;
    transform: scale(1.1) !important;
}

/* نام محصول */
.wgc-product-name {
    flex-grow: 1 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #333 !important;
    line-height: 1.4 !important;
}

/* ویژگی‌های محصول */
.wgc-product-attribute {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin-top: 6px !important;
}

.wgc-product-attribute span {
    font-size: 12px !important;
    color: #666 !important;
    background: #fff !important;
    padding: 3px 8px !important;
    border-radius: 3px !important;
    border: 1px solid #e0e0e0 !important;
}

/* ═══════════════════════════════════════════════════════════════
   🚀 Global Loader
   ═══════════════════════════════════════════════════════════════ */

#wgc-global-loader {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.6) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 999999 !important;
}

.wgc-spinner {
    width: 50px !important;
    height: 50px !important;
    border: 4px solid rgba(255, 255, 255, 0.3) !important;
    border-top-color: #fff !important;
    border-radius: 50% !important;
    animation: spin 0.8s linear infinite !important;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════════════════════════
   🔲 پاپ‌آپ انتخاب محصول
   ═══════════════════════════════════════════════════════════════ */

/* اورلی */
.wgc-popup-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: rgba(0, 0, 0, 0.7) !important;
    z-index: 99999 !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    animation: fadeIn 0.2s ease-out !important;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* کانتینر اصلی پاپ‌آپ */
.wgc-popup-container {
    width: 90% !important;
    max-width: 900px !important;
    max-height: 80vh !important;
    background-color: #fff !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    animation: slideIn 0.2s ease-out !important;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* هدر پاپ‌آپ */
.wgc-popup-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px 20px !important;
    border-bottom: 1px solid #eee !important;
    background: #f9f9f9 !important;
}

.wgc-popup-title {
    font-size: 18px !important;
    font-weight: 600 !important;
    color: #333 !important;
}

.wgc-popup-close {
    font-size: 24px !important;
    cursor: pointer !important;
    color: #999 !important;
    transition: all 0.3s ease !important;
    line-height: 1 !important;
    padding: 5px !important;
}

.wgc-popup-close:hover {
    color: #e74c3c !important;
    transform: rotate(90deg) !important;
}

/* ═══════════════════════════════════════════════════════════
   🔍 نوار جستجو - با دکمه در کنار
   ═══════════════════════════════════════════════════════════ */

.wgc-popup-search {
    padding: 15px 20px !important;
    background: #fff !important;
    border-bottom: 1px solid #eee !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.wgc-search-input {
    flex: 1 !important;
    padding: 10px 15px !important;
    border: 1px solid #ddd !important;
    border-radius: 5px !important;
    font-size: 14px !important;
    transition: border-color 0.3s ease !important;
}

.wgc-search-input:focus {
    outline: none !important;
    border-color: #602aeac9 !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
}

/* دکمه جستجو */
.wgc-search-button {
	border: 2px #155724 ;
    padding: 10px 20px !important;
    background: #faf8f8 !important;
    color: rgb(102, 95, 95) !important;
    border-radius: 5px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.wgc-search-button:hover {
    background: #e3e6e3 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3) !important;
}

.wgc-search-button:active {
    transform: translateY(0) !important;
}

/* Loader جستجو */
.wgc-search-loader {
    text-align: center !important;
    padding: 40px 20px !important;
    display: none !important;
}

.wgc-search-loader .wgc-spinner {
    margin: 0 auto 15px !important;
}

.wgc-search-loader p {
    color: #666 !important;
    font-size: 14px !important;
}

/* ═══════════════════════════════════════════════════════════
   📑 تب‌ها + Pagination در یک ردیف
   ═══════════════════════════════════════════════════════════ */

.wgc-popup-tabs {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    border-bottom: 1px solid #eee !important;
    background: #fff !important;
    padding: 0 !important;
}

/* تب‌ها در سمت راست */
.wgc-tab {
    padding: 12px 20px !important;
    cursor: pointer !important;
    font-weight: 500 !important;
    color: #666 !important;
    transition: all 0.3s ease !important;
    border-bottom: 3px solid transparent !important;
    background: transparent !important;
}

.wgc-tab:hover {
    color: #333 !important;
    background: #f9f9f9 !important;
}

.wgc-tab.active {
    border-bottom-color: #602aeac9 !important;
    color: #602aeac9 !important;
    background: #fff !important;
}

/* Pagination در سمت چپ (انتهای ردیف) */
.wgc-pagination-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 15px !important;
    margin-right: auto !important; /* ✅ این خط کلیدی است */
}

.wgc-page-btn {
    padding: 6px 12px !important;
    background: #fff !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    color: #333 !important;
}

.wgc-page-btn:hover:not(:disabled) {
    background: #f5f5f5 !important;
    border-color: #999 !important;
}

.wgc-page-btn:disabled {
    opacity: 0.4 !important;
    cursor: not-allowed !important;
}

.wgc-page-info {
    font-size: 13px !important;
    color: #666 !important;
    white-space: nowrap !important;
}

.wgc-current-page {
    font-weight: 600 !important;
    color: #602aeac9 !important;
}

/* ═══════════════════════════════════════════════════════════
   📱 Responsive برای موبایل
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .wgc-popup-tabs {
        flex-direction: column !important;
        align-items: stretch !important;
    }
    
    .wgc-pagination-wrapper {
        margin-right: 0 !important;
        justify-content: center !important;
        border-top: 1px solid #eee !important;
        padding-top: 12px !important;
        width: 100% !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   🛍️ گرید محصولات در پاپ‌آپ
   ═══════════════════════════════════════════════════════════════ */

.wgc-products-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)) !important;
    gap: 20px !important;
    padding: 10px 0 !important;
}

.wgc-product-item {
    background: #fff !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 8px !important;
    padding: 15px !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    flex-direction: column !important;
}

.wgc-product-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
    transform: translateY(-2px) !important;
}

/* تصویر محصول */
.wgc-product-image {
    margin-bottom: 12px !important;
    text-align: center !important;
    overflow: hidden !important;
    border-radius: 6px !important;
    background: #f5f5f5 !important;
}

.wgc-product-image img {
    width: 100% !important;
    height: auto !important;
    display: block !important;
    transition: opacity 0.3s ease !important;
}

/* 🖼️ Lazy Loading Images */
.wgc-product-item img[data-src] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%) !important;
    background-size: 200% 100% !important;
    animation: shimmer 1.5s infinite !important;
    min-height: 150px !important;
    opacity: 0.6 !important;
}

.wgc-product-item img.loaded {
    opacity: 1 !important;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* عنوان محصول */
.wgc-product-title {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin-bottom: 8px !important;
    min-height: 42px !important;
    line-height: 1.4 !important;
    text-align: center !important;
}

/* جزئیات محصول */
.wgc-product-details {
    font-size: 13px !important;
    color: #666 !important;
    margin-bottom: 12px !important;
    text-align: center !important;
}

/* کد اشتراکی */
.wgc-shared-code {
    display: inline-block !important;
    padding: 2px 8px !important;
    border-radius: 3px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    color: #fff !important;
    margin-right: 5px !important;
    background: #602aeac9 !important;
}

/* ═══════════════════════════════════════════════════════════════
   🎛️ ویژگی‌ها (Attributes)
   ═══════════════════════════════════════════════════════════════ */

.wgc-popup-attributes {
    margin: 10px 0 !important;
    min-height: 50px !important;
    text-align: right !important;
}

.wgc-attributes-wrapper {
    text-align: right !important;
}

.wgc-attribute-group {
    margin-bottom: 10px !important;
}

.wgc-attribute-label {
    display: block !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    color: #555 !important;
    margin-bottom: 5px !important;
    text-align: right !important;
}

.wgc-attribute-select {
    width: 100% !important;
    padding: 8px 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 13px !important;
    background-color: #fff !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    direction: rtl !important;
}

.wgc-attribute-select:focus {
    outline: none !important;
    border-color: #602aeac9 !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1) !important;
}

.wgc-attribute-select:hover {
    border-color: #bbb !important;
}

/* ⏳ حالت Loading */
.wgc-loading {
    display: inline-block !important;
    font-size: 16px !important;
    color: #999 !important;
    animation: pulse 1.5s ease-in-out infinite !important;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.wgc-no-attr {
    display: inline-block !important;
    font-size: 12px !important;
    color: #999 !important;
    font-style: italic !important;
}

.wgc-error {
    display: inline-block !important;
    color: #e74c3c !important;
    font-size: 12px !important;
    font-weight: 500 !important;
}

/* ═══════════════════════════════════════════════════════════════
   🎬 دکمه‌های اقدام در پاپ‌آپ
   ═══════════════════════════════════════════════════════════════ */

.wgc-product-actions {
    display: flex !important;
    gap: 8px !important;
    margin-top: auto !important;
}

/* دکمه افزودن در پاپ‌آپ */
.wgc-product-item button.wgc-add-product,
button.wgc-add-product {
    flex: 1 !important;
    padding: 10px 15px !important;
    background: #602aeac9 !important;
    background-color: #602aeac9 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 5px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    text-decoration: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
}

.wgc-product-item button.wgc-add-product:hover:not(:disabled),
button.wgc-add-product:hover:not(:disabled) {
    background: #602aeac9!important;
    background-color: #602aeac9!important;
    color: #fff !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3) !important;
}

.wgc-product-item button.wgc-add-product:active:not(:disabled),
button.wgc-add-product:active:not(:disabled) {
    transform: translateY(0) !important;
}

.wgc-product-item button.wgc-add-product:disabled,
button.wgc-add-product:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
}

/* ✅ دکمه اضافه شده */
.wgc-product-item button.wgc-add-product.wgc-added,
button.wgc-add-product.wgc-added {
    background: #27ae60 !important;
    background-color: #27ae60 !important;
    color: white !important;
    cursor: default !important;
    animation: successPulse 0.6s ease !important;
}

@keyframes successPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

/* لینک مشاهده محصول */
.wgc-product-actions a {
    padding: 10px 15px !important;
    background: #95a5a6 !important;
    background-color: #95a5a6 !important;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 5px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    text-align: center !important;
}

.wgc-product-actions a:hover {
    background: #7f8c8d !important;
    background-color: #7f8c8d !important;
    color: #fff !important;
    transform: translateY(-1px) !important;
}

/* ═══════════════════════════════════════════════════════════════
   📱 ریسپانسیو (تبلت)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 992px) {
    .wgc-products-grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .wgc-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }

    .wgc-popup-container {
        width: 95% !important;
        max-height: 85vh !important;
    }

    .wgc-popup-header {
        padding: 12px 15px !important;
    }

    .wgc-popup-title {
        font-size: 16px !important;
    }

    .wgc-popup-tabs {
        overflow-x: auto !important;
        flex-wrap: nowrap !important;
    }

    .wgc-tab {
        flex-shrink: 0 !important;
        padding: 10px 16px !important;
        font-size: 14px !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   📱 ریسپانسیو (موبایل)
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .wgc-product-section {
        padding: 12px !important;
        border-radius: 6px !important;
        margin: 12px 0 !important;
    }

    .wgc-section-title {
        font-size: 14px !important;
    }

    .wgc-add-button {
        font-size: 13px !important;
        padding: 9px 14px !important;
    }

    .wgc-product-name {
        font-size: 13px !important;
    }

    .wgc-product-attribute span {
        font-size: 11px !important;
        padding: 2px 6px !important;
    }

    .wgc-popup-container {
        width: 100% !important;
        max-height: 90vh !important;
        border-radius: 0 !important;
    }

    /* محتوای پاپ‌آپ */
.wgc-popup-content {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 20px !important;
    background: #fafafa !important;
    max-height: calc(80vh - 200px) !important;
}

.wgc-tab-content {
    display: none !important;
}

.wgc-tab-content.active {
    display: block !important;
}

    .wgc-products-grid {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    .wgc-product-actions {
        flex-direction: column !important;
    }
}

/* ═══════════════════════════════════════════════════════════════
   🔧 فیلدهای مخفی و المان‌های کمکی
   ═══════════════════════════════════════════════════════════════ */

#wgc-max-products,
#wgc-required-product,
#wgc-required-message {
    display: none !important;
}

/* اسکرول‌بار سفارشی */
.wgc-popup-content::-webkit-scrollbar {
    width: 8px !important;
}

.wgc-popup-content::-webkit-scrollbar-track {
    background: #f1f1f1 !important;
}

.wgc-popup-content::-webkit-scrollbar-thumb {
    background: #c1c1c1 !important;
    border-radius: 4px !important;
}

.wgc-popup-content::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1 !important;
}

/* ═══════════════════════════════════════════════════════════════
   🎨 انیمیشن‌های اضافی
   ═══════════════════════════════════════════════════════════════ */

@keyframes pulseButton {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.wgc-add-button:focus {
    animation: pulseButton 0.5s ease !important;
}
    // ═══════════════════════════════════════════════════════════
    // 🔍 جستجوی Ajax لحظه‌ای + Pagination
    // ═══════════════════════════════════════════════════════════
    var currentPage = 1;
    var searchQuery = '';
    var searchTimeout = null;

    // ✅ کلیک روی دکمه جستجو
    $(document).on('click', '.wgc-search-button', function() {
        performSearch();
    });

    // ✅ Enter در نوار جستجو
    $(document).on('keypress', '#wgc-search-input', function(e) {
        if (e.which === 13) {
            e.preventDefault();
            performSearch();
        }
    });

    // ✅ جستجوی لحظه‌ای (با تاخیر 500ms)
    $(document).on('input', '#wgc-search-input', function() {
        var query = $(this).val().trim();
        
        clearTimeout(searchTimeout);
        
        if (query.length >= 2) {
            searchTimeout = setTimeout(function() {
                searchQuery = query;
                currentPage = 1;
                loadProducts();
            }, 500); // تاخیر 500ms
        } else if (query.length === 0) {
            // اگر کاربر همه را پاک کرد، محصولات اولیه را نمایش بده
            searchQuery = '';
            currentPage = 1;
            loadProducts();
        }
    });

    // ✅ دکمه صفحه بعد
    $(document).on('click', '.wgc-next-page', function() {
        if (!$(this).prop('disabled')) {
            currentPage++;
            loadProducts();
        }
    });

    // ✅ دکمه صفحه قبل
    $(document).on('click', '.wgc-prev-page', function() {
        if (!$(this).prop('disabled')) {
            currentPage--;
            loadProducts();
        }
    });

    // ✅ تابع جستجو
    function performSearch() {
        searchQuery = $('#wgc-search-input').val().trim();
        currentPage = 1;
        loadProducts();
    }

    // ✅ تابع بارگذاری محصولات
    function loadProducts() {
        var $grid = $('.wgc-tab-content-shop .wgc-products-grid');
        var $loader = $('.wgc-search-loader');
        
        // نمایش Loader
        $loader.fadeIn(150);
        $grid.css('opacity', '0.5');

        $.ajax({
            url: wgc_data.ajax_url,
            type: 'POST',
            data: {
                action: 'wgc_search_products',
                nonce: wgc_data.nonce,
                search: searchQuery,
                page: currentPage,
                categories: window.wgcPopupSettings.shopCategories
            },
            success: function(response) {
                if (response.success) {
                    $grid.html(response.data.html);
                    
                    // ✅ آپدیت Pagination
                    $('.wgc-current-page').text(response.data.current_page);
                    $('.wgc-total-pages').text(response.data.total_pages);
                    
                    // ✅ فعال/غیرفعال کردن دکمه‌ها
                    $('.wgc-prev-page').prop('disabled', response.data.current_page <= 1);
                    $('.wgc-next-page').prop('disabled', response.data.current_page >= response.data.total_pages);
                    
                    // ✅ Lazy Load تصاویر جدید
                    enableLazyLoadImages();
                    
                    // ✅ بارگذاری Attributes
                    loadPopupAttributesBulk();
                    
                    console.log('✅ محصولات بارگذاری شدند:', response.data.found_posts, 'محصول');
                } else {
                    $grid.html('<p class="wgc-no-results">خطا در بارگذاری محصولات</p>');
                }
            },
            error: function() {
                $grid.html('<p class="wgc-no-results">خطا در ارتباط با سرور</p>');
            },
            complete: function() {
                $loader.fadeOut(200);
                $grid.css('opacity', '1');
            }
        });
    }

    // ✅ ریست کردن جستجو هنگام تعویض تب
    $(document).on('click', '.wgc-tab', function() {
        var tab = $(this).data('tab');
        
        if (tab === 'shop') {
            // اگر روی تب فروشگاه کلیک شد، جستجو را ریست نکن
            // فقط pagination را ریست کن
            if (currentPage !== 1 || searchQuery !== '') {
                currentPage = 1;
                // جستجو را خالی نکن، فقط به صفحه 1 برو
            }
        }
    });
});
/* ═══════════════════════════════════════════════════════════════════════
   🔔 استایل ناتیف سفارشی سازگار با Woodmart
   ═══════════════════════════════════════════════════════════════════════ */

.wgc-custom-notice {
    position: relative;
    padding: 15px 45px 15px 20px;
    margin: 15px 0;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    animation: wgc-notice-slide-in 0.4s ease-out;
}

.wgc-custom-notice.woocommerce-message {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-right: 4px solid #28a745;
    color: #155724;
}

.wgc-custom-notice.woocommerce-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border-right: 4px solid #dc3545;
    color: #721c24;
}

.wgc-custom-notice .wd-notice-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wgc-custom-notice .wd-notice-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
}

.wgc-custom-notice.woocommerce-message .wd-notice-icon {
    background-color: #28a745;
    color: white;
}

.wgc-custom-notice.woocommerce-error .wd-notice-icon {
    background-color: #dc3545;
    color: white;
}

.wgc-custom-notice .wd-notice-close {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    opacity: 0.6;
    transition: opacity 0.3s ease;
    line-height: 1;
}

.wgc-custom-notice .wd-notice-close:hover {
    opacity: 1;
}

/* انیمیشن ورود */
@keyframes wgc-notice-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════════════════════════════════════════════════════
   🔔 پیام موفقیت/خطا - Fixed Position
   ═══════════════════════════════════════════════════════════ */
#wgc-notice-wrapper {
    position: fixed !important;
    top: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 2147483647 !important; /* بالاترین مقدار ممکن */
    width: auto !important;
    max-width: 90% !important;
    min-width: 300px !important;
    pointer-events: auto !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.wgc-custom-notice {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* انیمیشن ورود */
@keyframes wgcNoticeSlide {
    0% {
        opacity: 0;
        transform: translateY(-30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}
