/**************************/
/* RECENT PAGE FINAL CSS */
/**************************/

.recent {
    padding: 11rem 0 8rem;
    position: relative;
    background: linear-gradient(#f8f4db, #fffffe);
    min-height: 100vh;
    overflow: hidden;
}

.recent::before,
.recent::after {
    content: "";
    position: absolute;
    left: 0;
    transform: translateX(-60%);
    width: 18.4rem;
    height: 18.4rem;
    border-radius: 50%;
    background-color: transparent;
    z-index: 0;
    opacity: 0.25;
    pointer-events: none;
}

.recent::before {
    top: 3rem;
    border: 4rem solid rgba(255, 212, 51, 0.15);
}

.recent::after {
    top: 9rem;
    border: 4rem solid rgba(35, 135, 194, 0.15);
}

.recent .container {
    position: relative;
    z-index: 1;
}

/**************************/
/* HEADER */
/**************************/

.recent-page-header {
    position: relative;
    margin-bottom: 4rem;
}

.recent .heading-secondary {
    font-size: 3rem;
    font-weight: 800;
    color: #1f3347;
    margin-bottom: 3rem;
    position: relative;
    text-align: center;
}

.recent .heading-secondary::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -1rem;
    width: 8rem;
    height: 0.4rem;
    border-radius: 2rem;
    transform: translateX(-50%);
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
}

/**************************/
/* FILTER BUTTON */
/**************************/

.filter-btn {
    position: absolute;
    top: 0;
    inset-inline-end: 0;
    z-index: 50;

    height: 4.4rem;
    padding: 0 1.8rem;

    border: 0;
    border-radius: 999px;

    background: #ffffff;
    color: #1f3347;

    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;

    font-size: 1.5rem;
    font-weight: 800;

    box-shadow: 0 0.6rem 1.6rem rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: 0.25s ease;
}

.filter-btn:hover {
    transform: translateY(-0.2rem);
    box-shadow: 0 0.8rem 2rem rgba(35, 135, 194, 0.18);
}

.filter-btn img {
    width: 2rem;
    height: 2rem;
}

/**************************/
/* LAYOUT */
/**************************/

.recent-wrapper {
    display: grid;
    grid-template-columns: 30rem 1fr;
    gap: 3.2rem;
    align-items: start;
}

.recent-content-wrapper {
    min-width: 0;
}

/**************************/
/* FILTER PANEL */
/**************************/

.recent-filter {
    position: sticky;
    top: 10rem;

    padding: 2.4rem;

    border-radius: 2rem;
    background: rgba(255, 255, 255, 0.88);

    box-shadow: 0 0.8rem 2.4rem rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);

    max-height: calc(100vh - 12rem);
    overflow-y: auto;
}

.recent-filter::-webkit-scrollbar {
    width: 0.7rem;
}

.recent-filter::-webkit-scrollbar-track {
    background: rgba(35, 135, 194, 0.06);
    border-radius: 1rem;
}

.recent-filter::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 1rem;
}

.close-btn {
    display: none;
    cursor: pointer;
}

.recent-filter .heading-tertiary {
    font-size: 2.2rem;
    font-weight: 800;
    color: #1f3347;
    margin-bottom: 2rem;
    padding-bottom: 1.2rem;
    border-bottom: 0.1rem solid rgba(31, 51, 71, 0.1);
}

.recent-filter .box {
    margin-bottom: 2.2rem;
}

.recent-filter label {
    display: block;
    font-size: 1.4rem;
    font-weight: 700;
    color: #1f3347;
    margin-bottom: 0.9rem;
}

/**************************/
/* SELECT MENU */
/**************************/

.select-menu {
    width: 100%;
    position: relative;
}

.select-btn,
.custom-input,
.budget-input input {
    width: 100%;
    min-height: 4.8rem;

    border: 0.1rem solid rgba(31, 51, 71, 0.12);
    border-radius: 1.4rem;

    background: #ffffff;
    color: #1f3347;

    padding: 0 1.4rem;

    display: flex;
    align-items: center;
    justify-content: space-between;

    font-size: 1.4rem;
    font-weight: 700;

    cursor: pointer;
    transition: 0.25s ease;
}

.select-btn:hover,
.custom-input:hover,
.budget-input input:hover {
    border-color: rgba(35, 135, 194, 0.35);
}

.custom-input,
.budget-input input {
    display: block;
    cursor: text;
}

.select-btn img {
    width: 1.4rem;
    transition: 0.25s ease;
}

.select-menu.active .select-btn img,
.select-menu.active-select .select-btn img {
    transform: rotate(180deg);
}

.options {
    position: absolute;
    top: calc(100% + 0.8rem);
    left: 0;
    right: 0;
    z-index: 30;

    max-height: 22rem;
    overflow-y: auto;

    padding: 0.8rem;
    margin: 0;

    list-style: none;

    border-radius: 1.4rem;
    background: #ffffff;

    box-shadow: 0 0.8rem 2.4rem rgba(0, 0, 0, 0.12);

    opacity: 0;
    visibility: hidden;
    transform: translateY(-0.8rem);
    transition: 0.2s ease;
}

.select-menu.active .options,
.select-menu.active-select .options {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

.option {
    padding: 1rem 1.2rem;
    border-radius: 1rem;
    cursor: pointer;
    color: #1f3347;
    font-size: 1.4rem;
    font-weight: 700;
    transition: 0.2s ease;
}

.option:hover {
    background: rgba(35, 135, 194, 0.08);
}

.option-text {
    pointer-events: none;
}

/**************************/
/* INPUTS */
/**************************/

.input-box {
    padding: 1.2rem;
    border-radius: 1.4rem;
    background: rgba(35, 135, 194, 0.06);
}

.input-box label {
    font-size: 1.3rem;
    color: #707070;
}

.budget-input {
    width: 100%;
}

.budget-input input {
    border: 0;
    padding: 0;
    background: transparent;
}

/**************************/
/* ADS GRID */
/**************************/

.recent-content {
    display: grid !important;
    grid-template-columns: repeat(3, 28rem) !important;
    justify-content: center !important;
    gap: 3.2rem !important;
}

/**************************/
/* CARD */
/**************************/

.recent-card {
    width: 28rem !important;
    min-height: 43rem !important;
    height: auto !important;

    position: relative !important;

    display: flex !important;
    flex-direction: column !important;

    border-radius: 1.8rem !important;
    overflow: hidden !important;

    background: #ffffff !important;
    color: inherit !important;
    text-decoration: none !important;

    box-shadow: 0 0.8rem 2.4rem rgba(0, 0, 0, 0.12) !important;
    transition: 0.3s ease !important;
}

.recent-card:hover {
    transform: translateY(-0.8rem);
    box-shadow: 0 1.2rem 3.2rem rgba(35, 135, 194, 0.18) !important;
}

.recent-card-image-wrapper {
    width: 100%;
    height: auto !important;
    min-height: 0 !important;

    position: relative !important;
    overflow: visible !important;

    background: #eeeeee;
}

.recent-card-image-wrapper > img,
.recent-img {
    width: 100% !important;
    height: 23rem !important;
    object-fit: cover !important;
    display: block !important;
    transition: transform 0.5s ease;
}

.recent-card:hover .recent-img,
.recent-card:hover .recent-card-image-wrapper > img {
    transform: scale(1.08);
}

/**************************/
/* FAVORITE BUTTON */
/**************************/

.recent-card .recent-favorite-btn,
.recent-card .add-favorite {
    position: absolute !important;
    top: 1.2rem !important;
    inset-inline-start: 1.2rem !important;
    inset-inline-end: auto !important;

    width: 4.2rem !important;
    height: 4.2rem !important;

    border: 0 !important;
    border-radius: 50% !important;

    background: #ffffff !important;
    color: #ef4444 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    z-index: 20 !important;
    cursor: pointer !important;

    box-shadow: 0 0.6rem 1.6rem rgba(0, 0, 0, 0.16) !important;
    transition: 0.25s ease;
}

.recent-card .recent-favorite-btn:hover,
.recent-card .add-favorite:hover {
    transform: scale(1.08);
}

.recent-card .recent-favorite-btn i,
.recent-card .add-favorite i,
.recent-card .favorite-heart {
    font-size: 2.4rem !important;
    color: #ef4444 !important;
}

/**************************/
/* CARD BODY */
/**************************/

.recent-card-body,
.card-details {
    position: static !important;

    width: 100% !important;
    min-height: 20rem !important;
    height: auto !important;

    padding: 1.8rem 2rem !important;

    display: flex !important;
    flex-direction: column !important;

    background: #ffffff !important;
    color: inherit !important;

    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.recent-card-title,
.card-title {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;

    margin: 0 !important;
    padding-bottom: 1rem !important;

    color: #1f3347 !important;
    font-size: 1.8rem !important;
    font-weight: 800 !important;
    line-height: 1.4 !important;
    text-shadow: none !important;

    border-bottom: 0.1rem solid rgba(0, 0, 0, 0.08) !important;
}

.recent-card-footer,
.card-price-location {
    margin-top: auto !important;
    padding-top: 1.4rem !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
}
/**************************/
/* EMPTY */
/**************************/

.recent-empty-state,
.no-ads-message {
    width: 100%;
    min-height: 560px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    text-align: center;
    padding: 40px 20px;
    background: #fff;
    border-radius: 18px;
}

.no-ads-img {
    display: block;
    max-width: 360px;
    width: 100%;
    height: auto;
    margin: 0 auto 24px;
    object-fit: contain;
}

.no-ads-message h3 {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 600;
    color: #555;
}

.no-ads-message p {
    margin: 0;
    font-size: 14px;
    color: #999;
}

/**************************/
/* PAGINATION */
/**************************/

.recent-pagination-wrapper {
    margin-top: 4rem;
    display: flex;
    justify-content: center;
}

.recent-pagination-wrapper nav {
    display: flex;
    justify-content: center;
}

.recent-pagination-wrapper .pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    margin: 0;
    padding: 0;
}

.recent-pagination-wrapper .page-item {
    list-style: none;
}

.recent-pagination-wrapper .page-link {
    min-width: 4rem;
    height: 4rem;

    border: 0 !important;
    border-radius: 1rem !important;

    display: flex;
    align-items: center;
    justify-content: center;

    background: #ffffff;
    color: #1f3347;

    font-size: 1.4rem;
    font-weight: 800;

    box-shadow: 0 0.3rem 1rem rgba(0, 0, 0, 0.08);
    transition: 0.2s ease;
}

.recent-pagination-wrapper .page-link:hover {
    background: rgba(35, 135, 194, 0.12);
    color: var(--color-primary);
}

.recent-pagination-wrapper .page-item.active .page-link {
    background: var(--color-primary) !important;
    color: #ffffff !important;
}

.recent-pagination-wrapper .page-item.disabled .page-link {
    opacity: 0.45;
    cursor: not-allowed;
}

/**************************/
/* RESPONSIVE */
/**************************/

@media only screen and (max-width: 1200px) {
    .recent-wrapper {
        grid-template-columns: 28rem 1fr;
        gap: 2.4rem;
    }

    .recent-content {
        grid-template-columns: repeat(2, 28rem) !important;
    }
}

@media only screen and (max-width: 900px) {
    .recent {
        padding: 4rem 0 6rem;
    }

    .recent-wrapper {
        display: block;
    }

    .filter-btn {
        position: static;
        margin: 0 auto 2rem;
    }

    .recent-filter {
        position: fixed;
        top: 0;
        bottom: 0;
        inset-inline-start: 0;
        z-index: 9999;

        width: min(34rem, 90vw);
        max-height: none;
        height: auto;

        border-radius: 0;
        overflow-y: auto;

        transform: translateX(-105%);
        transition: 0.3s ease;
    }

    [dir="rtl"] .recent-filter,
    html[dir="rtl"] .recent-filter {
        inset-inline-start: auto;
        inset-inline-end: 0;
        transform: translateX(105%);
    }

    .recent-filter.active {
        transform: translateX(0);
    }

    .close-btn {
        display: flex;
        position: absolute;
        top: 1rem;
        inset-inline-end: 1rem;

        width: 3.6rem;
        height: 3.6rem;

        border: 0;
        border-radius: 50%;

        background: rgba(31, 51, 71, 0.08);
        color: #1f3347;

        align-items: center;
        justify-content: center;

        font-size: 2.6rem;
        cursor: pointer;
        transition: 0.25s ease;
    }

    .close-btn:hover {
        background: rgba(35, 135, 194, 0.12);
        color: var(--color-primary);
    }
}

@media only screen and (max-width: 640px) {
    .recent {
        padding: 4rem 0 6rem;
    }

    .recent .heading-secondary {
        font-size: 2.4rem;
    }

    .recent-content {
        grid-template-columns: 28rem !important;
        gap: 2.4rem !important;
    }

    .recent-card {
        height: 41rem !important;
    }

    /* .recent-card-image-wrapper {
        height: 21rem;
    } */

    .recent-card-body,
    .card-details {
        height: 20rem !important;
    }

    .recent-pagination-wrapper .page-link {
        min-width: 3.6rem;
        height: 3.6rem;
        font-size: 1.3rem;
    }
}
/**************************/
/* FINAL FIX - RECENT CARDS */
/**************************/

.recent-content {
    display: grid !important;
    grid-template-columns: repeat(3, 28rem) !important;
    justify-content: center !important;
    gap: 3.2rem !important;
}

.recent-card {
    width: 28rem !important;
    height: 43rem !important;
    min-height: 43rem !important;

    position: relative !important;

    display: flex !important;
    flex-direction: column !important;

    border-radius: 1.8rem !important;
    overflow: hidden !important;

    background: #ffffff !important;
    color: inherit !important;
    text-decoration: none !important;

    box-shadow: 0 0.8rem 2.4rem rgba(0, 0, 0, 0.12) !important;
    transition: 0.3s ease !important;
}

.recent-card:hover {
    transform: translateY(-0.8rem);
    box-shadow: 0 1.2rem 3.2rem rgba(35, 135, 194, 0.18) !important;
}

.recent-card-image-wrapper {
    width: 100% !important;
    height: auto !important;
    min-height: 23rem !important;

    position: relative !important;
    overflow: visible !important;

    background: #eeeeee !important;
    flex-shrink: 0 !important;
}

/* مهم: يستهدف أي صورة داخل الغلاف حتى لو ليست ابن مباشر */
.recent-card-image-wrapper img,
.recent-img {
    width: 100% !important;
    height: 23rem !important;
    max-height: 23rem !important;

    object-fit: cover !important;
    display: block !important;

    border-radius: 0 !important;
}

/* يمنع أي صورة صغيرة أو مكسورة من تخريب الكرت */
.recent-card-image-wrapper img:not(.favorite-heart) {
    object-fit: cover !important;
}

/**************************/
/* FAVORITE BUTTON */
/**************************/

.recent-card .recent-favorite-btn,
.recent-card .add-favorite {
    position: absolute !important;
    top: 1.2rem !important;

    /* مكان القلب داخل الصورة */
    right: 1.2rem !important;
    left: auto !important;
    inset-inline-start: auto !important;
    inset-inline-end: auto !important;

    width: 4.2rem !important;
    height: 4.2rem !important;

    border: 0 !important;
    border-radius: 50% !important;

    background: #ffffff !important;
    color: #ef4444 !important;

    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    z-index: 50 !important;
    cursor: pointer !important;

    box-shadow: 0 0.6rem 1.6rem rgba(0, 0, 0, 0.16) !important;
    transition: 0.25s ease !important;
}

.recent-card .recent-favorite-btn:hover,
.recent-card .add-favorite:hover {
    transform: scale(1.08) !important;
}

.recent-card .recent-favorite-btn i,
.recent-card .add-favorite i,
.recent-card .favorite-heart {
    font-size: 2.4rem !important;
    color: #ef4444 !important;
}

/**************************/
/* CARD DETAILS */
/**************************/

.recent-card-body,
.card-details {
    position: static !important;

    width: 100% !important;
    height: 20rem !important;
    min-height: 20rem !important;

    padding: 1.8rem 2rem !important;

    display: flex !important;
    flex-direction: column !important;

    background: #ffffff !important;
    color: inherit !important;

    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;

    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;

    flex: 1 !important;
}

.recent-card-title,
.card-title {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;

    margin: 0 !important;
    padding-bottom: 1rem !important;

    color: #1f3347 !important;
    font-size: 1.8rem !important;
    font-weight: 800 !important;
    line-height: 1.4 !important;
    text-align: center !important;
    text-shadow: none !important;

    border-bottom: 0.1rem solid rgba(0, 0, 0, 0.08) !important;
}

.recent-card-footer,
.card-price-location {
    margin-top: auto !important;
    padding-top: 1.4rem !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
}

.price,
.recent-price {
    margin: 0 !important;

    display: flex !important;
    align-items: baseline !important;
    justify-content: flex-end !important;
    gap: 0.4rem !important;

    color: #707070 !important;
    font-size: 1.3rem !important;
}

.price span,
.price-amount {
    color: var(--color-secondary) !important;
    font-size: 2rem !important;
    font-weight: 800 !important;
}

.price-period {
    color: #707070 !important;
    font-size: 1.3rem !important;
}

.location,
.recent-location {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;

    color: #707070 !important;
    font-size: 1.4rem !important;
}

.location-icon {
    width: 2rem !important;
    height: 2rem !important;
    color: var(--color-primary) !important;
    filter: none !important;
}

/**************************/
/* RESPONSIVE FIX */
/**************************/

@media only screen and (max-width: 1200px) {
    .recent-content {
        grid-template-columns: repeat(2, 28rem) !important;
    }
}

@media only screen and (max-width: 640px) {
    .recent-content {
        grid-template-columns: 28rem !important;
        gap: 2.4rem !important;
    }

    .recent-card {
        height: 41rem !important;
        min-height: 41rem !important;
    }

    .recent-card-image-wrapper {
        min-height: 21rem !important;
    }

    .recent-card-image-wrapper img,
    .recent-img {
        height: 21rem !important;
        max-height: 21rem !important;
    }

    .recent-card-body,
    .card-details {
        height: 20rem !important;
        min-height: 20rem !important;
    }
}