/* ==========================================================================
   Property Floor Plans Section (Single Property & Projects)
   Zoom/pan, keyboard navigation, mobile swipe gestures & print styles
   ========================================================================== */

/* Hide container when no floor plans are present */
body:not(.elementor-editor-active) .maxx-floor-plan-container:not(.houzez-has-floor-plans) {
    display: none !important;
}

/* Floor plan image wrapper for Panzoom */
.floor-plan-image-wrap {
    position: relative;
    overflow: hidden;
    cursor: grab;
    touch-action: pinch-zoom;
    -webkit-overflow-scrolling: touch;
    background: #f8f9fa;
}

.floor-plan-image-wrap:active {
    cursor: grabbing;
}

.floor-plan-image-wrap img {
    display: block;
    max-width: 100%;
    height: auto;
    transition: transform 0.2s ease-out;
    transform-origin: center center;
    will-change: transform;
}

/* Panzoom controls */
.fp-controls {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.floor-plan-image-wrap:hover .fp-controls,
.fp-controls:focus-within {
    opacity: 1;
}

.fp-control-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: var(--property-primary, #0b6230);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background 0.2s ease;
    padding: 0;
    color: #fff;
}

.fp-control-btn:hover {
    background: #094a24;
    transform: scale(1.1);
}

.fp-control-btn:active {
    transform: scale(0.95);
}

.fp-control-btn i,
.fp-control-btn span {
    font-size: 18px;
    color: #fff;
}

.fp-pan-controls {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 2px;
    background: var(--property-primary, #0b6230);
    padding: 6px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.fp-pan-controls .fp-control-btn {
    box-shadow: none;
    background: transparent;
    width: 26px;
    height: 26px;
}

.fp-pan-controls .fp-control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.fp-pan-up { grid-column: 2; grid-row: 1; }
.fp-pan-left { grid-column: 1; grid-row: 2; }
.fp-pan-right { grid-column: 3; grid-row: 2; }
.fp-pan-down { grid-column: 2; grid-row: 3; }

/* Keyboard navigation focus states */
.accordion-header:focus {
    outline: 2px solid var(--property-primary, #0b6230);
    outline-offset: 2px;
}

.accordion-header:focus:not(:focus-visible) {
    outline: none;
}

.accordion-header:focus-visible {
    outline: 2px solid var(--property-primary, #0b6230);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(11, 98, 48, 0.15);
}

/* Mobile responsiveness for floor plan viewer */
@media (max-width: 768px) {
    .floor-plan-image-wrap {
        max-height: 60vh;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .floor-plan-image-wrap img {
        max-height: 60vh;
        width: auto;
        object-fit: contain;
    }

    /* Always show zoom/pan controls on touch devices — :hover never fires */
    .fp-controls {
        opacity: 1;
    }

    /* Larger touch target for mobile */
    .accordion-header {
        min-height: 48px;
        padding: 12px 16px;
    }

    /* Improve swipe gesture area */
    .maxx-floor-plan-accordion {
        touch-action: pan-y;
    }
}

/* Touch devices: always show zoom/pan controls regardless of viewport width */
@media (hover: none) and (pointer: coarse) {
    .fp-controls {
        opacity: 1;
    }
}

/* Print styles for floor plans */
@media print {
    .floor-plan-image-wrap {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .fp-controls {
        display: none !important;
    }

    .floor-plan-image-wrap img {
        max-width: 100% !important;
        height: auto !important;
    }
}

