/* ============================================================
   Real Estate Embed – self-contained stylesheet
   Scoped under .re-* to avoid clashing with host-page CSS.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

.re-embed-body {
    margin: 0;
    padding: 12px 12px 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #1a202c;
    background: #f7f8fa;
    /* No min-height – height is driven purely by content so the
       iframe resizes correctly without an infinite-growth loop. */
    overflow: hidden;
}

/* ── Top bar (result count + filter toggle) ─────────────────── */
.re-embed-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    min-height: 32px;
}

.re-result-count {
    font-size: 13px;
    color: #6b7280;
}

.re-toggle-filters {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}

.re-toggle-filters:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.re-toggle-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* ── Filter bar ─────────────────────────────────────────────── */
.re-embed-filters {
    background: #fff;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,.07);
    overflow: hidden;
    transition: max-height .3s ease, opacity .3s ease, margin-bottom .3s ease, padding .3s ease;
    max-height: 300px;
    opacity: 1;
}

.re-embed-filters.re-filters-hidden {
    max-height: 0;
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.re-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.re-filter-row-secondary {
    margin-top: 10px;
}

.re-filter-item {
    flex: 1 1 140px;
    min-width: 120px;
}

.re-filter-search {
    flex: 2 1 220px;
}

.re-filter-price {
    flex: 1 1 120px;
}

.re-filter-btn-wrap {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
}

.re-input,
.re-select {
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    color: #374151;
    background: #f9fafb;
    outline: none;
    transition: border-color .2s;
    appearance: none;
    -webkit-appearance: none;
}

.re-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

.re-input:focus,
.re-select:focus {
    border-color: #4f46e5;
    background: #fff;
}

.re-btn-search {
    height: 38px;
    padding: 0 20px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
}

.re-btn-search:hover { background: #4338ca; }

.re-btn-reset {
    height: 38px;
    padding: 0 16px;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    font-size: 13px;
    cursor: pointer;
    transition: background .2s;
    white-space: nowrap;
}

.re-btn-reset:hover { background: #e5e7eb; }

/* ── Grid ───────────────────────────────────────────────────── */
.re-embed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ── Card ───────────────────────────────────────────────────── */
.re-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 6px rgba(0,0,0,.07);
    transition: transform .18s, box-shadow .18s;
    display: flex;
    flex-direction: column;
}

.re-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,.11);
}

/* Image */
.re-card-img-link { display: block; }

.re-card-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #f0f2f5;
    overflow: hidden;
}

.re-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}

.re-card:hover .re-card-img { transform: scale(1.04); }

.re-card-img-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f4f8;
}

/* Badge */
.re-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    border-radius: 4px;
    color: #fff;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

.re-badge-sale { background: #f59e0b; }
.re-badge-rent { background: #10b981; }

/* Body */
.re-card-body {
    padding: 14px 16px 16px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.re-card-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.re-card-title:hover { color: #4f46e5; }

.re-card-location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 10px;
}

.re-icon-pin {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
    color: #9ca3af;
}

.re-card-divider {
    height: 1px;
    background: #f3f4f6;
    margin-bottom: 10px;
}

/* Meta row */
.re-card-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.re-meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: #6b7280;
}

.re-meta-item strong { color: #374151; }

.re-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    color: #9ca3af;
}

/* Price */
.re-card-price {
    margin: auto 0 0;
    font-size: 17px;
    font-weight: 700;
    color: #4f46e5;
}

/* ── No results ─────────────────────────────────────────────── */
.re-embed-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 20px;
    color: #9ca3af;
    font-size: 15px;
}

/* ── Loading spinner ────────────────────────────────────────── */
.re-embed-loading {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    padding: 48px 0;
}

.re-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: re-spin .7s linear infinite;
}

@keyframes re-spin { to { transform: rotate(360deg); } }

/* ── Pagination ─────────────────────────────────────────────── */
.re-embed-pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 20px 0 8px;
    flex-wrap: wrap;
}

.re-page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 10px;
    border: 1px solid #e2e8f0;
    border-radius: 7px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.re-page-btn:hover {
    background: #f3f4f6;
}

.re-page-btn.active {
    background: #4f46e5;
    color: #fff;
    border-color: #4f46e5;
}

.re-page-btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 540px) {
    .re-embed-grid {
        grid-template-columns: 1fr;
    }
    .re-filter-item { flex: 1 1 100%; }
    .re-filter-price { flex: 1 1 calc(50% - 5px); }
    .re-filter-btn-wrap { flex: 1 1 100%; justify-content: flex-end; }
}
