/* ==========================================================================
   RBM REAL ESTATE — Frontend Styles
   Version: 1.0.0
   Prefix: .rbm- for total theme isolation.
   ========================================================================== */

:root {
    --rbm-color-primary:   #008c8c;
    --rbm-color-accent:    #3498db;
    --rbm-color-accent-dk: #2980b9;
    --rbm-color-green:     #009f3a;
    --rbm-color-blue:      #0b5cff;
    --rbm-color-betta-blue:#066a88;
    --rbm-color-orange:    #f39c12;
    --rbm-color-red:       #e50914;
    --rbm-color-red-ar:    #ff0033;
    --rbm-color-grey-lt:   #f4f6f8;
    --rbm-color-grey-md:   #0cabb7;
    --rbm-color-bone:      #f1ebe4;
    --rbm-color-border:    #eaeaea;
    --rbm-color-text:      #333333;

    --rbm-radius-card:  14px;
    --rbm-radius-btn:   8px;
    --rbm-radius-badge: 6px;

    --rbm-shadow-card:  0 4px 20px rgba(0,0,0,0.07);
    --rbm-shadow-hover: 0 12px 32px rgba(0,0,0,0.13);

    --rbm-transition: 0.3s cubic-bezier(.25,.8,.25,1);
    --rbm-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.rbm-archive-page *,
.rbm-archive-page *::before,
.rbm-archive-page *::after,
.rbm-carousel-wrapper *,
.rbm-carousel-wrapper *::before,
.rbm-carousel-wrapper *::after {
    box-sizing: border-box;
}

.rbm-card,
.rbm-property-main-header,
.rbm-property-details-container {
    border: 2px solid var(--rbm-color-primary);
}

.rbm-card {
    background: #ffffff;
    border-radius: var(--rbm-radius-card);
    overflow: hidden;
    box-shadow: var(--rbm-shadow-card);
    transition: transform var(--rbm-transition), box-shadow var(--rbm-transition);
    display: flex;
    flex-direction: column;
    font-family: var(--rbm-font);
    color: var(--rbm-color-text);
}

.rbm-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--rbm-shadow-hover);
}

.rbm-card__image {
    position: relative;
    height: 230px;
    background: var(--rbm-color-grey-lt);
    overflow: hidden;
    flex-shrink: 0;
}

.rbm-card__image .rbm-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.55s var(--rbm-transition);
}

.rbm-card:hover .rbm-card__img {
    transform: scale(1.06);
}

.rbm-card__no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    color: var(--rbm-color-grey-md);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.rbm-card__badge {
    position: absolute;
    top: 14px;
    left: 14px;
    padding: 2px 8px;
    border-radius: var(--rbm-radius-badge);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    z-index: 2;
}

.rbm-status-in-vendita { background: var(--rbm-color-green); color: #fff; }
.rbm-status-in-affitto { background: var(--rbm-color-accent); color: #fff; }
.rbm-status-venduto,
.rbm-status-affittato { background: var(--rbm-color-red);   color: #fff; }

.rbm-card__body {
    border-top: 2px dashed var(--rbm-color-primary);
    padding: 8px 24px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.rbm-card__ref {
    font-size: 0.80rem;
    color: var(--rbm-color-text);
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rbm-card__ref-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    color: var(--rbm-color-text);
    flex-shrink: 0;
}

.rbm-card__ref-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}

.rbm-card__ref-label,
.rbm-card__metric-label,
.rbm-icon-card__text {
    font-weight: 600;
}

.rbm-card__ref-value,
.rbm-card__location {
    font-weight: 700;
}

.rbm-card__title {
    font-size: 1.2rem;
    line-height: 1.35;
    font-weight: 700;
    
    /* 1. Altezza minima per allineamento (2 righe) */
    min-height: 2.7em; 

    margin-bottom: 8px;

    line-clamp: 2;
    /* 2. Attivazione dei tre puntini */
    display: -webkit-box;           /* Obbligatorio per line-clamp */
    -webkit-line-clamp: 2;          /* Numero di righe massimo prima dei puntini */
    -webkit-box-orient: vertical;   /* Obbligatorio per definire l'orientamento */
    overflow: hidden;               /* Nasconde il testo in eccesso */
}


.rbm-card__title a {
    text-decoration: none;
    color: var(--rbm-color-primary);
    transition: color 0.2s;
}

.rbm-card__title a:hover {
    color: var(--rbm-color-accent);
}

.rbm-card__location {
    font-size: 0.88rem;
    color: var(--rbm-color-text);
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 8px;
}

.rbm-card__location-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--rbm-color-text);
    flex-shrink: 0;
}

.rbm-card__location-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}

/* Card metrics (area, rooms, bathrooms, beds) - 4-column layout */
.rbm-card__metrics {
    display: flex;
    justify-content: space-between; /* Distribute space evenly between items */
    gap: 8px; /* Reduced gap for 4 items */
}

.rbm-card__metric {
    display: flex;
    flex-direction: column; /* Stack icon above text */
    align-items: center; /* Center horizontally */
    justify-content: center; /* Center vertically */
    flex: 1; /* Each metric takes equal width */
    min-width: 0; /* Allow shrinking */
    font-size: 0.85rem;
    border-radius: 8px;
    background-color: var(--rbm-color-bone);
    color: var(--rbm-color-text);
    text-align: center;
    padding: 8px 4px;
}

.rbm-card__metric-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px; /* Slightly larger for better visibility */
    height: 24px;
    color: var(--rbm-color-text);
    margin-bottom: 4px; /* Space between icon and text */
    flex-shrink: 0;
}

.rbm-card__metric-icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}

.rbm-card__metric-value {
    font-weight: 700;
    color: var(--rbm-color-text);
    line-height: 1.2;
    margin-bottom: 1px;
}

.rbm-card__metric-label {
    color: var(--rbm-color-text);
    font-size: 0.75rem; /* Slightly smaller for labels */
    line-height: 1.1;
    text-transform: lowercase;
}

/* Icon cards for single property page */
.rbm-icon-cards-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.rbm-icon-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--rbm-color-bone);
    border-radius: var(--rbm-radius-btn);
}

.rbm-icon-card__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    color: var(--rbm-color-text);
    flex-shrink: 0;
}

.rbm-icon-card__icon svg {
    width: 100%;
    height: 100%;
    stroke-width: 2;
}

.rbm-icon-card__content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rbm-icon-card__value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rbm-color-text);
    line-height: 1;
}

.rbm-icon-card__text {
    font-size: 0.85rem;
    color: var(--rbm-color-text);
}

.rbm-card__price {
    font-size: 1.60rem;
    font-weight: 800;
    color: var(--rbm-color-text);
    margin-bottom: 8px;
}

.rbm-card__price .rbm-price__label {
    font-size: 1rem;
}

.rbm-property-price .rbm-price__label {
    font-size: 1.5rem;
}

.rbm-card__price.rbm-price--reserved,
.rbm-property-price.rbm-price--reserved {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.rbm-price__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    flex-shrink: 0;
}

.rbm-price__label {
    display: inline-block;
    line-height: 1.2;
}

.rbm-card__btn {
    display: block;
    text-align: center;
    background: var(--rbm-color-accent);
    color: #ffffff !important;
    padding: 13px 20px;
    text-decoration: none !important;
    border-radius: var(--rbm-radius-btn);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.06em;
    transition: background 0.2s ease, transform 0.15s ease;
}

.rbm-card__btn:hover {
    background: var(--rbm-color-accent-dk);
    transform: translateY(-1px);
}

.rbm-archive-page {
    width: 100%;
    max-width: 1280px;
    font-family: var(--rbm-font);
}

.rbm-archive-header {
    text-align: center;
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--rbm-color-border);
}

.rbm-page-title {
    font-size: 2.4rem;
    color: var(--rbm-color-primary);
    margin-bottom: 12px;
}

.rbm-page-content {
    max-width: 800px;
    margin: 0 auto 40px;
    color: #555555;
    text-align: center;
}

.rbm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
}

.rbm-pagination {
    grid-column: 1 / -1;
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid var(--rbm-color-border);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.rbm-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 14px;
    background: #ffffff;
    color: var(--rbm-color-betta-blue);
    border: 1px solid var(--rbm-color-border);
    border-radius: var(--rbm-radius-btn);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.rbm-pagination .page-numbers:hover {
    background: var(--rbm-color-grey-lt);
    border-color: #cbd5e1;
    color: var(--rbm-color-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.rbm-pagination .page-numbers.current {
    background: var(--rbm-color-betta-blue);
    color: #ffffff;
    border-color: var(--rbm-color-betta-blue);
    box-shadow: 0 4px 14px rgba(52,152,219,0.3);
    cursor: default;
    pointer-events: none;
}

.rbm-pagination .page-numbers.dots {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    pointer-events: none;
    padding: 0 5px;
    min-width: auto;
}

.rbm-pagination .prev.page-numbers,
.rbm-pagination .next.page-numbers {
    font-weight: 700;
    padding: 0 20px;
}

.rbm-no-results {
    grid-column: 1 / -1;
    text-align: center;
    font-size: 1.2rem;
    color: var(--rbm-color-grey-md);
    padding: 60px 0;
}

.rbm-carousel-section {
    position: relative;
    width: 100%;
    font-family: var(--rbm-font);
}

.rbm-carousel-wrapper {
    padding-top: 1.5rem;
    overflow: hidden;
}

.rbm-carousel-track {
    display: flex;
    gap: 24px;
    transition: transform 0.45s cubic-bezier(.4,0,.2,1);
    will-change: transform;
}

.rbm-carousel-slide {
    flex: 0 0 auto;
}

.rbm-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(calc(-50% - 18px));
    background: #ffffff;
    border: 2px solid var(--rbm-color-border);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
    padding: 0;
    font-size: 1.1rem;
    color: var(--rbm-color-primary);
    line-height: 1;
}

.rbm-carousel-btn:hover {
    background: var(--rbm-color-accent);
    border-color: var(--rbm-color-accent);
    color: #fff;
    box-shadow: 0 6px 20px rgba(52,152,219,0.35);
}

.rbm-carousel-btn:disabled,
.rbm-carousel-btn[aria-disabled="true"] {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
}

.rbm-carousel-btn--prev { left:  -24px; }
.rbm-carousel-btn--next { right: -24px; }

.rbm-carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 22px;
}

.rbm-carousel-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--rbm-color-border);
    border: none;
    cursor: pointer;
    padding: 0;
    transition: background 0.25s, transform 0.25s;
}

.rbm-carousel-dot.is-active,
.rbm-carousel-dot:hover {
    background: var(--rbm-color-accent);
    transform: scale(1.35);
}

/* ==========================================================================
   REDFIN-STYLE SINGLE PROPERTY PAGE
   ========================================================================== */
.rbm-single-page {
    margin: 0 auto;
    font-family: var(--rbm-font);
    color: var(--rbm-color-text);
    line-height: 1.6;
}

.rbm-single-page article {
    padding-top: 24px;
    padding-bottom: 24px;
}

.rbm-single-page *, .rbm-single-page *::before, .rbm-single-page *::after {
    box-sizing: border-box;
}

/* Main content layout */
.rbm-single-page article {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .rbm-single-page article {
        grid-template-columns: 2fr 1fr;
        gap: 24px;
    }
}

/* Gallery section — now directly inside .rbm-single-page (not inside article grid) */
/* grid-column removed: no longer inside a CSS grid container */

/* Property header */
.rbm-property-main-header {
    background: #ffffff;
    border-radius: var(--rbm-radius-card);
    padding: 24px;
    box-shadow: var(--rbm-shadow-card);
}

.rbm-badges-container {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.rbm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 8px 16px;
    border-radius: var(--rbm-radius-badge);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.rbm-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    display: block;
}

.rbm-badge-tipologia {
    background: var(--rbm-color-betta-blue);
    color: #ffffff;
}

.rbm-property-ref {
    font-size: 0.9rem;
    color: var(--rbm-color-text);
    font-weight: 600;
}

.rbm-property-ref span {
    color: var(--rbm-color-text);
    font-weight: 800;
}

.rbm-property-title {
    font-size: 2.2rem;
    line-height: 1.2;
    font-weight: 800;
    color: var(--rbm-color-primary);
}

.rbm-property-address {
    font-size: 1.1rem;
    color: var(--rbm-color-text);
    margin: 0 0 25px 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    white-space: pre-wrap;
}

.rbm-property-address-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    margin-right: 4px;
    color: var(--rbm-color-text);
}

.rbm-property-address-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.rbm-property-address-label {
    font-weight: 700;
    color: var(--rbm-color-text);
}

.rbm-property-price {
    font-size: 2rem;
    line-height: 1;
    font-weight: 800;
    color: var(--rbm-color-text);
    margin-bottom: 8px;
}

/* Details container */
.rbm-details-html-block {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

@media (min-width: 1024px) {
    .rbm-details-html-block {
        grid-column: 1;
    }
}

.rbm-property-details-container {
    background: #ffffff;
    border-radius: var(--rbm-radius-card);
    padding: 24px;
    box-shadow: var(--rbm-shadow-card);
}

.rbm-property-section-title {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--rbm-color-border);
    color: var(--rbm-color-text);
    font-weight: 700;
}

.rbm-property-description-content {
    font-size: 1.05rem;
    line-height: 1.7;
}

.rbm-property-description-content p {
    margin: 0 0 1.2em 0;
}

.rbm-property-description-content p:last-child {
    margin-bottom: 0;
}

/* Media iframes */
.rbm-media-iframe {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    height: 0;
    overflow: hidden;
    border-radius: 8px;
    background: #000;
}

.rbm-media-iframe iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

/* Chart image */
.rbm-chart-img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

 .rbm-sidebar-widget {
    background: #ffffff;
    border: 2px solid var(--rbm-color-primary);
    border-radius: var(--rbm-radius-card);
    padding: 25px;
 }

/* Sidebar styles */
@media (min-width: 1024px) {
    .rbm-single-page aside {
        grid-column: 2;
    }
    
    .rbm-sidebar-widget h3 {
        font-size: 1.3rem;
        margin: 0 0 16px 0;
        color: var(--rbm-color-text);
        font-weight: 700;
    }
}

/* Contact form/widget placeholder */
.rbm-contact-widget {
    padding: 24px;
    border-radius: var(--rbm-radius-card);
}

.rbm-contact-widget h3 {
    margin: 0 0 16px 0;
    font-size: 1.4rem;
}

/* Redfin-style Gallery */
.rbm-property-gallery {
    display: grid;
    gap: 8px;
    overflow: hidden;
    height: 500px;
}

.rbm-gallery-layout-1 { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.rbm-gallery-layout-1 .rbm-gallery-item:nth-child(1) { grid-column: 1 / -1; grid-row: 1 / -1; }

.rbm-gallery-layout-2 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr; }
.rbm-gallery-layout-2 .rbm-gallery-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / -1; }
.rbm-gallery-layout-2 .rbm-gallery-item:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / -1; }

.rbm-gallery-layout-3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.rbm-gallery-layout-3 .rbm-gallery-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
.rbm-gallery-layout-3 .rbm-gallery-item:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / 2; }
.rbm-gallery-layout-3 .rbm-gallery-item:nth-child(3) { grid-column: 2 / 3; grid-row: 2 / 3; }

.rbm-gallery-layout-4 { grid-template-columns: 2fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.rbm-gallery-layout-4 .rbm-gallery-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
.rbm-gallery-layout-4 .rbm-gallery-item:nth-child(2) { grid-column: 2 / 4; grid-row: 1 / 2; }
.rbm-gallery-layout-4 .rbm-gallery-item:nth-child(3) { grid-column: 2 / 3; grid-row: 2 / 3; }
.rbm-gallery-layout-4 .rbm-gallery-item:nth-child(4) { grid-column: 3 / 4; grid-row: 2 / 3; }

.rbm-gallery-layout-5 { grid-template-columns: 2fr 1fr 1fr; grid-template-rows: 1fr 1fr; }
.rbm-gallery-layout-5 .rbm-gallery-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
.rbm-gallery-layout-5 .rbm-gallery-item:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / 2; }
.rbm-gallery-layout-5 .rbm-gallery-item:nth-child(3) { grid-column: 3 / 4; grid-row: 1 / 2; }
.rbm-gallery-layout-5 .rbm-gallery-item:nth-child(4) { grid-column: 2 / 3; grid-row: 2 / 3; }
.rbm-gallery-layout-5 .rbm-gallery-item:nth-child(5) { grid-column: 3 / 4; grid-row: 2 / 3; }

/* Layout 6+ (6 photos, 4 columns × 2 rows, Redfin-style).
   Hero spans left column (2 rows), items 2-7 fill cols 2-4 (3 cols × 2 rows = 6 cells). */
.rbm-gallery-layout-6,
.rbm-gallery-layout-7 {
    grid-template-columns: 2fr 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    height: 500px; /* Same as layout-5 since both use 2 rows */
}
.rbm-gallery-layout-6 .rbm-gallery-item:nth-child(1),
.rbm-gallery-layout-7 .rbm-gallery-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
.rbm-gallery-layout-6 .rbm-gallery-item:nth-child(2),
.rbm-gallery-layout-7 .rbm-gallery-item:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / 2; }
.rbm-gallery-layout-6 .rbm-gallery-item:nth-child(3),
.rbm-gallery-layout-7 .rbm-gallery-item:nth-child(3) { grid-column: 3 / 4; grid-row: 1 / 2; }
.rbm-gallery-layout-6 .rbm-gallery-item:nth-child(4),
.rbm-gallery-layout-7 .rbm-gallery-item:nth-child(4) { grid-column: 4 / 5; grid-row: 1 / 2; }
.rbm-gallery-layout-6 .rbm-gallery-item:nth-child(5),
.rbm-gallery-layout-7 .rbm-gallery-item:nth-child(5) { grid-column: 2 / 3; grid-row: 2 / 3; }
.rbm-gallery-layout-6 .rbm-gallery-item:nth-child(6),
.rbm-gallery-layout-7 .rbm-gallery-item:nth-child(6) { grid-column: 3 / 4; grid-row: 2 / 3; }
.rbm-gallery-layout-7 .rbm-gallery-item:nth-child(7) { grid-column: 4 / 5; grid-row: 2 / 3; }

/* ── Responsive: shrink right column count progressively ── */

/* Tablet: 3 columns (hero spans 2 rows, right side is 2 cols × 2 rows = 4 small images) */
@media (max-width: 1100px) {
    .rbm-gallery-layout-6,
    .rbm-gallery-layout-7 {
        grid-template-columns: 2fr 1fr 1fr;
        grid-template-rows: 1fr 1fr;
    }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(1),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(2),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / 2; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(3),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(3) { grid-column: 3 / 4; grid-row: 1 / 2; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(4),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(4) { grid-column: 2 / 3; grid-row: 2 / 3; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(5),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(5) { grid-column: 3 / 4; grid-row: 2 / 3; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(n+6),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(n+6) { display: none; }
    /* Reset height to 500px since only 2 rows */
    .rbm-gallery-layout-6,
    .rbm-gallery-layout-7 { height: 500px; }
}

/* Small: 2 columns (hero spans 2 rows, right side is 1 col × 2 rows = 2 small images) */
@media (max-width: 900px) {
    .rbm-gallery-layout-6,
    .rbm-gallery-layout-7 {
        grid-template-columns: 2fr 1fr;
        grid-template-rows: 1fr 1fr;
    }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(1),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(1) { grid-column: 1 / 2; grid-row: 1 / 3; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(2),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(2) { grid-column: 2 / 3; grid-row: 1 / 2; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(3),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(3) { grid-column: 2 / 3; grid-row: 2 / 3; }
    .rbm-gallery-layout-6 .rbm-gallery-item:nth-child(n+4),
    .rbm-gallery-layout-7 .rbm-gallery-item:nth-child(n+4) { display: none; }
    .rbm-gallery-layout-6,
    .rbm-gallery-layout-7 { height: 500px; }
}

.rbm-gallery-item {
    position: relative;
    cursor: pointer;
    overflow: hidden;
    border-radius: 8px;
}

.rbm-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(.25,.8,.25,1), opacity 0.3s;
}

.rbm-gallery-item:hover img {
    opacity: 0.9;
    transform: scale(1.04);
}

/* Redfin-style gallery overlay button */
.rbm-gallery-overlay-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.98);
    color: var(--rbm-color-text);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.95rem;
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    border: 1px solid rgba(0,0,0,0.08);
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.rbm-gallery-overlay-btn:hover {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    transform: translateY(-1px);
}

.rbm-gallery-overlay-btn svg {
    width: 24px;
    height: 24px;
}

.rbm-lightbox {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: none;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.3s ease;
    font-family: var(--rbm-font);
}

.rbm-lightbox.is-open {
    display: flex;
    opacity: 1;
}

.rbm-lightbox__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    color: #fff;
}

.rbm-lightbox__counter {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.rbm-lightbox__toolbar {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.rbm-lightbox__toolbar svg {
    width: 22px;             /* Comanda la grandezza qui */
    height: 22px;
    display: block;          /* Evita spazi vuoti strani */
    stroke-width: 4px;
}

.rbm-lightbox__tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    min-width: 48px;
    height: 48px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.rbm-lightbox__tool:hover {
    background: rgba(255, 255, 255, 0.24);
    transform: translateY(-1px);
}

.rbm-lightbox__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    background: transparent;
    border: none;
    color: #fff;
    line-height: 0;
    cursor: pointer;
    transition: transform 0.2s, color 0.2s;
}

.rbm-lightbox__close:hover {
    color: var(--rbm-color-red-ar);
}

.rbm-lightbox__close svg {
    width: 48px;
    height: 48px;
}

.rbm-lightbox__content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 0 80px 40px;
    overflow: hidden;
}

.rbm-lightbox__content img {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    user-select: none;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    transition: transform 0.18s ease;
    transform-origin: center center;
    touch-action: none;
    cursor: zoom-in;
    z-index: 1;
    position: relative;
}

.rbm-lightbox__content img.rbm-lightbox__image--dragging {
    transition: none;
}

/* Swipe animation styles for mobile gestures */
.rbm-lightbox__content img.rbm-lightbox__image--swipe-left {
    animation: rbmSwipeLeft 0.3s ease-out;
}

.rbm-lightbox__content img.rbm-lightbox__image--swipe-right {
    animation: rbmSwipeRight 0.3s ease-out;
}

@keyframes rbmSwipeLeft {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateX(-30px) scale(0.95);
        opacity: 0.7;
    }
    100% {
        transform: translateX(-100px) scale(0.9);
        opacity: 0;
    }
}

@keyframes rbmSwipeRight {
    0% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateX(30px) scale(0.95);
        opacity: 0.7;
    }
    100% {
        transform: translateX(100px) scale(0.9);
        opacity: 0;
    }
}

/* Mobile-specific optimizations */
@media (max-width: 768px) {
    .rbm-lightbox__content img {
        max-height: 75vh;
        touch-action: pan-x pan-y pinch-zoom;
        -webkit-touch-callout: none;
    }
    
    .rbm-lightbox__content {
        padding: 0 20px 30px;
    }
    
    /* Improve tap targets for mobile */
    .rbm-lightbox__nav {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }
    
    .rbm-lightbox__tool {
        min-width: 44px;
        height: 38px;
        padding: 0 12px;
    }
}

/* Prevent text selection during gestures */
.rbm-lightbox__content {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.rbm-lightbox__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 1.6rem;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.rbm-lightbox__nav:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.05);
}

.rbm-lightbox__nav svg {
    width: 24px; 
    height: 24px;
}

.rbm-lightbox__prev { left: 20px; }
.rbm-lightbox__next { right: 20px; }

.rbm-property-title {
    font-size: 2rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.rbm-property-address {
    font-size: 1.1rem;
    color: var(--rbm-color-text);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.rbm-property-address-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.rbm-property-address-label {
    font-weight: 700;
}

.rbm-property-price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--rbm-color-text);
}

.rbm-price--reserved {
    color: #d4a300;
}

.rbm-property-ref {
    margin-bottom: 8px;
}

.rbm-badges-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

.rbm-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 13px;
    border-radius: var(--rbm-radius-badge);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.rbm-badge svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    display: block;
}

.rbm-details-html-block .rbm-property-details-container {
    background: #ffffff;
}

.rbm-details-html-block .rbm-property-section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--rbm-color-text);
    border-left: 4px solid var(--rbm-color-accent);
    padding: 0 0 8px 8px;
    margin-bottom: 16px;
    line-height: 1;
}

.rbm-details-html-block .rbm-html-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 14px 36px;
    padding: 0;
    list-style: none;
    margin: 0 0 36px 0;
}

.rbm-details-html-block .rbm-html-list__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1.05rem;
}

/* Redfin-style feature icons */
.rbm-details-html-block .rbm-html-list__label {
    font-weight: 600;
    color: var(--rbm-color-grey-md);
    display: flex;
    align-items: center;
    gap: 10px;
}

.rbm-feature-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--rbm-color-grey-md);
    opacity: 0.8;
}

.rbm-details-html-block .rbm-html-list__value {
    color: var(--rbm-color-primary);
    font-weight: 600;
    text-align: right;
}

.rbm-property-description-content {
    line-height: 1.6;
    font-size: 1.05rem;
}

.rbm-media-iframe {
    width: 100%;
    aspect-ratio: 16/9;
    border: none;
    border-radius: 8px;
    overflow: hidden;
}

.rbm-media-iframe iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Agent Widget Styles */
.rbm-agent-widget {
    background: #ffffff;
    border: 2px solid var(--rbm-color-primary);
    border-radius: var(--rbm-radius-card);
    padding: 24px;
    margin-bottom: 24px;
}

.rbm-agent-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rbm-agent-photo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--rbm-color-border);
}

.rbm-agent-photo-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--rbm-color-grey-lt);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid var(--rbm-color-border);
    color: var(--rbm-color-grey-md);
}

.rbm-agent-info {
    flex: 1;
}

.rbm-agent-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--rbm-color-text);
    margin: 0 0 5px 0;
}

.rbm-agent-placeholder .rbm-agent-name {
    color: var(--rbm-color-grey-md);
}

/* Agent Error Message Styles */
.rbm-agent-error {
    background: #fff5f5;
    border: 2px solid #f8d7da;
    border-radius: var(--rbm-radius-card);
    padding: 25px;
    margin-bottom: 30px;
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.rbm-agent-error-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rbm-agent-error-icon svg {
    width: 100%;
    height: 100%;
}

.rbm-agent-error-message {
    flex: 1;
}

.rbm-agent-error-title {
    color: #dc3232;
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.rbm-agent-error-description {
    color: #721c24;
    font-size: 0.95rem;
    margin: 0;
    line-height: 1.5;
}

/* Mobile adjustments for agent error */
@media (max-width: 768px) {
    .rbm-agent-error {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 15px;
        padding: 20px;
    }
    
    .rbm-agent-error-icon {
        width: 36px;
        height: 36px;
    }
    
    .rbm-agent-error-title {
        font-size: 1.1rem;
    }
}

/* Contact Form 7 Styles */
.wpcf7-form p {
    margin: 0;
}

.wpcf7-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--rbm-color-text);
}

.wpcf7-form input[type="text"],
.wpcf7-form input[type="email"],
.wpcf7-form input[type="tel"] {
    max-height: 46px;
}

.wpcf7-form input[type="text"],
.wpcf7-form input[type="email"],
.wpcf7-form input[type="tel"],
.wpcf7-form textarea {
    width: 100%;
    padding: 11px 12px;
    border: 2px solid var(--rbm-color-border);
    border-radius: var(--rbm-radius-btn);
    font-family: var(--rbm-font);
    font-size: 1rem;
    font-weight: 500;
    color: #777;
}

.wpcf7-form input:focus,
.wpcf7-form textarea:focus {
    border-color: var(--rbm-color-accent);
}

.wpcf7-form .wpcf7-submit {
    background: var(--rbm-color-accent);
    color: #ffffff;
    border: none;
    padding: 14px 20px;
    border-radius: var(--rbm-radius-btn);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.wpcf7-form .wpcf7-submit:hover {
    background: var(--rbm-color-accent-dk);
    transform: translateY(-2px);
}

.wpcf7 form .wpcf7-response-output {
    margin: 1em 0 0 0;
    padding: 0.5em 1em;
    border-radius: var(--rbm-radius-btn);
}

/* Contact Form Widget */
.rbm-contact-widget {
    padding: 24px;
    border-radius: var(--rbm-radius-card);
}

.rbm-contact-widget h3 {
    margin: 0 0 16px 0;
    font-size: 1.4rem;
}

.rbm-contact-widget .wpcf7-form input,
.rbm-contact-widget .wpcf7-form textarea {
    border-color: var(--rbm-color-border);
}

.rbm-contact-widget .wpcf7-form input::placeholder,
.rbm-contact-widget .wpcf7-form textarea::placeholder {
    color: #bcbcbc;
}

.rbm-contact-widget .wpcf7-form label {
    font-size: 0.88rem;
    color: var(--rbm-color-text);
    text-transform: uppercase;
}

/* ==========================================================================
   SIDEBAR: DESKTOP STICKY + MOBILE BOTTOM BAR + MODAL
   Zero-JS sticky. Zero-overhead modal. Mobile bottom app bar pattern.
   ========================================================================== */

/* Desktop (≥1024px): sidebar tracks viewport on scroll, no overflow scrollbar */
@media (min-width: 1024px) {
    .rbm-property-sidebar {
        position: sticky;
        top: 24px;
        align-self: start;
    }
    .rbm-agent-contact-btn {
        display: none;
    }
    #rbm-contact-modal {
        position: static;
        display: block;
    }
    .rbm-contact-modal__backdrop,
    .rbm-contact-modal__close {
        display: none;
    }
    .rbm-contact-modal__container {
        position: static;
        transform: none;
        width: auto;
        padding: 0;
        background: transparent;
        border-radius: 0;
        box-shadow: none;
    }
    #rbm-contact-modal .rbm-contact-widget {
        border: 2px solid var(--rbm-color-primary);
        padding: 25px;
        box-shadow: var(--rbm-shadow-card);
    }
}

/* Mobile (<1024px): sidebar becomes fixed bottom bar, modal centered overlay */
@media (max-width: 1023px) {
    .rbm-property-sidebar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: #ffffff;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.1);
        padding: 12px 16px;
        margin: 0;
        border-top: 2px solid var(--rbm-color-primary);
    }
    /* Push footer up above the fixed bottom bar */
    body.single-rbm_property .footer-wrapper {
        margin-bottom: 120px;
    }
    .rbm-agent-widget {
        border: none;
        padding: 0;
        margin: 0;
        background: transparent;
        box-shadow: none;
    }
    .rbm-agent-widget h3 {
        display: none;
    }
    .rbm-agent-card {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .rbm-agent-info {
        flex: 1;
        min-width: 0;
    }
    .rbm-agent-photo,
    .rbm-agent-photo-placeholder {
        width: 44px;
        height: 44px;
    }
    .rbm-agent-name {
        font-size: 1rem;
        margin: 0;
    }
    .rbm-agent-contact-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        margin-top: 8px;
        padding: 10px 20px;
        background: var(--rbm-color-accent);
        color: #fff;
        border: none;
        border-radius: var(--rbm-radius-btn);
        font-weight: 700;
        font-size: 0.95rem;
        cursor: pointer;
        transition: background 0.2s;
    }
    .rbm-agent-contact-btn:hover {
        background: var(--rbm-color-accent-dk);
    }
    .rbm-agent-contact-btn svg {
        width: 18px;
        height: 18px;
    }

    /* Modal: centered overlay with backdrop */
    #rbm-contact-modal {
        position: fixed;
        inset: 0;
        z-index: 99999;
        display: flex;
        align-items: center;
        justify-content: center;
        visibility: hidden;
        opacity: 0;
        transition: opacity 0.2s, visibility 0.2s;
    }
    #rbm-contact-modal.is-open {
        visibility: visible;
        opacity: 1;
    }
    .rbm-contact-modal__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0,0,0,0.6);
    }
    .rbm-contact-modal__container {
        position: relative;
        width: 92%;
        max-width: 520px;
        max-height: 90vh;
        overflow-y: auto;
        background: #fff;
        border-radius: var(--rbm-radius-card);
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
        padding: 32px 24px 24px;
        z-index: 1;
    }
    .rbm-contact-modal__close {
        position: absolute;
        top: 12px;
        right: 12px;
        width: 36px;
        height: 36px;
        border: none;
        background: var(--rbm-color-grey-lt);
        border-radius: 50%;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 2;
    }
    .rbm-contact-modal__close svg {
        width: 20px;
        height: 20px;
    }
    #rbm-contact-modal .rbm-contact-widget {
        border: none;
        padding: 0;
        margin: 0;
        box-shadow: none;
    }
}

.rbm-chart-img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 30px;
}

@media (max-width: 768px) {
    .rbm-property-gallery {
        display: flex;
        height: 320px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        border-radius: 0;
        margin-left: -20px;
        margin-right: -20px;
        width: calc(100% + 40px);
        gap: 0;
    }
    
    .rbm-gallery-item {
        flex: 0 0 100%;
        scroll-snap-align: start;
        border-radius: 0;
    }

    .rbm-gallery-overlay-btn {
        display: none;
    }

    .rbm-lightbox__content { padding: 0 10px 20px; }
    .rbm-lightbox__nav { width: 44px; height: 44px; font-size: 1.3rem; z-index: 100; }
    .rbm-lightbox__prev { left: 10px; }
    .rbm-lightbox__next { right: 10px; }
    .rbm-lightbox__header { padding: 15px 20px; }
    .rbm-lightbox__toolbar { gap: 8px; }
    .rbm-lightbox__tool { min-width: 42px; height: 36px; padding: 0 10px; }
    .rbm-lightbox__close { font-size: 2.2rem; }
}

@media (max-width: 680px) {
    .rbm-property-title { font-size: 1.9rem; }
    .rbm-details-html-block .rbm-html-list { grid-template-columns: 1fr; }
    .rbm-archive-page { padding: 0 14px; }
    .rbm-page-title { font-size: 1.7rem; }
    .rbm-details-html-block .rbm-html-list__item { align-items: flex-start; }
    
    /* Responsive styles for icon cards — 2 columns on mobile */
    .rbm-icon-cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .rbm-icon-card {
        padding: 10px 12px;
        gap: 8px;
    }
    
    .rbm-icon-card__value {
        font-size: 1.1rem;
    }
    
    .rbm-icon-card__text {
        font-size: 0.8rem;
    }
    
    /* Responsive styles for card metrics (4-column layout) */
    .rbm-card__metrics {
        gap: 6px; /* Reduced gap for smaller screens */
    }
    
    .rbm-card__metric {
        font-size: 0.75rem; /* Slightly smaller font */
        padding: 2px 1px; /* Reduced padding */
    }
    
    .rbm-card__metric-icon {
        width: 16px; /* Slightly smaller but still visible */
        height: 16px;
        margin-bottom: 2px; /* Reduced space between icon and text */
    }
    
    .rbm-card__metric-value {
        font-size: 0.85rem; /* Adjust value size */
        line-height: 1.1;
    }
    
    .rbm-card__metric-label {
        font-size: 0.7rem; /* Smaller label */
        line-height: 1;
    }
}

/* Nearby amenities checkmark styling */
.rbm-nearby-check {
    color: var(--rbm-color-green);
    font-weight: bold;
    font-size: 1.2em;
}
