/**
 * استایل‌های ویجت جستجوی محصولات
 * Search Widget Styles
 */

/* Wrapper فرم جستجو */
.cpc-search-form-wrapper {
    width: 100%;
    margin-bottom: 30px;
    padding: 0;
    box-sizing: border-box;
}

/* سازگاری با وودمارت - رفع مشکل عرض و ارتفاع */
.elementor-widget-html .cpc-search-form-wrapper,
.wd-html-block .cpc-search-form-wrapper,
.woodmart-html-block .cpc-search-form-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    display: block !important;
    box-sizing: border-box !important;
}

/* فرم جستجو */
.cpc-search-form {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    align-items: stretch;
    position: relative;
    box-sizing: border-box;
}

.cpc-search-form-full-width {
    max-width: 100% !important;
}

/* سازگاری با وودمارت - رفع مشکل عرض و ارتفاع در بلوک HTML */
.elementor-widget-html .cpc-search-form,
.wd-html-block .cpc-search-form,
.woodmart-html-block .cpc-search-form {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    box-sizing: border-box !important;
    margin: 0 !important;
}

/* Wrapper فیلد ورودی */
.cpc-search-input-wrapper {
    flex: 1;
    position: relative;
    min-width: 0;
    box-sizing: border-box;
}

/* سازگاری با وودمارت */
.elementor-widget-html .cpc-search-input-wrapper,
.wd-html-block .cpc-search-input-wrapper,
.woodmart-html-block .cpc-search-input-wrapper {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    width: auto !important;
    max-width: none !important;
    height: auto !important;
    box-sizing: border-box !important;
}

/* فیلد ورودی جستجو */
.cpc-search-form input[type="search"],
.cpc-search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: all 0.3s ease;
    background-color: #ffffff;
    color: #333;
    font-family: inherit;
    box-sizing: border-box;
    min-width: 0;
    height: auto;
    line-height: 1.5;
}

/* سازگاری با وودمارت */
.elementor-widget-html .cpc-search-form input[type="search"],
.elementor-widget-html .cpc-search-input,
.wd-html-block .cpc-search-form input[type="search"],
.wd-html-block .cpc-search-input,
.woodmart-html-block .cpc-search-form input[type="search"],
.woodmart-html-block .cpc-search-input {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    box-sizing: border-box !important;
    display: block !important;
    line-height: 1.5 !important;
}

.cpc-search-form input[type="search"]:focus,
.cpc-search-input:focus {
    border-color: #ddd;
    box-shadow: none;
    outline: none;
}

.cpc-search-form input[type="search"]::placeholder,
.cpc-search-input::placeholder {
    color: #999;
    opacity: 1;
}

/* دکمه جستجو */
.cpc-search-button {
    padding: 12px 20px !important;
    font-size: 18px !important;
    border: none !important;
    border-radius: 8px !important;
    background-color: #333 !important;
    color: #ffffff !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 50px !important;
    font-family: inherit !important;
    box-sizing: border-box !important;
    height: auto !important;
    flex-shrink: 0 !important;
}

/* سازگاری با وودمارت */
.elementor-widget-html .cpc-search-button,
.wd-html-block .cpc-search-button,
.woodmart-html-block .cpc-search-button {
    width: auto !important;
    min-width: 50px !important;
    max-width: none !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.cpc-search-button:hover {
    background-color: #555;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.cpc-search-button:active {
    transform: translateY(0);
}

.cpc-search-button i {
    font-size: 18px;
    line-height: 1;
}

/* پیشنهادات جستجو */
.cpc-search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 500px;
    overflow: hidden;
    z-index: 1000;
    margin-top: -1px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

/* لیست پیشنهادات - Grid 2 ستونه */
.cpc-search-suggestions-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 12px;
    overflow-y: auto;
    max-height: 420px;
    flex: 1;
}

/* موبایل - یک ستون کامل */
@media (max-width: 768px) {
    .cpc-search-suggestions-list {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }
}

.cpc-search-suggestions-item {
    cursor: pointer;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    padding: 0;
}

.cpc-search-suggestions-item:not(.cpc-product-item) {
    padding: 12px 16px;
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.cpc-search-suggestions-item:hover:not(.cpc-product-item),
.cpc-search-suggestions-item.cpc-active:not(.cpc-product-item) {
    border-color: #0066cc;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.15);
    transform: translateY(-1px);
}

/* Simple text suggestions (fallback) */
.cpc-search-suggestions-item:not(.cpc-product-item) {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cpc-search-suggestions-item:not(.cpc-product-item) i {
    color: #999;
    font-size: 14px;
}

.cpc-search-suggestions-item:not(.cpc-product-item) .cpc-search-suggestions-item-text {
    flex: 1;
    color: #333;
    font-size: 14px;
}

.cpc-search-suggestions-loading {
    padding: 12px 16px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

.cpc-search-suggestions-empty {
    padding: 12px 16px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* استایل برای آیتم‌های محصول در پیشنهادات - طراحی ردیفی (کوچک و فشرده) */
.cpc-search-suggestions-item.cpc-product-item {
    padding: 0 !important;
    height: auto !important;
    max-height: 90px !important;
    display: block !important;
    overflow: hidden !important;
}

.cpc-search-suggestions-item.cpc-product-item a {
    display: block;
    padding: 0;
    text-decoration: none;
    color: #333;
    transition: all 0.2s ease;
    height: 100%;
}

.cpc-search-suggestions-item.cpc-product-item:hover,
.cpc-search-suggestions-item.cpc-product-item.cpc-active {
    border-color: #0066cc;
    box-shadow: 0 2px 8px rgba(0, 102, 204, 0.2);
    transform: translateY(-1px);
}

.cpc-search-suggestions-item.cpc-product-item:hover a,
.cpc-search-suggestions-item.cpc-product-item.cpc-active a {
    color: #333;
}

/* تراز کردن محتوای محصول - طراحی ردیفی - بهینه شده برای اندازه کوچک‌تر */
.cpc-search-suggestions-item.cpc-product-item .cpc-product-card,
.cpc-search-suggestions-item.cpc-product-item .cpc-card {
    width: 100% !important;
    height: auto !important;
    max-height: 90px !important;
    margin: 0 !important;
    border: none !important;
    box-shadow: none !important;
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px !important;
    min-height: auto !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-card-image,
.cpc-search-suggestions-item.cpc-product-item .cpc-thumb-wrapper {
    flex-shrink: 0 !important;
    width: 70px !important;
    height: 70px !important;
    min-width: 70px !important;
    min-height: 70px !important;
    max-width: 70px !important;
    max-height: 70px !important;
    margin: 0 !important;
    overflow: hidden !important;
    border-radius: 6px !important;
    position: relative !important;
    aspect-ratio: 1 !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-card-image img,
.cpc-search-suggestions-item.cpc-product-item .cpc-thumb-wrapper img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 6px !important;
    display: block !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-card-content,
.cpc-search-suggestions-item.cpc-product-item .cpc-meta {
    flex: 1 !important;
    min-width: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 4px !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-card-title,
.cpc-search-suggestions-item.cpc-product-item .cpc-title {
    font-size: 13px !important;
    line-height: 1.3 !important;
    margin: 0 0 4px 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    max-height: 2.6em !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-card-title a,
.cpc-search-suggestions-item.cpc-product-item .cpc-title a {
    font-size: 13px !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
    color: #333 !important;
    text-decoration: none !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-card-price,
.cpc-search-suggestions-item.cpc-product-item .cpc-meta-content {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 6px !important;
    font-size: 12px !important;
    margin: 0 !important;
    padding: 0 !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-price-left,
.cpc-search-suggestions-item.cpc-product-item .cpc-meta-left {
    font-size: 12px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-rating-right,
.cpc-search-suggestions-item.cpc-product-item .cpc-meta-right {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-rating-wrapper {
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-rating-number {
    font-size: 11px !important;
    line-height: 1 !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-star-img {
    width: 12px !important;
    height: 12px !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-discount-badge {
    font-size: 10px !important;
    padding: 2px 5px !important;
    background: #ff4444 !important;
    color: #fff !important;
    border-radius: 3px !important;
    line-height: 1 !important;
}

.cpc-search-suggestions-item.cpc-product-item .cpc-sale-badge {
    font-size: 9px !important;
    padding: 2px 5px !important;
    top: 3px !important;
    right: 3px !important;
    line-height: 1 !important;
}

/* مخفی کردن عناصر اضافی در پیشنهادات */
.cpc-search-suggestions-item.cpc-product-item .cpc-info-boxes,
.cpc-search-suggestions-item.cpc-product-item .cpc-info-box {
    display: none !important;
}

/* جلوگیری از override شدن توسط استایل‌های موبایل */
@media (max-width: 768px) {
    .cpc-search-suggestions-item.cpc-product-item .cpc-product-card,
    .cpc-search-suggestions-item.cpc-product-item .cpc-card {
        max-height: 90px !important;
        padding: 8px !important;
        flex-direction: row !important;
    }
    
    .cpc-search-suggestions-item.cpc-product-item .cpc-card-image,
    .cpc-search-suggestions-item.cpc-product-item .cpc-thumb-wrapper {
        width: 70px !important;
        height: 70px !important;
        min-width: 70px !important;
        min-height: 70px !important;
        max-width: 70px !important;
        max-height: 70px !important;
    }
}

/* Container اصلی نتایج جستجو */
.cpc-search-results {
    width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
}

/* سازگاری با وودمارت - رفع مشکل عرض و ارتفاع در نتایج */
.elementor-widget-html .cpc-search-results,
.wd-html-block .cpc-search-results,
.woodmart-html-block .cpc-search-results {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    box-sizing: border-box !important;
    display: grid !important;
}

/* پیام عدم وجود جستجو */
.cpc-search-no-query {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.cpc-search-no-query p {
    margin: 0;
    font-size: 16px;
}

/* پیام عدم یافتن نتیجه */
.cpc-search-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.cpc-search-no-results p {
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

/* تطبیق با گرید اصلی */
.cpc-search-results.cpc-products-grid {
    display: grid;
    gap: 20px;
    width: 100%;
}

/* ستون‌های مختلف */
.cpc-search-results.cpc-columns-1 {
    grid-template-columns: repeat(1, 1fr);
}

.cpc-search-results.cpc-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.cpc-search-results.cpc-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.cpc-search-results.cpc-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.cpc-search-results.cpc-columns-5 {
    grid-template-columns: repeat(5, 1fr);
}

.cpc-search-results.cpc-columns-6 {
    grid-template-columns: repeat(6, 1fr);
}

/* ریسپانسیو برای تبلت */
@media (max-width: 1024px) {
    .cpc-search-results.cpc-columns-4,
    .cpc-search-results.cpc-columns-5,
    .cpc-search-results.cpc-columns-6 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .cpc-search-results.cpc-columns-2,
    .cpc-search-results.cpc-columns-3,
    .cpc-search-results.cpc-columns-4,
    .cpc-search-results.cpc-columns-5,
    .cpc-search-results.cpc-columns-6 {
        grid-template-columns: 1fr !important;
    }
    
    .cpc-search-results {
        gap: 15px;
    }
}

/* موبایل */
@media (max-width: 480px) {
    .cpc-search-results.cpc-columns-2,
    .cpc-search-results.cpc-columns-3,
    .cpc-search-results.cpc-columns-4,
    .cpc-search-results.cpc-columns-5,
    .cpc-search-results.cpc-columns-6 {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .cpc-search-results {
        gap: 12px;
    }
    
    .cpc-search-no-query,
    .cpc-search-no-results {
        padding: 30px 15px;
    }
    
    .cpc-search-no-query p,
    .cpc-search-no-results p {
        font-size: 14px;
    }
    
    /* فرم جستجو در موبایل - دکمه و سرچ در یک خط */
    .cpc-search-form {
        flex-direction: row !important;
        max-width: 100%;
        gap: 8px;
    }
    
    .cpc-search-input-wrapper {
        flex: 1;
    }
    
    .cpc-search-button {
        width: auto !important;
        min-width: 50px !important;
        padding: 12px 16px !important;
    }
    
    .cpc-search-form-wrapper {
        margin-bottom: 20px;
    }
}

/* انیمیشن برای کارت‌های جستجو */
.cpc-search-results .cpc-product-card {
    animation: cpc-search-fade-in 0.3s ease-in;
}

@keyframes cpc-search-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* استایل برای حالت لودینگ (اگر نیاز باشد) */
.cpc-search-loading {
    text-align: center;
    padding: 40px 20px;
}

/* ============================================
   سازگاری با وودمارت - Override استایل‌های وودمارت
   ============================================ */

/* رفع مشکل عرض و ارتفاع در بلوک HTML وودمارت */
.elementor-widget-html .cpc-search-form-wrapper,
.elementor-widget-html .cpc-search-form,
.elementor-widget-html .cpc-search-results,
.wd-html-block .cpc-search-form-wrapper,
.wd-html-block .cpc-search-form,
.wd-html-block .cpc-search-results,
.woodmart-html-block .cpc-search-form-wrapper,
.woodmart-html-block .cpc-search-form,
.woodmart-html-block .cpc-search-results {
    /* Override وودمارت width/height restrictions */
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: auto !important;
    max-height: none !important;
    box-sizing: border-box !important;
}

/* رفع مشکل flex در وودمارت */
.elementor-widget-html .cpc-search-form,
.wd-html-block .cpc-search-form,
.woodmart-html-block .cpc-search-form {
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: flex-start !important;
}

/* رفع مشکل input در وودمارت */
.elementor-widget-html .cpc-search-input-wrapper,
.wd-html-block .cpc-search-input-wrapper,
.woodmart-html-block .cpc-search-input-wrapper {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    max-width: none !important;
}

/* رفع مشکل دکمه در وودمارت */
.elementor-widget-html .cpc-search-button,
.wd-html-block .cpc-search-button,
.woodmart-html-block .cpc-search-button {
    flex: 0 0 auto !important;
    width: auto !important;
}

/* رفع مشکل پیشنهادات در وودمارت */
.elementor-widget-html .cpc-search-suggestions,
.wd-html-block .cpc-search-suggestions,
.woodmart-html-block .cpc-search-suggestions {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    position: absolute !important;
    z-index: 9999 !important;
}

.cpc-search-loading::after {
    content: '';
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: cpc-search-spin 1s linear infinite;
}

@keyframes cpc-search-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* مجبور کردن ویجت المنتور به پر کردن ۱۰۰ درصد فضا */
.whb-col-center .elementor-widget__width-initial {
    width: 100% !important;
    max-width: 100% !important;
    flex-basis: 100% !important;
    flex-grow: 1 !important;
}

/* اطمینان از اینکه کانتینر داخلی ویجت هم باز میشه */
.whb-col-center .elementor-widget-container {
    width: 100% !important;
}
/* 1. ستون اصلی هدر وودمارت */
.whb-header-bottom .whb-col-center {
    flex: 1 !important; /* تمام فضای خالی را بگیر */
    width: 100% !important;
}

/* 2. بلوک HTML واسط وودمارت (این معمولا عامل اصلی بدبختی است!) */
.whb-header-bottom .whb-col-center .wd-header-html,
.whb-header-bottom .whb-col-center .wd-html-block {
    width: 100% !important;
    max-width: 100% !important;
    display: block !important; /* فلکس نباشد که جمع شود */
    flex: 1 !important;
}

/* 3. کانتینر اصلی المنتور داخل بلوک */
.whb-header-bottom .whb-col-center .elementor {
    width: 100% !important;
}

/* 4. سکشن‌ها و کانتینرهای المنتور */
.whb-header-bottom .whb-col-center .elementor-section,
.whb-header-bottom .whb-col-center .elementor-container,
.whb-header-bottom .whb-col-center .elementor-column,
.whb-header-bottom .whb-col-center .elementor-widget-wrap {
    width: 100% !important;
    max-width: 100% !important;
}

/* 5. خودِ ویجت المنتور (مهم: کلاس width-initial را خنثی می‌کنیم) */
.whb-header-bottom .whb-col-center .elementor-element,
.whb-header-bottom .whb-col-center .elementor-widget,
.whb-header-bottom .whb-col-center .elementor-widget__width-initial {
    width: 100% !important;
    max-width: 100% !important;
    flex-basis: 100% !important;
    flex-grow: 1 !important;
}

/* 6. فرم نهایی */
.cpc-search-form-wrapper,
.cpc-search-form {
    width: 100% !important;
    max-width: 100% !important;
}

/* رفع مشکل هدر در صفحه نتایج جستجو */
body.search .whb-header-bottom .whb-col-center,
body.search-results .whb-header-bottom .whb-col-center {
    flex: 0 0 auto !important;
    width: auto !important;
}

body.search .whb-header-bottom .whb-col-center .cpc-search-form-wrapper,
body.search-results .whb-header-bottom .whb-col-center .cpc-search-form-wrapper {
    max-width: 500px !important;
}

body.search .whb-header-bottom .whb-col-center .elementor-widget,
body.search-results .whb-header-bottom .whb-col-center .elementor-widget {
    width: auto !important;
    flex-grow: 0 !important;
}

/* حالت موبایل - نمایش افقی (ردیفی) محصولات در نتایج جستجو */
@media (max-width: 768px) {
    /* تک ستونه کردن گرید */
    .cpc-search-results.cpc-products-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    /* تبدیل کارت به حالت افقی */
    .cpc-search-results .cpc-product-card,
    .cpc-search-results .cpc-card {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 10px !important;
    }
    
    /* تصویر محصول - کوچک و مربعی */
    .cpc-search-results .cpc-card-image {
        flex-shrink: 0 !important;
        width: 100px !important;
        height: 100px !important;
        min-width: 100px !important;
        max-width: 100px !important;
    }
    
    .cpc-search-results .cpc-card-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
    
    /* محتوای کارت */
    .cpc-search-results .cpc-card-content {
        flex: 1 !important;
        min-width: 0 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
    }
    
    /* عنوان محصول */
    .cpc-search-results .cpc-card-title {
        font-size: 14px !important;
        line-height: 1.3 !important;
        margin: 0 !important;
    }
    
    /* قیمت و امتیاز */
    .cpc-search-results .cpc-card-price {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        margin: 0 !important;
    }
}
