/* کدهای پایه و مدال */
.dm-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: visibility 0.5s ease;
}

.dm-search-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.dm-search-modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.dm-search-modal__content {
    background: #fff;
    width: 90%;
    max-width: 600px;
    border-radius: 12px;
    position: relative;
    z-index: 1;
    transform: translateY(-20px);
    transition: transform 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.dm-search-modal.is-open .dm-search-modal__content {
    transform: translateY(0);
}

/* هدر مدال */
.dm-search-modal__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.dm-search-modal__title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #333;
}

.dm-search-modal__close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    line-height: 1;
    padding: 0;
}

.dm-search-modal__close:hover {
    color: #e74c3c;
}

/* بادی و فرم */
.dm-search-modal__body {
    padding: 20px;
    overflow-y: auto;
}

.dm-search-form__group {
    display: flex;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.3s ease;
}

.dm-search-form__group:focus-within {
    border-color: #3498db;
}

.dm-search-form__input {
    flex-grow: 1;
    border: none;
    padding: 12px 15px;
    font-size: 1rem;
    outline: none;
    background: #fcfcfc;
}

.dm-search-form__submit {
    background: #fcfcfc;
    border: none;
    padding: 0 15px;
    cursor: pointer;
    color: #555;
}

/* نتایج و یوتلیتی‌ها */
.dm-search-results {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 40px;
}

.dm-hidden {
    display: none !important;
}

.dm-search-more-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 100%;
    padding: 10px;
    margin-top: 15px;
    background: #0c2d57;
    border: none;
    cursor: pointer;
    font-weight: bold;
    color: #fff;
    z-index: 11;
}

.dm-search-open-btn {
    border: none;
    cursor: pointer;
    color: white;
    padding: 5px;
}

/* استایل مینیمال برای کارت‌های جستجو */
.dm-search-card {
    display: flex;
    align-items: center;
    position: relative;
    padding: 10px;
    border-bottom: 1px solid #f1f1f1;
    transition: background-color 0.2s ease;
}

.dm-search-card:hover {
    background-color: #f9f9f9;
}

.dm-search-card:last-child {
    border-bottom: none;
}

.dm-search-card__link {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
}

.dm-search-card__image-wrapper {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    margin-left: 15px; /* برای راست‌چین */
    border-radius: 6px;
    overflow: hidden;
    background: #fcfcfc;
}

.dm-search-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dm-search-card__content {
    flex-grow: 1;
}

.dm-search-card__title {
    margin: 0;
    font-size: 0.95rem;
    color: #333;
    font-weight: 600;
    line-height: 1.4;
}

/* --- استایل‌های اختصاصی صفحه نتایج جستجو --- */
.dm-container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 15px;
}

.dm-search-page__header {
    background-color: #0c2d57; /* معادل رنگ پس زمینه ثانویه */
    color: #fff;
    padding: 16px;
    text-align: center;
    margin-bottom: 40px;
}

.dm-search-page__header h1 {
    margin: 0 0 10px 0;
    font-size: 2rem;
    color: #fff;
}

.dm-search-page__tabs {
    margin-top: -24px;
    margin-bottom: 24px;
    position: relative;
    z-index: 2;
}

.dm-search-section__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 20px;
}

.dm-btn {
    background-color: #0c2d57;
    color: #fff;
    padding: 8px 20px;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
}

.dm-btn:hover {
    background-color: #5a6268;
    color: #fff;
}

/* اسلایدر بدون جاوااسکریپت (CSS Scroll Snap) */
.dm-slider-container {
    width: 100%;
    overflow: hidden;
}

.dm-slider {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 15px;
    padding-bottom: 15px;
    scrollbar-width: thin;
}

.dm-slider::-webkit-scrollbar {
    height: 8px;
}

.dm-slider::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 10px;
}

.dm-slider__item {
    flex: 0 0 calc(20% - 15px); /* نمایش ۵ آیتم */
    scroll-snap-align: start;
}

/* ریسپانسیو اسلایدر */
@media (max-width: 1200px) {
    .dm-slider__item {
        flex: 0 0 calc(25% - 15px);
    }
}

@media (max-width: 992px) {
    .dm-slider__item {
        flex: 0 0 calc(33.333% - 15px);
    }
}

@media (max-width: 768px) {
    .dm-slider__item {
        flex: 0 0 calc(50% - 15px);
    }
}

@media (max-width: 576px) {
    .dm-slider__item {
        flex: 0 0 calc(85% - 15px);
    }
}

/* نمای گرید محصولات و سایدبار */
.dm-grid-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

.dm-search-sidebar {
    width: 100%;
    max-width: 25%;
}

.dm-search-tabs-list {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    display: flex;
    flex-direction: row;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.dm-search-tab-btn {
    min-width: 120px;
    border: 1px solid #d7d7d7;
    background: #fff;
    color: #333;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.dm-search-tab-btn:hover {
    border-color: #0c2d57;
    color: white;
}

.dm-search-tab-btn.is-active {
    background: #0c2d57;
    color: #fff;
    border-color: #0c2d57;
}

.dm-main-results {
    flex: 1;
    min-width: 60%;
}

.dm-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
}

.dm-grid.is-loading {
    opacity: 0.5;
    pointer-events: none;
}


@media (max-width: 1200px) {
    .dm-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .dm-search-page__tabs {
        margin-top: -16px;
    }

    .dm-search-sidebar {
        max-width: 100%;
        margin-bottom: 30px;
    }

    .dm-search-tab-btn {
        min-width: 96px;
    }

    .dm-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* تغییر ظاهر کارت در اسلایدر و صفحه گرید (عمودی شدن کارت) */
.dm-slider__item .dm-search-card,
.dm-grid__item .dm-search-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 20px 10px;
    height: 100%;
}

.dm-slider__item .dm-search-card__image-wrapper,
.dm-grid__item .dm-search-card__image-wrapper {
    width: 130px;
    height: 130px;
    margin-left: 0;
    margin-bottom: 15px;
}

/* --- استایل‌های پیشنهاد ویژه (همگام‌سازی شده با کارت‌های جستجو) --- */
.dm-special-suggestion {
    position: relative;
    padding: 0;
    border-bottom: 1px solid #f1f1f1; /* خط پایین مشابه کارت عادی */
    transition: background-color 0.2s ease;
    margin: 0;
    background: transparent;

    /* ریست کردن استایل‌های قبلی (حذف حاشیه‌های ضخیم و سایه) */
    border-radius: 0;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
}

/* برای اینکه رنگ انتخابی حاشیه در تنظیمات، فقط روی خط پایین اعمال شود */
.dm-special-suggestion[style] {
    border-bottom-width: 1px !important;
    border-bottom-style: solid !important;
}

.dm-special-suggestion:hover {
    background-color: #f9f9f9;
}

.dm-special-suggestion__wrapper {
    display: flex;
    align-items: center;
    padding: 10px; /* پدینگ کاملا مشابه dm-search-card */
    text-decoration: none !important;
    color: #333 !important;
}

.dm-special-suggestion__badge {
    position: absolute;
    top: 0;
    left: 0;
    color: #000;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 8px;
    border-bottom-right-radius: 6px;
    z-index: 2;
}

.dm-special-suggestion__image {
    width: 50px; /* تغییر سایز عکس به 50 پیکسل مشابه کارت عادی */
    height: 50px;
    flex-shrink: 0;
    margin-left: 15px;
    border-radius: 6px;
    overflow: hidden;
    background: #fcfcfc;
}

.dm-special-suggestion__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dm-special-suggestion__content {
    flex-grow: 1;
}

.dm-special-suggestion__title {
    margin: 0;
    font-size: 0.95rem; /* سایز فونت دقیقا مشابه کارت عادی */
    font-weight: 600;
    line-height: 1.4;
    color: #333;
}

.dm-special-suggestion__subtitle {
    margin: 3px 0 0 0;
    font-size: 12px;
    color: #888;
}

.dm-special-suggestion__action {
    margin-right: 15px;
    z-index: 10;
    margin-top: auto;
}

.dm-special-suggestion__close {
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%); /* وسط‌چین کردن عمودی دکمه بستن */
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #bbb;
    z-index: 10;
    line-height: 1;
    padding: 5px;
    transition: color 0.2s ease;
}

.dm-special-suggestion__close:hover {
    color: #e74c3c;
}

.dm-special-card-badge {
    position: absolute;
    top: 10px;
    right: 8px;
    z-index: 5;
    color: #fff;
    padding: 3px 12px;
    font-size: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.dm-special-card-inner {
    transition: transform 0.3s ease;
}
.dm-special-card-inner:hover {
    transform: translateY(-5px);
}
/* =========================================================
   General Search Widget (Blog) Styles
========================================================= */

/* استایل باکس نتایج (دراپ‌داون) */
.dms-general-search-results {
    max-height: 380px;
    overflow-y: auto;
    border: 1px solid #eaeaea;
    border-top: none;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    border-radius: 0 0 8px 8px;
    background: #fff;
    /* اسکرول‌بار اختصاصی و باریک */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.dms-general-search-results::-webkit-scrollbar {
    width: 6px;
}
.dms-general-search-results::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

.dms-general-results-list {
    display: flex;
    flex-direction: column;
}

/* استایل کارت‌های جستجو (BEM) */
.dm-search-card {
    position: relative;
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f1f5f9;
    transition: background-color 0.2s ease;
    background: #fff;
}

.dm-search-card:last-child {
    border-bottom: none;
}

.dm-search-card:hover {
    background-color: #f8fafc; /* رنگ هاور ملایم */
}

/* لینک مخفی برای کلیک‌پذیر شدن کل کارت */
.dm-search-card__link {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 1;
}

/* باکس تصویر */
.dm-search-card__image-wrapper {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    margin-left: 15px; /* تنظیم برای RTL */
    border-radius: 6px;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
}

.dm-search-card__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* محتوای متنی */
.dm-search-card__content {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dm-search-card__title {
    margin: 0 0 4px 0;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dm-search-card__meta {
    font-size: 11px;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start; /* جلوگیری از کش آمدن تگ */
}
/* =========================================================
   Mobile Sticky Search Widget (Only < 992px)
========================================================= */
@media (max-width: 991.98px) {
    .dms-general-search-wrapper.dms-sticky-active {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        z-index: 999999 !important; /* افزایش z-index برای قرارگیری روی تمام هدرها */
        background: #ffffff;
        padding: 12px 15px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
        border-bottom: 1px solid #eaeaea;
        animation: dmsSlideDown 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
        /* رفع مشکل قرارگیری داخل کانتینرهای Transform دار */
        transform: translateZ(0);
    }

    .dms-general-search-wrapper.dms-sticky-active .dms-general-search-results {
        top: 100%;
        left: 0; /* تمام عرض کردن نتایج در حالت موبایل */
        width: 100%;
        border-radius: 0 0 8px 8px;
        box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
    }
}

@keyframes dmsSlideDown {
    from { transform: translateY(-100%); }
    to { transform: translateY(0); }
}