/* استایل‌های اصلی */
.aps-widget-container {
    position: relative;
    direction: rtl;
    font-family: 'Vazir', 'IRANSans', 'Tahoma', sans-serif;
    text-align: right;
    z-index: 10;
}

/* افکت بلور پس‌زمینه */
body.aps-overlay-active {
    overflow: hidden;
}

.aps-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 9;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.aps-overlay.active {
    opacity: 1;
    visibility: visible;
}

.aps-search-container {
    position: relative;
    background: #ffffff;
    border-radius: 10px;
    overflow: visible;
    box-shadow: 0 5px 5px rgb(0 0 0 / 15%);
    transition: all 0.3s ease;
    z-index: 11;
}

.aps-search-container.active {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 10px 10px 0 0;
}


.aps-row {
    display: flex;
    align-items: center;
}

.aps-search-row {
    display: block;
    border-bottom: 1px solid #f0f0f0;
    padding: 5px;
}

.aps-search-input-wrapper {
    position: relative; 
    display: flex;
    align-items: center;
    width: 100%;
}

.aps-search-input {
    font-family: 'yekanbakhfanum-regul';
    width: 100%;
    border: none !important;
    outline: none;
    font-size: 16px;
    background-color: #f8f9fa;
    color: #333;
    padding: 12px 20px 12px 65px; 
    text-align: right;
    border-radius: 6px;
}

.aps-search-input:focus {
    box-shadow: none;
}

.aps-search-input::placeholder {
    color: #999;
}

/* موقعیت‌دهی آیکن جستجو */
.aps-search-icon-positioner {
    position: absolute;
    left: 0px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
}

.aps-search-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

/* استایل آیکن‌های SVG با Mask */
.aps-search-icon, .aps-category-icon {
    display: block;
    width: 20px;
    height: 20px;
    background-color: #555;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

/* انیمیشن نبض */
@keyframes aps-pulse-animation {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05); /* کمی بزرگتر برای جلوه بهتر */
    }
    100% {
        transform: scale(1);
    }
}

.aps-icon-animated .aps-search-icon-wrapper {
    animation-name: aps-pulse-animation;
    animation-iteration-count: infinite;
    animation-timing-function: ease-in-out;
}


/* محتوای دراپ‌دون */
.aps-dropdown-content {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: none;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 12;
    max-height: 520px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.aps-dropdown-content.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* تب‌ها */
.aps-tabs-row {
    flex-shrink: 0;
    padding: 10px;
}

.aps-tab-container {
    display: flex;
    width: 100%;
}

.aps-tab {
    font-family: 'yekanbakhfanum-regul';
    font-weight: bold;
    width: 50%;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    color: #fb743e;
    border: 2px solid #fb743e;
    background-color: #fff;
    transition: all 0.2s ease;
    flex-grow: 1;
    text-align: center;
}

.aps-tab.aps-results-tab {
    border-radius: 0 10px 10px 0;
    border-left-width: 0.5px;
}

.aps-tab.aps-recent-tab {
    border-radius: 10px 0 0 10px;
    border-right-width: 0.5px;
}

.aps-tab.active {
    color: #fff;
    background-color: #fb743e;
    border: 2px solid #fb743e;
}

.aps-tab:hover:not(.active) {
    background-color: #e9ecef;
}

.aps-tab.aps-close-categories-tab {
    font-weight: bold;
    flex-direction: row;
    justify-content: center;
    display: none;
    width: 100%;
    border-radius: 10px;
}

/* محتوای تب‌ها */
.aps-content-row {
    flex: 1;
    overflow: hidden;
    display: flex;
}

.aps-content-col {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.aps-tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
    padding: 10px;
}

.aps-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* گرید محصولات */
.aps-results-content {
    overflow: hidden;
}

.aps-products-grid {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 10px; /* بازگرداندن فاصله برای محاسبه دقیق */
    max-height: calc((80px + 10px) * 2.5); /* تغییر ارتفاع به ۲.۵ ردیف */
    padding: 0px 5px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.aps-products-grid::-webkit-scrollbar { width: 6px; }
.aps-products-grid::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.aps-products-grid::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
.aps-products-grid::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

.aps-product-item {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: #fff;
    cursor: pointer;
    flex-shrink: 0;
    will-change: transform, opacity;
    animation: aps-fadeInUp 0.3s ease forwards;
    opacity: 0;
    transform: translateY(20px);
    display: flex;
    align-items: center;
}

.aps-initial-prompt {
    text-align: center;
    padding: 30px 20px;
    color: #999;
    flex-shrink: 0;
}

.aps-product-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.aps-product-image {
    position: relative;
    width: 80px;
    height: 80px;
    padding: 5px;
    overflow: hidden;
    flex-shrink: 0;
    margin-left: 12px;
    border-radius: 4px;
}

.aps-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.aps-product-item:hover .aps-product-image img { transform: scale(1.05); }

.aps-sale-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ff4444;
    color: white;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: bold;
}

.aps-product-info {
    padding: 0;
    flex-grow: 1;
}

.aps-product-title {
    font-size: 13px;
    font-weight: bold;
    color: #333;
    margin-bottom: 6px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.aps-product-price { font-size: 14px; font-weight: bold; color: #fb743e; margin-bottom: 4px;font-family: 'yekanbakhfanum-regul'; }
.aps-product-rating { font-size: 11px; }

/* جستجوهای اخیر */
.aps-recent-content { overflow: hidden; }
.aps-recent-searches { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; max-height: 300px; padding-right: 5px; scroll-behavior: smooth; scrollbar-width: thin; scrollbar-color: #c1c1c1 #f1f1f1; }
.aps-recent-searches::-webkit-scrollbar { width: 6px; }
.aps-recent-searches::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.aps-recent-searches::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
.aps-recent-searches::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }

.aps-recent-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 13px;
    color: #333;
    flex-shrink: 0;
}
.aps-recent-item:hover { background: #e9ecef; }
.aps-recent-term { font-family: 'yekanbakhfanum-regul'; }
.aps-recent-date {
    font-size: 11px;
    font-family: 'yekanbakhfanum-regul';
    color: #777;
    direction: ltr;
    text-align: left;
}


/* دسته‌ها */
.aps-categories-content { overflow: hidden; }
/* START: تغییرات استایل برای فیلترهای فعال */
.aps-active-filters-row {
    padding: 0 0 10px 0;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 10px;
    flex-shrink: 0;
}

/* این استایل لیست را دقیقا مانند دسته‌های پیشنهادی، افقی و اسکرولی می‌کند */
.aps-active-filters-list {
    display: flex;
    flex-wrap: nowrap;     /* جلوگیری از شکستن خط */
    align-items: center;   /* جلوگیری از کش آمدن عمودی آیتم‌ها */
    gap: 8px;              /* فاصله بین آیتم‌ها */
    overflow-x: auto;      /* فعال کردن اسکرول افقی */
    padding-bottom: 10px;  /* ایجاد فضا برای اسکرول‌بار */
    scrollbar-width: thin; /* استایل اسکرول‌بار برای فایرفاکس */
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.aps-active-filters-list::-webkit-scrollbar {
    height: 6px;
}

.aps-active-filters-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.aps-active-filters-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.aps-active-filters-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.aps-active-filter-item {
    background-color: #fb743e;
    color: #fff;
    padding: 4px 10px;
    border-radius: 15px;
    display: inline-flex;
    align-items: center;
    font-weight: normal;
    font-size: 12px;
    flex-shrink: 0; /* جلوگیری از کوچک شدن آیتم‌ها */
}

.aps-remove-filter-icon {
    font-style: normal;
    font-weight: bold;
    margin-right: 6px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.aps-remove-filter-icon:hover {
    opacity: 1;
}
/* END: تغییرات استایل */

.aps-category-search-wrapper { margin-bottom: 15px; flex-shrink: 0; }
.aps-category-search { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: 5px; font-size: 13px; outline: none;font-family: 'yekanbakhfanum-regul'; height: 45px; }
.aps-category-search:focus { border-color: #fb743e; box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.3); }
.aps-category-search::placeholder { text-align: center; color: #999; }

.aps-categories-list {
    overflow-y: auto;
    max-height: 200px;
    padding-right: 5px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

.aps-categories-list::-webkit-scrollbar { width: 6px; }
.aps-categories-list::-webkit-scrollbar-track { background: #f1f1f1; border-radius: 3px; }
.aps-categories-list::-webkit-scrollbar-thumb { background: #c1c1c1; border-radius: 3px; }
.aps-categories-list::-webkit-scrollbar-thumb:hover { background: #a8a8a8; }
.aps-category-item { display: flex; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0f0f0; cursor: pointer; flex-shrink: 0; }
.aps-category-item:last-child { border-bottom: none; }
.aps-category-checkbox { margin-right: 8px; margin-left: 0; }
.aps-category-name { flex: 1; font-size: 13px; color: #333;font-family: 'yekanbakhfanum-regul'; }
.aps-category-count { font-size: 12px;
    font-family: 'yekanbakhfanum-regul';
    color: #ffffff;
    background: #fb743e;
    padding: 2px 5px;
    width: 20px;
    text-align: center;
    height: 20px;
    border-radius: 5px; }

/* فوتر و دکمه مشاهده همه */
.aps-footer-row {
    flex-shrink: 0;
    padding: 5px;
    display: flex;
    align-items: center;
    background-color: #fff;
    justify-content: space-between;
}

.aps-category-col {
    flex: 1;
    border-left: none;
}

.aps-category-selector {
    cursor: pointer;
    display: flex;
    width: fit-content;
    align-items: center;
    background-color: #fb743e;
    padding: 10px 15px;
    border-radius: 10px;
    justify-content: flex-start;
}

.aps-category-text {
    font-weight: bold;
    font-size: 13px;
    color: #fff;
    margin-right: 10px; /* ایجاد فاصله بین متن و آیکن */
    font-family: 'yekanbakhfanum-regul';
}

/* حذف استایل‌های قدیمی */
.aps-category-selector::before,
.aps-dropdown-icon {
    display: none;
    content: none;
}

.aps-view-all-btn {
    flex: 1;
    text-align: left;
    padding: 0;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.aps-view-all-btn:hover { background: transparent; }

.aps-view-all-text {
    color: #fff;
    font-weight: bold;
    background-color: #fb743e;
    border-radius: 10px;
    padding: 10px 15px;
    font-family: 'yekanbakhfanum-regul';
    font-size: 13px;
}

/* لودینگ و پیام‌ها */
.aps-loading { text-align: center; padding: 30px 0; flex-shrink: 0; }
.aps-spinner { width: 30px; height: 30px; border: 3px solid #f3f3f3; border-top: 3px solid #fb743e; border-radius: 50%; animation: aps-spin 1s linear infinite; margin: 0 auto; }
@keyframes aps-spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.aps-no-results { text-align: center; padding: 30px 20px; color: #999; flex-shrink: 0; }
.aps-empty-message { text-align: center; padding: 20px; color: #999; font-style: italic; font-size: 13px; }

/* انیمیشن محصولات */
@keyframes aps-fadeInUp { to { opacity: 1; transform: translateY(0); } }
.aps-product-item:nth-child(1) { animation-delay: 0.05s; }
.aps-product-item:nth-child(2) { animation-delay: 0.1s; }
.aps-product-item:nth-child(3) { animation-delay: 0.15s; }
.aps-product-item:nth-child(4) { animation-delay: 0.2s; }
.aps-product-item:nth-child(5) { animation-delay: 0.25s; }
.aps-product-item:nth-child(6) { animation-delay: 0.3s; }

/* Focus states */
.aps-tab:focus,
.aps-recent-item:focus,
.aps-category-item:focus,
.aps-product-item:focus {
    outline: 2px solid #fb743e;
    outline-offset: 2px;
}

/* Z-index المنتور */
.elementor-widget-advanced_product_search { z-index: 10; }
.elementor-widget-advanced_product_search .aps-search-container { z-index: 11; }
.elementor-widget-advanced_product_search .aps-dropdown-content { z-index: 12; }

/* استایل‌های بخش دسته‌های پیشنهادی */
.aps-suggested-categories-row {
    padding: 10px 15px 5px 15px;
    flex-shrink: 0;
}

.aps-suggested-title {
    font-size: 13px;
    font-weight: bold;
    color: #555;
    margin: 0 0 8px 0;
    font-family: 'yekanbakhfanum-regul', sans-serif;
}

.aps-suggested-categories-list {
    display: flex;
    flex-wrap: nowrap; 
    gap: 8px;
    overflow-x: auto; 
    padding-bottom: 10px; 
    scrollbar-width: thin; 
    scrollbar-color: #c1c1c1 #f1f1f1; 
}

.aps-suggested-categories-list::-webkit-scrollbar {
    height: 6px; 
}

.aps-suggested-categories-list::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.aps-suggested-categories-list::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.aps-suggested-categories-list::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.aps-suggested-category-item {
    background-color: #e9ecef;
    color: #495057;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-family: 'yekanbakhfanum-regul', sans-serif;
    white-space: nowrap; 
}

.aps-suggested-category-item:hover {
    background-color: #fb743e;
    color: #ffffff;
}

.aps-highlight {
    background-color: #FFFDE7; /* یک زرد بسیار روشن */
    font-weight: bold;
    color: #5d4037; /* قهوه‌ای برای خوانایی بهتر */
    padding: 0 2px;
    border-radius: 3px;
    white-space: nowrap; /* این خط اضافه شده و از شکستن خط جلوگیری می‌کند */
}

.aps-suggested-category-count {
    font-size: 0.9em;
    color: #777;
    margin-right: 4px;
}