/* hamyar-tools/assets/css/hmyt-ajax-search.css */
.hmyt-ajax-search-wrapper {
    position: relative;
    font-family: inherit;
    width: 100%;
}
.hmyt-ajax-search-form {
    display: flex !important;
    align-items: center;
    overflow: hidden;
    padding: 15px;
    position: relative !important;
    z-index: 101; /* Higher than results */
    background: #fff;
}

.hmyt-ajax-search-input {
    flex-grow: 1;
    border: 1px solid #dee1e9ee;
    border-radius: 8px !important;
    padding: 10px 45px 10px 15px !important;
    font-size: 16px;
    outline: none;
    background: transparent;
}

/* Hide the default browser 'x' in search inputs */
.hmyt-ajax-search-input::-webkit-search-decoration,
.hmyt-ajax-search-input::-webkit-search-cancel-button,
.hmyt-ajax-search-input::-webkit-search-results-button,
.hmyt-ajax-search-input::-webkit-search-results-decoration {
    -webkit-appearance:none;
}

.hmyt-ajax-search-button {
    position: absolute !important;
     /* Changed to left for RTL */
    top: 50% !important;
    transform: translateY(-50%);
    background-color: transparent !important;
    pointer-events: none;
    border: none !important;
    padding: 0 20px !important;
    cursor: pointer !important;
    display: flex !important;
    justify-content: center !important;
    height: 100%;
    color: #555;
}

.hmyt-ajax-search-clear svg {
    fill: #555;
}
/* --- Modern Flat Results Container --- */
.hmyt-ajax-search-results {
    background: #fff !important;
    border: 1px solid #e5e7eb; /* خاکستری خیلی ملایم */
    border-top: none;
    border-radius: 16px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01); /* سایه بسیار سافت و مدرن */
    max-height: 500px;
    overflow-y: auto;
    z-index: 102;
    display: none;
    padding: 8px 0; /* فاصله داخلی کلی */
}

.hmyt-results-list {
    list-style: none !important;
    margin: 0;
    padding: 0;
}

.hmyt-result-item {
    margin: 0;
    padding: 4px 8px; /* فاصله بین آیتم‌ها از دیواره */
}

/* --- Card Style --- */
.hmyt-result-card {
    display: flex;
    align-items: center;
    padding: 10px;
    text-decoration: none !important;
    color: #1f2937; /* خاکستری تیره */
    border-radius: 10px; /* آیتم‌ها هم گرد می‌شوند */
    transition: background-color 0.15s ease; /* فقط تغییر رنگ پس‌زمینه */
    gap: 12px;
    border: none !important; /* حذف بوردرهای خطی قدیمی */
}

.hmyt-result-card:hover {
    background-color: #f3f4f6; /* رنگ هاور خیلی ملایم */
}

/* --- Thumbnail & Placeholder --- */
.hmyt-card-thumbnail {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
}

.hmyt-card-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}

/* استایل آیکون جایگزین جدید */
.hmyt-card-placeholder {
    width: 100%;
    height: 100%;
    background-color: #e3e8ee; /* رنگ طوسی متناسب با آیکون سفید */
    display: flex;
    align-items: center;
    justify-content: center;
}

.hmyt-card-placeholder svg {
    width: 20px;
    height: 20px;
    opacity: 0.9;
}

/* --- Content Typography --- */
.hmyt-card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex-grow: 1;
    min-width: 0; /* جلوگیری از بهم ریختگی متن طولانی */
    gap: 2px;
}

.hmyt-card-title {
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.4;
}

.hmyt-card-excerpt {
    font-size: 12px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hmyt-card-price {
    font-size: 13px;
    font-weight: 600;
    color: #059669; /* سبز مدرن */
    margin-top: 2px;
    display: flex;
    align-items: center;
}

.hmyt-card-price del {
    color: #9ca3af;
    font-size: 0.9em;
    font-weight: 400;
    margin-left: 6px;
    opacity: 0.8;
}

.hmyt-card-price ins {
    text-decoration: none; /* حذف خط زیر */
    color: #059669;
    background: transparent;
}

/* حذف خط زیر از قیمت تخفیف‌خورده */
.hmyt-card-price ins {
    text-decoration: none;
    background: transparent; /* برای اطمینان از حذف پس‌زمینه در برخی قالب‌ها */
    font-weight: 700; /* کمی ضخیم‌تر برای تاکید بیشتر */
}

/* --- View All Button --- */
.hmyt-view-all-item {
    padding: 8px;
    margin-top: 4px;
    border-top: 1px solid #f3f4f6;
}

.hmyt-view-all-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background-color: #e3e8ee;
    color: #4b5563;
    font-weight: 600;
    font-size: 13px;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s;
}

.hmyt-view-all-link:hover {
    background-color: #e5e7eb;
    color: #111827;
}

/* -- Suggestions Styles -- */
.hmyt-suggestions-loaded { padding: 15px; }
.hmyt-suggestions-banner { margin-bottom: 15px; }
.hmyt-suggestions-banner img { width: 100%; height: auto; border-radius: 8px !important; display: block; }
.hmyt-suggestions-section { margin-bottom: 15px; }
.hmyt-suggestions-section:last-child { margin-bottom: 0; }
.hmyt-suggestions-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.hmyt-suggestions-title { font-size: 14px; font-weight: 600; color: #333; gap: 10px;}
.hmyt-reset-recent {
    font-size: 12px;
    color: #6b7280;
    display: flex;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.hmyt-suggestions-loaded > div svg {
    width: 20px;
    height: 20px;
    color: #6b7280;
}
.hmyt-suggestions-section:last-child {
    padding-top: 10px;
    border-top: 1px solid #ececec;
}
.hmyt-suggestions-list { display: flex; flex-wrap: wrap; gap: 8px; }
.hmyt-suggestion-item {
    border: 1px solid #6b7280 ;
    color: #3c434a;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.hmyt-suggestion-item svg {
    margin-right: auto; /* Pushes the icon to the end in RTL */
    opacity: 0.7;
    width: 15px !important;
}
.hmyt-suggestion-item:hover { background-color: #e0e2e5; }

.hmyt-ajax-search-submit {
    display: flex !important;
    flex-direction: column;
    justify-content: center !important;
    align-items: flex-end;
}

.hmyt-view-all-results a {
    display: block;
    text-align: center;
    padding: 12px 15px;
    background-color: #f8f9fa;
    color: #0073aa;
    font-weight: 600;
    text-decoration: none;
    font-size: 14px;
}
.hmyt-view-all-results a:hover {
    background-color: #f1f1f1;
    color: #005a87;
}
.hmyt-search-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 30px 0;
}

/* -- Site Overlay Styles -- */
body.hmyt-search-overlay-active {
    overflow: hidden !important; /* جلوگیری از اسکرول سایت */
}

/* استایل دیو مستقل اورلی */
.hmyt-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #00052a30; /* رنگ سیاه با شفافیت */
    backdrop-filter: blur(1px); /* افکت بلور */
    -webkit-backdrop-filter: blur(1px);
    z-index: 999999; /* باید کمتر از مودال (99999) و بیشتر از هدر سایت باشد */
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none; /* در حالت مخفی، کلیک را مسدود نکند */
}

/* نمایش اورلی وقتی کلاس فعال روی رپر (Wrapper) باشد */
.hmyt-ajax-search-wrapper.hmyt-modal-active .hmyt-search-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.hmyt-ajax-search-results {
    text-align: right;
}

/* -- Did You Mean Styles -- */
.hmyt-did-you-mean {
    padding: 15px;
    text-align: center;
    font-size: 14px;
    color: #555;
    border-bottom: 1px solid #eee;
}


/* -- Skeleton Loading Styles -- */
.hmyt-skeleton-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.hmyt-skeleton-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
}

.hmyt-skeleton-thumb {
    width: 50px;
    height: 50px;
    margin-left: 12px; /* فاصله از متن (در حالت RTL) */
    background-color: #f0f0f0;
    border-radius: 4px;
    flex-shrink: 0;
}

.hmyt-skeleton-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hmyt-skeleton-line {
    height: 10px;
    background-color: #f0f0f0;
    border-radius: 4px;
}

.hmyt-skeleton-line.title {
    width: 70%;
    height: 14px;
}

.hmyt-skeleton-line.meta {
    width: 40%;
}

/* انیمیشن Shimmer (براق شدن متحرک) */
.hmyt-skeleton-thumb,
.hmyt-skeleton-line {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: hmyt-skeleton-loading 1.5s infinite linear;
}

@keyframes hmyt-skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.hmyt-no-results {
    display: flex;
    justify-content: center;
}

/* --- Modal Search Styles --- */

/* 1. Trigger Style (The fake input shown on page) */
.hmyt-search-trigger {
    position: relative;
    cursor: text;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: #fff;
    display: flex;
    align-items: center;
    overflow: hidden;
    height: 42px; /* تنظیم ارتفاع دلخواه */
}

.hmyt-search-trigger input {
    border: none;
    background: transparent;
    pointer-events: none; /* کلیک روی اینپوت به والد منتقل شود */
    padding: 0 15px;
    width: 100%;
    color: #666;
}

.hmyt-trigger-icon {
    padding: 0 15px;
    display: flex;
    align-items: center;
    color: #555;
}

/* 2. Modal Container (Hidden by default) */
.hmyt-search-modal-container {
    position: fixed;
    top: 15%;
    left: 50%;
    /* شروع انیمیشن: کمی کوچک‌تر (Scale 0.95) و کمی پایین‌تر */
    transform: translate(-50%, 10px) scale(0.95);
    width: 680px;
    max-width: 90%;
    background: #fff;
    z-index: 9999990;
    border-radius: 10px;
    padding: 0;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    /* انیمیشن نرم و جذاب برای زوم و فید */
    transition: opacity 0.25s ease-out, transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* 3. Active State (When modal is open) */
.hmyt-ajax-search-wrapper.hmyt-modal-active .hmyt-search-modal-container {
    opacity: 1;
    visibility: visible;
    /* پایان انیمیشن: سایز اصلی و سر جای خود */
    transform: translate(-50%, 0) scale(1);
}

/* 4. Modal Form Styling */
.hmyt-search-modal-container .hmyt-ajax-search-form {
    border: none;
    border-bottom: 1px solid #eee;
    border-radius: 16px 16px 0 0;
    box-shadow: none;
}

.hmyt-search-modal-container .hmyt-ajax-search-input {
    font-size: 16px; /* بزرگتر کردن فونت در مودال */
    height: auto;
}

/* 5. Results in Modal */
.hmyt-search-modal-container .hmyt-ajax-search-results {
    display: block !important; /* همیشه در دام وجود دارد */
    position: static; /* دیگر شناور نیست، بخشی از مودال است */
    box-shadow: none;
    border: none;
    max-height: 60vh; /* اسکرول خوردن در صورت طولانی بودن */
    border-radius: 0 0 16px 16px;
    padding-top: 0;
}

/* 6. Close Button */
.hmyt-modal-close-btn {
    position: absolute;
    top: -40px;
    right: 0; /* یا left بسته به سلیقه */
    color: #fff;
    cursor: pointer;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}
.hmyt-modal-close-btn:hover {
    background: rgba(255,255,255,0.4);
}
/* Mobile Tweaks */
@media (max-width: 768px) {
    .hmyt-search-modal-container {
        /* تغییر از حالت تمام صفحه به مودال وسط‌چین */
        top: 15%; /* فاصله مناسب از بالا */
        left: 50%;
        width: 90%; /* عرض ۹۰ درصد صفحه */
        max-width: 90%;
        height: auto; /* ارتفاع بر اساس محتوا */
        border-radius: 12px; /* گوشه‌های گرد */
        /* حذف کدهای فول‌اسکرین قبلی */
    }

    /* محدود کردن ارتفاع لیست نتایج تا کاربر بتواند اسکرول کند */
    .hmyt-search-modal-container .hmyt-ajax-search-results {
        max-height: 55vh; 
    }

    /* دکمه بستن در موبایل */
    .hmyt-modal-close-btn {
        /* قرارگیری در بیرون باکس (بالای مودال) */
        top: -40px; 
        right: 0;
        width: 30px;
        height: 30px;
        background: rgba(255, 255, 255, 0.2); /* شفاف و شیک */
        backdrop-filter: blur(4px);
    }
}

/* --- Ultra Thin & Transparent Scrollbar --- */

/* برای مرورگرهای کروم، سافاری و اج */
.hmyt-search-modal-container .hmyt-ajax-search-results::-webkit-scrollbar {
    width: 4px; /* عرض بسیار کم */
}

.hmyt-search-modal-container .hmyt-ajax-search-results::-webkit-scrollbar-track {
    background: transparent; /* پس‌زمینه کاملا شفاف */
}

.hmyt-search-modal-container .hmyt-ajax-search-results::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.1); /* رنگ طوسی بسیار محو و شفاف */
    border-radius: 10px; /* لبه‌های کاملا گرد */
    transition: background-color 0.3s;
}

.hmyt-search-modal-container .hmyt-ajax-search-results::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.2); /* کمی پررنگ‌تر هنگام هاور */
}

/* برای مرورگر فایرفاکس */
.hmyt-search-modal-container .hmyt-ajax-search-results {
    scrollbar-width: thin; /* باریک */
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent; /* تامب محو و ترک شفاف */
}


/* --- Footer Modal Instance (Backup) --- */
/* وقتی مودال به صورت خودکار در فوتر لود می‌شود، 
   ما فقط به قابلیت‌های مودال نیاز داریم، نه فیلد جستجوی نمایشی در پایین سایت.
*/
.hmyt-ajax-search-wrapper.hmyt-footer-instance {
    width: 0;
    height: 0;
    position: absolute;
    overflow: visible; /* برای اینکه مودال بتواند از داخلش بیرون بیاید */
}

.hmyt-ajax-search-wrapper.hmyt-footer-instance .hmyt-search-trigger {
    display: none !important;
}
/* --- Grouped Results Layout --- */
.hmyt-results-group {
    margin-bottom: 15px;
}

.hmyt-results-group:last-child {
    margin-bottom: 0;
}

.hmyt-group-header {
    display: flex; /* برای چیدمان آیکون و متن */
    align-items: center; /* تراز عمودی دقیق */
    gap: 6px; /* فاصله مناسب بین آیکون و متن */
    font-size: 13px;
    font-weight: 700;
    color: #9ca3af; /* خاکستری ملایم */
    padding: 8px 15px;
    background: #f9fafb;
    border-bottom: 1px solid #f3f4f6;
    border-top: 1px solid #f3f4f6;
    margin-bottom: 5px;
}

.hmyt-group-header svg {
    width: 15px; /* سایز استاندارد آیکون */
    height: 15px;
}

/* اولین هدر حاشیه بالا نداشته باشد تا زیباتر شود */
.hmyt-results-group:first-child .hmyt-group-header {
    border-top: none;
}

.hmyt-view-all-wrapper {
    padding: 10px;
    border-top: 1px solid #e5e7eb;
}

/* حذف حاشیه لیست‌های قدیمی چون اکنون داخل گروپ هستند */
.hmyt-view-all-item {
    border-top: none; 
    margin-top: 0;
    padding: 0;
}