
/* ========================================
   فرم جست‌وجو
======================================== */

.search-form {
    width: 100%;
    min-width: 0;
}

.search-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: last baseline;;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
}

.search-filters .filter-item {
    min-width: 0;
}

.search-filters .filter-item .filter-group {
    margin-bottom: 1em;
}

.search-filters .filter-item label:not(:last-child) {
    margin-left: 5px;
}

.search-filters .filter-item .filter-group label {
    display: inline-block;
}

.search-filters .filter-item .filter-group .filter-title {
    font-size: 14px;
}

/* ========================================
   ترتیب و گروه‌بندی فیلترها
======================================== */

.location-filters,
.other-filters {
    display: contents;
}

.property-type-item {
    order: 1;
}

.city-item {
    order: 2;
}

.mantaghe-item {
    order: 3;
}

.other-filter-item {
    order: 4;
}

.search-submit-item {
    order: 5;
    flex: 0 0 auto;
}

.filter-item.city-item {
    width: 100%;
    max-width: 10vw;
}

.filter-item.mantaghe-item {
    width: 100%;
    max-width: 20vw;
}

.location-filters .form-group {
    margin-bottom: 0;
}

.location-filters .form-group > label {
    display: block;
    margin-bottom: 5px;
}

/* ========================================
   نوع ملک، checkbox و radio
======================================== */

/* برچسب‌های انتخابی */
.search-filters .filter-item .filter-group label span,.search-filters .filter-item .filter-group a {
    display: inline-block;
    font-size: 14px;
    height: 30px;
    line-height: 28px;
    padding: 0 12px;
    transition: 0.1s;
    border-radius: 9999px;
    border: 1px solid #d1d5db;
}

/* مخفی‌کردن ورودی اصلی برای حفظ ظاهر سفارشی */
.search-filters .filter-item .filter-group
label input[type="checkbox"],
.search-filters .filter-item .filter-group
label input[type="radio"] {
    display: none;
}

/* ظاهر گزینه انتخاب‌شده */
.search-filters .sort-options
input[type="checkbox"]:checked + span,
.search-filters .sort-options
input[type="radio"]:checked + span ,.search-filters .filter-item .filter-group a.active{
    color: #fff;
    background-color: var(--main-color-one);
    border-color: var(--main-color-one);
}

/* ========================================
   آکاردئون و دکمه فیلتر
======================================== */

.accordion-item {
    margin-bottom: 15px;
    position: relative;
}

.toggle-btn {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 5px 10px;
    background: #fff;
    color: #495057;

    border: 1px solid #ced4da;
    border-radius: 8px;

    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;

    transition: background-color 0.3s ease;
}

.toggle-btn:hover {
    background: #f5f5f5;
}

.toggle-btn.active {
    background: #f5f5f5;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.toggle-btn .icon {
    font-size: 14px;
    transition: transform 0.3s ease;
}

.toggle-btn.active .icon {
    transform: rotate(180deg);
}

/* ========================================
   پنل فیلتر - دسکتاپ
======================================== */

.content-box {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;

    width: 280px;
    max-width: min(340px, calc(100vw - 30px));
    max-height: 0;

    box-sizing: border-box;
    padding: 0;
    margin: 0;

    overflow-x: hidden;
    overflow-y: auto;

    background: #fff;
    border: 0 solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgb(0 0 0 / 12%);

    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    z-index: 1050;

    transition:
            opacity 0.2s ease,
            visibility 0.2s ease;
}

.content-box .form-group label {
    font-size: 12px;
}

.content-box .form-group input:not([type="checkbox"]):not([type="radio"]) {
    font-size: 12px;
}

.content-box.show {
    max-height: 420px;
    padding: 15px;

    overflow-y: auto;

    border-width: 1px;

    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ========================================
   حفظ ظاهر checkbox و radio داخل پنل
======================================== */
.content-box .filter-group {
    margin-bottom: 10px;
}
.content-box .filter-group .filter-title {
    font-size: 14px;
}
.content-box .filter-group label {
    display: inline-block;
    cursor: pointer;
}

.content-box .filter-group label span {
    display: inline-block;
    font-size: 14px;
    height: 30px;
    line-height: 28px;
    padding: 0 12px;
    border-radius: 9999px;
    border: 1px solid #d1d5db;
    transition: 0.1s;
}

.content-box .filter-group
label input[type="checkbox"],
.content-box .filter-group
label input[type="radio"] {
    display: none;
}

.content-box .sort-options
input[type="checkbox"]:checked + span,
.content-box .sort-options
input[type="radio"]:checked + span {
    color: #fff;
    background-color: var(--main-color-one);
}

/* ========================================
   دکمه ارسال فرم
======================================== */

.search-submit-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;

    padding: 8px 18px;
    min-height: 38px;

    color: #fff;
    background-color: var(--main-color-one);
    border: 1px solid var(--main-color-one);
    border-radius: 8px;

    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;

    transition: filter 0.2s ease;
}

.search-submit-btn:hover {
    filter: brightness(0.92);
}
.mobile-popup-close {
    display: none;
}
/* ========================================
   موبایل
======================================== */

@media (max-width: 768px) {

    /* فرم: سه ردیف اصلی */
    .search-filters {
        display: flex;
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 12px;

        padding: 0 10px;
        overflow: visible;
    }

    /* ------------------------------------
       ردیف اول: شهر و منطقه
    ------------------------------------ */

    .location-filters {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 8px;

        width: 100%;
        min-width: 0;
        order: 1;
    }

    .location-filters .filter-item {
        flex: 1 1 0;
        width: 0;
        max-width: none;
        min-width: 0;
        order: initial;
    }

    .location-filters .form-group {
        width: 100%;
        min-width: 0;
    }

    .location-filters .form-group select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* ------------------------------------
       ردیف دوم: نوار افقی فیلترها
    ------------------------------------ */

    .other-filters {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: flex-start;
        gap: 8px;

        width: 100%;
        max-width: 100%;
        min-width: 0;
        order: 2;

        overflow-x: auto;
        overflow-y: hidden;

        padding: 0 0 12px;

        scrollbar-width: thin;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }

    .other-filters > .filter-item {
        flex: 0 0 auto;
        width: max-content;
        max-width: none;
        min-width: max-content;
        order: initial;
    }

    .other-filters .toggle-btn {
        padding: 10px 12px;
        font-size: 13px;
        white-space: nowrap;
    }

    .other-filters .accordion-item {
        margin-bottom: 0;
    }

    .other-filters .filter-group {
        margin-bottom: 0;
    }

    .other-filters .sort-options {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 6px;
    }

    .other-filters .sort-options label {
        flex: 0 0 auto;
        margin: 0 0 5px;
    }

    /* ------------------------------------
       پنل منتقل‌شده به body در موبایل
    ------------------------------------ */

    .content-box.mobile-popup {
        position: fixed;

        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;

        width: calc(100vw - 32px);
        max-width: 420px;
        max-height: 0;
        height: auto;

        box-sizing: border-box;
        padding: 0;
        margin: 0;

        overflow-x: hidden;
        overflow-y: hidden;

        transform: translate(-50%, -50%);

        background: #fff;
        border: 0;
        border-radius: 12px;
        box-shadow: 0 16px 48px rgb(0 0 0 / 22%);

        z-index: 1060;
    }

    .content-box.mobile-popup.show {
        max-height: 75dvh;
        padding: 18px;

        overflow-x: hidden;
        overflow-y: auto;

        border: 1px solid #e5e7eb;

        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .content-box.mobile-popup .form-group {
        width: 100%;
        min-width: 0;
    }

    /* ورودی‌های معمولی؛ بدون تغییر اندازه checkbox و radio */
    .content-box.mobile-popup input:not([type="checkbox"]):not([type="radio"]),
    .content-box.mobile-popup select,
    .content-box.mobile-popup textarea {
        max-width: 100%;
        box-sizing: border-box;
    }



    /* ------------------------------------
       پس‌زمینه پاپ‌آپ
    ------------------------------------ */

    .filter-popup-overlay {
        position: fixed;
        inset: 0;

        background: rgb(0 0 0 / 45%);

        opacity: 0;
        visibility: hidden;
        pointer-events: none;

        z-index: 1055;

        transition:
                opacity 0.2s ease,
                visibility 0.2s ease;
    }

    .filter-popup-overlay.show {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .mobile-popup-close {
        position: fixed;
        z-index: 1070;

        width: 36px;
        height: 36px;

        display: none;
        align-items: center;
        justify-content: center;

        padding: 0;
        border: 1px solid #e5e7eb;
        border-radius: 50%;

        background: #fff;
        color: #333;

        font-size: 27px;
        line-height: 1;
        cursor: pointer;

        box-shadow: 0 3px 12px rgb(0 0 0 / 15%);
    }

    .mobile-popup-close.show {
        display: flex;
    }

    /* ------------------------------------
       ردیف سوم: دکمه جست‌وجو
    ------------------------------------ */

    .search-filters > .search-submit-item {
        order: 3;

        display: flex;
        flex: 0 0 auto;

        width: 100%;
        max-width: 100%;

        justify-content: stretch;
    }

    .search-submit-btn {
        width: 100%;
        min-height: 44px;
        box-sizing: border-box;
    }
}
