/*
 * Property card, results header and empty state shared by the search (grid + list), favourites,
 * home and agency pages. Markup: templates/rtl/_property_card.html.twig.
 * Everything is scoped under .pc / .pc-* so the older card styles in home_page.css and
 * syria_house_seo.css cannot leak in.
 */

:root {
    --pc-surface: #ffffff;
    --pc-bg-soft: #f4f7fb;
    --pc-border: #e6ebf1;
    --pc-text: #1d2733;
    --pc-muted: #6b7785;
    --pc-accent: #0074c1;
    --pc-accent-soft: rgba(0, 116, 193, .09);
    --pc-price: #0a8f4a;
    --pc-sale: #0a8f4a;
    --pc-rent: #c2410c;
    --pc-radius: 14px;
    --pc-shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
    --pc-shadow-hover: 0 4px 10px rgba(16, 24, 40, .06), 0 14px 32px rgba(16, 24, 40, .1);
}

html.dark-theme {
    --pc-surface: #212121;
    --pc-bg-soft: #2a2a2a;
    --pc-border: rgba(255, 255, 255, .1);
    --pc-text: #f2f4f6;
    --pc-muted: #a9b2bc;
    --pc-accent: #4aa8e8;
    --pc-accent-soft: rgba(74, 168, 232, .14);
    --pc-price: #3ccf7e;
    --pc-sale: #3ccf7e;
    --pc-rent: #fb923c;
    --pc-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    --pc-shadow-hover: 0 6px 24px rgba(0, 0, 0, .4);
}

/* ---------- Results header ---------- */
.pc-results-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
    margin: 0 0 16px;
    padding: 0;
    scroll-margin-top: 90px;
}

.pc-results-count {
    margin: 0;
    font-size: .95rem;
    color: var(--pc-muted);
}

.pc-results-count strong {
    color: var(--pc-text);
    font-size: 1.15rem;
    font-weight: 800;
}

/* ---------- Grid / list containers ---------- */
.pc-grid {
    display: grid;
    /* At most 4 columns, so the 12 results of a page always fill whole rows on wide pages. */
    grid-template-columns: repeat(auto-fill, minmax(max(260px, calc((100% - 60px) / 4)), 1fr));
    gap: 20px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.pc-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* The old wrappers are Bootstrap .row elements: let the card grid take the full width. */
.row > .pc-results-head,
.row > .pc-grid,
.row > .pc-list,
.row > .pc-empty,
.row > .pc-pagination {
    flex: 0 0 100%;
    max-width: 100%;
    padding-inline: calc(var(--bs-gutter-x, 1.5rem) * .5);
}

/* ---------- Card ---------- */
.pc {
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--pc-surface);
    border: 1px solid var(--pc-border);
    border-radius: var(--pc-radius);
    box-shadow: var(--pc-shadow);
    overflow: hidden;
    transition: transform .2s, box-shadow .2s, border-color .2s;
}

.pc:hover,
.pc:focus-within {
    transform: translateY(-3px);
    box-shadow: var(--pc-shadow-hover);
    border-color: var(--pc-accent);
}

/* The whole card is one link: stretch it over the card. */
.pc-link {
    color: inherit !important;
    text-decoration: none;
}

.pc-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
}

.pc-link:focus-visible {
    outline: none;
}

.pc:has(.pc-link:focus-visible) {
    outline: 3px solid var(--pc-accent);
    outline-offset: 2px;
}

/* Media */
.pc-media {
    position: relative;
    aspect-ratio: 4 / 3;
    background: var(--pc-bg-soft);
    overflow: hidden;
    flex: 0 0 auto;
}

.pc-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s ease;
}

.pc:hover .pc-media img {
    transform: scale(1.04);
}

.pc-media-fallback {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.6rem;
    color: var(--pc-accent);
    opacity: .3;
}

.pc-badges {
    position: absolute;
    top: 10px;
    inset-inline: 10px;
    z-index: 4;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 6px;
    pointer-events: none;
}

.pc-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.4;
    white-space: nowrap;
    color: #fff;
    background: rgba(17, 24, 39, .66);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.pc-badge--sale { background: rgba(10, 143, 74, .92); }
.pc-badge--rent { background: rgba(194, 65, 12, .92); }
.pc-badge--fav { background: #e0245e; padding: 4px 8px; }

.pc-badges-end {
    display: flex;
    gap: 6px;
}

/* Sold / rented */
.pc--sold .pc-media img {
    filter: grayscale(65%);
}

.pc-sold {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .35);
}

.pc-sold span {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: #fff;
    font-weight: 800;
    padding: 8px 22px;
    border-radius: 8px;
    letter-spacing: .5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .3);
}

/* Body */
.pc-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
    padding: 14px 16px 16px;
    min-width: 0;
}

.pc-price {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    font-size: 1.3rem;
    font-weight: 800;
    line-height: 1.2;
    color: var(--pc-price);
}

.pc-price small {
    font-size: .8rem;
    font-weight: 600;
    color: var(--pc-muted);
}

.pc-title {
    margin: 0;
    font-size: 1.02rem;
    font-weight: 700;
    line-height: 1.45;
    color: var(--pc-text);
}

.pc-address {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: .88rem;
    color: var(--pc-muted);
    min-width: 0;
}

.pc-address i {
    color: var(--pc-accent);
    flex: 0 0 auto;
}

.pc-address span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pc-specs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: auto 0 0;
    padding: 12px 0 0;
    list-style: none;
    border-top: 1px solid var(--pc-border);
}

.pc-body > .pc-address + .pc-specs,
.pc-body > .pc-title + .pc-specs {
    margin-top: 8px;
}

.pc-spec {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--pc-bg-soft);
    font-size: .85rem;
    font-weight: 600;
    color: var(--pc-text);
}

.pc-spec i {
    color: var(--pc-accent);
    font-size: .8rem;
}

/* ---------- List (horizontal) variant ---------- */
@media (min-width: 768px) {
    .pc--list {
        flex-direction: row;
    }

    .pc--list .pc-media {
        flex: 0 0 min(38%, 340px);
        aspect-ratio: auto;
        min-height: 220px;
    }

    .pc--list .pc-body {
        padding: 18px 22px;
        gap: 8px;
    }

    .pc--list .pc-price {
        font-size: 1.45rem;
    }

    .pc--list .pc-title {
        font-size: 1.15rem;
    }
}

/* ---------- Empty state ---------- */
.pc-empty {
    width: 100%;
    text-align: center;
    padding: 48px 16px;
    margin-bottom: 24px;
    border: 1px dashed var(--pc-border);
    border-radius: var(--pc-radius);
    color: var(--pc-muted);
}

.pc-empty > i {
    font-size: 2.6rem;
    color: var(--pc-accent);
    margin-bottom: 12px;
}

.pc-empty-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--pc-text);
    margin-bottom: 4px;
}

.pc-empty .btn {
    margin-top: 16px;
    border-radius: 10px;
    font-weight: 700;
}

/* ---------- Pagination ---------- */
.pc-pagination {
    width: 100%;
    margin-top: 28px;
}

.pc-pagination .pagination {
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

.pc-pagination .page-link {
    min-width: 42px;
    min-height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px !important;
    border-color: var(--pc-border);
    background: var(--pc-surface);
    color: var(--pc-text);
    font-weight: 600;
}

.pc-pagination .page-item.active .page-link {
    background: var(--pc-accent);
    border-color: var(--pc-accent);
    color: #fff;
}

@media (prefers-reduced-motion: reduce) {
    .pc,
    .pc-media img {
        transition: none;
    }

    .pc:hover .pc-media img {
        transform: none;
    }
}
