/* Categorized property gallery for the main SPA */
.gallery-category-card {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.gallery-category-card img {
    display: block;
    width: 100%;
    height: 100%;
}

.gallery-category-card::after {
    content: '';
    position: absolute;
    inset: 45% 0 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, .78));
    pointer-events: none;
}

.gallery-tile-label {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 16px;
    z-index: 2;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .55);
    pointer-events: none;
}

.gallery-tile-label strong,
.gallery-tile-label small {
    display: block;
}

.gallery-tile-label strong {
    font-size: 18px;
    line-height: 1.15;
}

.gallery-tile-label small {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.3;
    opacity: .92;
}

.gallery-category-card:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 3px;
}

.property-gallery-open {
    overflow: hidden;
}

/* Keep JS-driven hidden states authoritative even when a component has its own display rule. */
.property-gallery-modal [hidden] {
    display: none !important;
}

.property-gallery-modal {
    position: fixed;
    inset: 0;
    z-index: 5000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(10, 12, 15, .82);
    backdrop-filter: blur(4px);
}

.property-gallery-modal.active {
    display: flex;
}

.property-gallery-dialog {
    width: min(1180px, 100%);
    max-height: min(900px, calc(100vh - 48px));
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .4);
}

.property-gallery-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 26px 16px;
    border-bottom: 1px solid #e8e8e8;
}

.property-gallery-header h2 {
    margin: 0;
    color: var(--primary-color);
    font-size: 28px;
    line-height: 1.15;
}

.property-gallery-header p {
    margin: 6px 0 0;
    color: var(--text-muted);
    font-size: 14px;
}

.property-gallery-close {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: #f1f1f1;
    color: #222;
    cursor: pointer;
    font-size: 30px;
    line-height: 1;
}

.property-gallery-close:hover,
.property-gallery-close:focus-visible {
    background: #e6e6e6;
}

.property-gallery-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 26px;
    border-bottom: 1px solid #ececec;
    scrollbar-width: thin;
}

.property-gallery-tab {
    flex: 0 0 auto;
    border: 1px solid #d9d9d9;
    border-radius: 999px;
    padding: 9px 14px;
    background: #fff;
    color: var(--text-main);
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

.property-gallery-tab[aria-selected='true'] {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: #fff;
}

.property-gallery-body {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(300px, .8fr);
    overflow: hidden;
}

.property-gallery-viewer {
    min-width: 0;
    overflow-y: auto;
    padding: 22px 24px 24px;
    background: #f6f6f4;
}

.property-gallery-stage {
    position: relative;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 10px;
}

/* Explicit grid placement keeps the photo centered/full-width when Prev/Next are hidden for a single-photo room. */
.property-gallery-prev {
    grid-column: 1;
    grid-row: 1;
}

.property-gallery-image-shell {
    position: relative;
    grid-column: 2;
    grid-row: 1;
    min-height: 450px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 14px;
    background: #111;
}

.property-gallery-next {
    grid-column: 3;
    grid-row: 1;
}

.property-gallery-image-shell > img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: 590px;
    object-fit: contain;
}

.property-gallery-image-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 30px;
    color: #d7d7d7;
    text-align: center;
}

.property-gallery-image-empty i {
    font-size: 38px;
}

.property-gallery-arrow {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #222;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .15);
    cursor: pointer;
}

.property-gallery-arrow:hover,
.property-gallery-arrow:focus-visible {
    transform: scale(1.04);
}

.property-gallery-photo-line {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    margin: 12px 58px 0;
    color: #666;
    font-size: 13px;
}

#property-gallery-counter {
    flex: 0 0 auto;
    font-weight: 700;
}

#property-gallery-caption {
    text-align: right;
}

.property-gallery-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    margin: 16px 58px 0;
    padding-bottom: 4px;
}

.property-gallery-thumb {
    flex: 0 0 82px;
    height: 62px;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 8px;
    background: #ddd;
    cursor: pointer;
}

.property-gallery-thumb.active {
    border-color: var(--accent-color);
}

.property-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.property-gallery-details {
    min-width: 0;
    overflow-y: auto;
    padding: 28px;
    border-left: 1px solid #ececec;
    background: #fff;
}

.property-gallery-details h3 {
    margin: 0;
    color: var(--primary-color);
    font-size: 26px;
    line-height: 1.18;
}

.property-gallery-details > p {
    font-size: 16px;
    line-height: 1.6;
}

.property-gallery-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 15px 0 18px;
}

.property-gallery-facts span {
    padding: 6px 9px;
    border-radius: 999px;
    background: #f0f2f2;
    color: #384047;
    font-size: 12px;
    font-weight: 700;
}

.property-gallery-relationship {
    margin-top: 18px;
    padding: 11px 13px;
    border-left: 4px solid var(--accent-color);
    background: #f7f7f7;
    font-weight: 700;
}

.property-gallery-bathroom-link {
    width: 100%;
    display: grid;
    grid-template-columns: 104px 1fr;
    gap: 14px;
    align-items: stretch;
    margin-top: 22px;
    padding: 0;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: #fff;
    color: inherit;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.property-gallery-bathroom-link:hover,
.property-gallery-bathroom-link:focus-visible {
    border-color: var(--accent-color);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .08);
}

.property-gallery-bathroom-link img {
    width: 104px;
    height: 100%;
    min-height: 118px;
    object-fit: cover;
    background: #eee;
}

.property-gallery-bathroom-link > span {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 13px 14px 13px 0;
}

.property-gallery-bathroom-link strong,
.property-gallery-bathroom-link small,
.property-gallery-bathroom-link em {
    display: block;
}

.property-gallery-bathroom-link strong {
    color: var(--primary-color);
    line-height: 1.25;
}

.property-gallery-bathroom-link small {
    margin-top: 5px;
    color: #626262;
    line-height: 1.4;
}

.property-gallery-bathroom-link em {
    margin-top: 9px;
    color: var(--accent-color);
    font-size: 12px;
    font-style: normal;
    font-weight: 800;
}

@media (max-width: 820px) {
    .property-gallery-modal {
        padding: 0;
    }

    .property-gallery-dialog {
        width: 100%;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
    }

    .property-gallery-header {
        padding: 15px 16px 12px;
    }

    .property-gallery-header h2 {
        font-size: 22px;
    }

    .property-gallery-header p {
        font-size: 12px;
        line-height: 1.35;
    }

    .property-gallery-close {
        width: 38px;
        height: 38px;
        font-size: 27px;
    }

    .property-gallery-tabs {
        padding: 10px 14px;
    }

    .property-gallery-tab {
        padding: 8px 12px;
        font-size: 12px;
    }

    .property-gallery-body {
        display: block;
        overflow-y: auto;
    }

    .property-gallery-viewer,
    .property-gallery-details {
        overflow: visible;
    }

    .property-gallery-viewer {
        padding: 14px 12px 18px;
    }

    .property-gallery-stage {
        grid-template-columns: 1fr;
    }

    .property-gallery-image-shell {
        grid-column: 1;
        grid-row: 1;
        min-height: 300px;
        border-radius: 10px;
    }

    .property-gallery-image-shell > img {
        max-height: 58vh;
    }

    .property-gallery-arrow {
        position: absolute;
        z-index: 3;
        top: 50%;
        transform: translateY(-50%);
        width: 38px;
        height: 38px;
        background: rgba(255, 255, 255, .9);
    }

    .property-gallery-arrow:hover,
    .property-gallery-arrow:focus-visible {
        transform: translateY(-50%) scale(1.04);
    }

    .property-gallery-prev {
        left: 8px;
    }

    .property-gallery-next {
        right: 8px;
    }

    .property-gallery-photo-line,
    .property-gallery-thumbnails {
        margin-left: 2px;
        margin-right: 2px;
    }

    .property-gallery-photo-line {
        display: block;
    }

    #property-gallery-caption {
        display: block;
        margin-top: 4px;
        text-align: left;
    }

    .property-gallery-thumb {
        flex-basis: 72px;
        height: 54px;
    }

    .property-gallery-details {
        padding: 20px 16px 32px;
        border-top: 1px solid #e7e7e7;
        border-left: 0;
    }

    .property-gallery-details h3 {
        font-size: 23px;
    }

    .property-gallery-details > p {
        font-size: 15px;
    }

    .property-gallery-bathroom-link {
        grid-template-columns: 90px 1fr;
    }

    .property-gallery-bathroom-link img {
        width: 90px;
        min-height: 112px;
    }
}

@media (max-width: 480px) {
    .gallery-tile-label {
        left: 12px;
        right: 12px;
        bottom: 11px;
    }

    .gallery-tile-label strong {
        font-size: 15px;
    }

    .gallery-tile-label small {
        font-size: 11px;
    }

    .property-gallery-image-shell {
        min-height: 255px;
    }
}
