/* 
 * WP Property Map - Frontend Styles
 */

/* ── App Wrapper ─────────────────────────────────────────────────────────── */
.wpm-frontend-wrapper {
    width: 100%;
    margin: 0 auto;
    font-family: inherit;
    display: flex;
    flex-direction: row-reverse;
    /* Map on right, Table on left */
    align-items: flex-start;
    gap: 30px;
    --wpm-text-color: #111111;
}

/* ── Maps Column ─────────────────────────────────────────────────────────── */
.wpm-maps-column {
    flex: 1 1 calc(50% - 15px);
    width: calc(50% - 15px);
    min-width: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* ── Maps Swiper ─────────────────────────────────────────────────────────── */
.wpm-maps-swiper {
    width: 100%;
    min-width: 0;
    position: relative;
    margin-bottom: 0;
    overflow: hidden;
    background: #f9f9f9;
    border-radius: var(--wpm-border-radius, 8px);
}

.wpm-map-container {
    position: relative;
    width: 100%;
    display: block;
    line-height: 0;
}

.wpm-map-image {
    width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

/* ── SVG Overlay ─────────────────────────────────────────────────────────── */
.wpm-map-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    pointer-events: none;
    /* let shapes capture events */
}

.wpm-shape {
    pointer-events: all;
    cursor: pointer;
}

.wpm-polygon {
    stroke-width: 1.5px;
    /* relative to 100x100 viewBox, so 1.5% of width */
    vector-effect: non-scaling-stroke;
    /* Keep stroke thin regardless of scale */
    fill-opacity: 0;
    stroke-opacity: 0;
    transition: fill-opacity 0.2s, stroke-opacity 0.2s, stroke-width 0.2s;
}

/* Status colors (Fill and Stroke) */
.wpm-shape.wpm-status-available .wpm-polygon {
    fill: var(--wpm-color-available, #4CAF50);
    stroke: var(--wpm-color-available, #4CAF50);
}

.wpm-shape.wpm-status-reserved .wpm-polygon {
    fill: var(--wpm-color-reserved, #FFC107);
    stroke: var(--wpm-color-reserved, #FFC107);
}

.wpm-shape.wpm-status-sold .wpm-polygon {
    fill: var(--wpm-color-sold, #F44336);
    stroke: var(--wpm-color-sold, #F44336);
    cursor: not-allowed;
}

.wpm-shape.wpm-status-unlinked .wpm-polygon {
    fill: #03A9F4;
    stroke: #03A9F4;
}

/* Hover effects */
.wpm-shape:hover .wpm-polygon,
.wpm-shape.wpm-hover-active .wpm-polygon {
    fill-opacity: var(--wpm-lot-opacity, 0.5);
    stroke-opacity: 1;
    stroke-width: 2.5px;
}

/* Label effects on hover */
.wpm-shape:hover .wpm-shape-label rect,
.wpm-shape.wpm-hover-active .wpm-shape-label rect {
    fill: #ffffff;
    stroke: #666;
}

/* ── Filter Container ────────────────────────────────────────────────────── */
.wpm-filter-wrapper {
	width: 100%;
	margin-bottom: 20px;
}

.wpm-filter-container {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 12px;
	background: #fff;
	border: 1px solid #eaeaea;
	border-radius: var(--wpm-border-radius, 8px);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.wpm-filter-icon {
	color: #999;
	font-size: 18px;
	width: 20px;
	height: 20px;
	display: flex;
	align-items: center;
	justify-content: center;
}

.wpm-filter-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
}

.wpm-filter-tag {
	display: inline-flex;
	align-items: center;
	background: #f0f4f8;
	color: #2c3e50;
	font-size: 13px;
	font-weight: 500;
	padding: 4px 8px;
	border-radius: 4px;
	white-space: nowrap;
}

.wpm-tag-remove {
	background: none;
	border: none;
	color: #999;
	margin-left: 6px;
	padding: 0;
	font-size: 16px;
	line-height: 1;
	cursor: pointer;
}

.wpm-tag-remove:hover {
	color: #f44336;
}

.wpm-filter-input {
	flex-grow: 1;
	border: none;
	outline: none;
	padding: 4px 0;
	font-size: 14px;
	min-width: 150px;
	background: transparent;
	box-shadow: none;
	color: var(--wpm-text-color);
}

.wpm-filter-input:focus {
	outline: none;
	box-shadow: none;
}

.wpm-dropdown-filters {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-top: 10px;
}

.wpm-dropdown-filter {
	flex: 1 1 auto;
	min-width: 120px;
	padding: 8px 30px 8px 12px;
	font-size: 13px;
	color: #333;
	background-color: #fff;
	border: 1px solid #eaeaea;
	border-radius: var(--wpm-border-radius, 8px);
	appearance: none;
	background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23333%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
	background-repeat: no-repeat;
	background-position: right 10px top 50%;
	background-size: 10px auto;
	cursor: pointer;
	box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.wpm-dropdown-filter option {
    font-weight: 600;
    color: #111;
}

.wpm-dropdown-filter option:disabled {
    font-weight: 400;
    color: #b0b0b0;
    font-style: italic;
}

.wpm-dropdown-filter:focus {
	outline: none;
	border-color: #999;
}

@media (max-width: 768px) {
	.wpm-dropdown-filter {
		flex: 1 1 100%;
	}
}


/* ── Lots Table ──────────────────────────────────────────────────────────── */
.wpm-table-container {
    flex: 1 1 calc(50% - 15px);
    width: calc(50% - 15px);
    min-width: min-content;
    max-width: 60%;
    box-sizing: border-box;
    overflow-x: auto;
}

.wpm-lots-table {
    width: 100%;
    border-collapse: collapse;
    background: transparent;
}

/* Hide mobile elements on desktop by default */
.wpm-mobile-icon,
.wpm-mobile-text,
.wpm-mobile-unit,
.wpm-mobile-lot-label,
.wpm-mobile-availability-header {
    display: none !important;
}

.wpm-lots-table th,
.wpm-lots-table td {
    padding: 12px 15px;
    text-align: center;
    border-bottom: 1px solid #eaeaea;
}

.wpm-lots-table th {
    background: transparent;
    font-weight: bold;
    font-size: 14px;
    color: var(--wpm-text-color);
    vertical-align: top;
}

.wpm-lots-table td {
    font-size: 14px;
    color: var(--wpm-text-color);
}

.wpm-lots-table tr {
    transition: background-color 0.2s;
}

.wpm-lots-table tr[data-lot-id] {
    cursor: pointer;
}

.wpm-lots-table tr.wpm-row-status-sold {
    cursor: not-allowed;
}

.wpm-lots-table tr:hover:not(.wpm-row-status-sold),
.wpm-lots-table tr.wpm-hover-active {
    background-color: transparent;
}

/* Row Status Backgrounds (Zones) - applied on hover */
.wpm-lots-table tr.wpm-row-status-available:hover,
.wpm-lots-table tr.wpm-row-status-available.wpm-hover-active {
    background-color: rgba(76, 175, 80, 0.15);
}

.wpm-lots-table tr.wpm-row-status-reserved:hover,
.wpm-lots-table tr.wpm-row-status-reserved.wpm-hover-active {
    background-color: rgba(255, 193, 7, 0.15);
}

.wpm-lots-table tr.wpm-row-status-sold:hover,
.wpm-lots-table tr.wpm-row-status-sold.wpm-hover-active {
    background-color: rgba(244, 67, 54, 0.15);
}

/* Sorting */
.wpm-sortable {
    cursor: pointer;
    user-select: none;
}

.wpm-sort-icon {
    display: inline-block;
    color: #999;
    font-size: 12px;
    margin-left: 4px;
}

.wpm-sortable.sort-asc .wpm-sort-icon {
    color: #333;
    font-weight: bold;
}

.wpm-sortable.sort-desc .wpm-sort-icon {
    color: #333;
    font-weight: bold;
}

/* Status Circle */
.wpm-status-circle {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

.wpm-status-circle-available {
    background-color: var(--wpm-color-available, #4CAF50);
}

.wpm-status-circle-reserved {
    background-color: var(--wpm-color-reserved, #FFC107);
}

.wpm-status-circle-sold {
    background-color: var(--wpm-color-sold, #F44336);
}

/* Legend */
.wpm-table-legend {
    margin-top: 30px;
    display: flex;
    gap: 20px;
    align-items: center;
    font-size: 14px;
    color: #333;
}

.wpm-table-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Badges */
.wpm-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    border-radius: calc(var(--wpm-border-radius, 8px) / 3);
}

.wpm-badge-available {
    background: var(--wpm-color-available, #4CAF50);
}

.wpm-badge-reserved {
    background: var(--wpm-color-reserved, #FFC107);
    color: #000;
}

.wpm-badge-sold {
    background: var(--wpm-color-sold, #F44336);
}


/* ── Modal Popup ─────────────────────────────────────────────────────────── */
.wpm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2147483647 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    padding: 20px;
}

.wpm-modal-overlay.wpm-modal-open {
    opacity: 1;
    visibility: visible;
}

.wpm-modal {
    background: #fff;
    width: 100%;
    max-width: 90vw;
    max-height: 90vh;
    display: block;
    position: relative;
    overflow: hidden;
    padding: 30px;
    box-sizing: border-box;
    border-radius: var(--wpm-border-radius, 8px);
}

.wpm-modal-content {
    display: flex;
    flex-direction: row-reverse;
    /* Details on right, Gallery on left */
    width: 100%;
    height: 100%;
    max-height: 90vh;
}

@media (max-width: 768px) {
    .wpm-modal-content {
        flex-direction: column;
        /* Details on top, Gallery on bottom */
        overflow-y: auto;
    }
}

.wpm-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #fff;
    border: none;
    width: 32px;
    height: 32px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.wpm-modal-close:hover {
    background: #f0f0f0;
}

.wpm-modal-gallery {
    width: 60%;
    background: transparent;
    position: relative;
    min-width: 0;
    aspect-ratio: 16 / 9;
    border-radius: var(--wpm-border-radius, 8px);
    overflow: hidden;
    /* Fix flex child overflow with Swiper */
}

.wpm-modal-swiper {
    width: 100%;
    height: 100%;
}

.wpm-modal-swiper img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Swiper Controls Customization */
.wpm-modal-swiper .swiper-pagination {
    bottom: 10px !important;
}

.wpm-modal-gallery .plans {
    position: relative;
    width: 100%;
    height: 100%;
}

.swiper-buttons {
    position: absolute;
    right: 15px;
    bottom: 30px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 768px) {
    .swiper-buttons {
        right: 30px;
        transform: none;
        flex-direction: row;
        gap: 10px;
    }
}

.swiper-button {
    width: 40px;
    height: 40px;
    background-color: #2c3e50;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    outline: none !important;
    border-radius: calc(var(--wpm-border-radius, 8px) / 2);
}

.swiper-button:hover {
    background-color: #1a252f;
}

.swiper-button.btn-next {
    background-color: #95a5a6;
}

.swiper-button.btn-next:hover {
    background-color: #7f8c8d;
}

.swiper-button img {
    width: 20px;
    height: 20px;
    display: block;
}

.wpm-modal-details {
    width: 40%;
    box-sizing: border-box;
    padding: 0 0 0 30px;
    border-left: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    background: #fff;
    overflow-y: auto;
    /* Allow scrolling if content is long */
}

@media (max-width: 768px) {
    .wpm-modal-details {
        width: 100%;
        padding: 30px 0 0 0;
        border-left: none;
        border-top: none;
    }

    .wpm-modal-gallery {
        width: 100%;
        aspect-ratio: 4 / 3;
    }
}

/* Button */
#wpm-modal-pdf-container {
    margin-bottom: 20px;
}

.wpm-modal-pdf-btn {
    display: inline-block;
    background-color: #2271b1;
    /* Default WP admin blue */
    color: #fff !important;
    padding: 8px 16px;
    text-decoration: none !important;
    font-weight: 500;
    transition: background-color 0.2s;
    border-radius: calc(var(--wpm-border-radius, 8px) / 2);
}

.wpm-modal-pdf-btn:hover {
    background-color: #135e96;
    color: #fff !important;
}

/* Table */
.wpm-modal-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.wpm-modal-table th,
.wpm-modal-table td {
    padding: 4px 0;
    text-align: left;
    border: none;
}

.wpm-modal-table th {
    font-weight: bold;
    color: #23274d;
    text-transform: capitalize;
    font-size: 14px;
    width: 25%;
}

.wpm-modal-table td {
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.wpm-modal-table tr:first-child th,
.wpm-modal-table tr:first-child td {
    font-size: 28px;
    color: #2c3e50;
    font-weight: bold;
    text-transform: none;
}

/* Additional Info */
.complementaires {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #eaeaea;
}

.complementaires .subtitle {
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 15px;
    font-size: 14px;
    color: #333;
}

.complementaires .txt {
    font-size: 14px;
    line-height: 1.6;
    color: #555;
}

/* ── Tooltip ─────────────────────────────────────────────────────────────── */
.wpm-tooltip {
    position: absolute;
    background: #fff;
    color: #333;
    padding: 0;
    pointer-events: none;
    z-index: 2147483647 !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease;
    width: 200px;
    overflow: hidden;
    border-radius: var(--wpm-border-radius, 8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.wpm-tooltip.wpm-tooltip-visible {
    opacity: 1;
    visibility: visible;
}

/* Tooltip Table Styles */
.wpm-tooltip-table {
    width: 100%;
    border-collapse: collapse;
}

.wpm-tooltip-table th,
.wpm-tooltip-table td {
    padding: 8px 10px;
    text-align: left;
    font-size: 12px;
    border-bottom: 1px solid #eee;
}

.wpm-tooltip-table th {
    width: 40%;
    font-weight: bold;
    color: #333;
}

.wpm-tooltip-table td {
    width: 60%;
    font-weight: normal;
    color: #333;
}

.wpm-tooltip-table tr.table-header {
    background-color: #2c3e50;
    /* Blue background for header */
}

.wpm-tooltip-table tr.table-header th:first-child {
    border-top-left-radius: var(--wpm-border-radius, 8px);
}

.wpm-tooltip-table tr.table-header th:last-child {
    border-top-right-radius: var(--wpm-border-radius, 8px);
}

.wpm-tooltip-table tr.table-header th,
.wpm-tooltip-table tr.table-header td {
    color: #fff;
    border-bottom: none;
}

.wpm-tooltip-table tr:last-child th,
.wpm-tooltip-table tr:last-child td {
    border-bottom: none;
}

/* ── Maps Thumbnails ─────────────────────────────────────────────────────── */
.wpm-maps-thumbs {
    margin-top: 15px;
    box-sizing: border-box;
    height: 100px;
}

.wpm-maps-thumbs .swiper-slide {
    width: auto;
    max-width: 200px;
    height: 100%;
    opacity: 0.5;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    border-radius: var(--wpm-border-radius, 8px);
    overflow: hidden;
}

.wpm-maps-thumbs .swiper-slide-thumb-active {
    opacity: 1;
}

.wpm-maps-thumbs .swiper-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

@media (max-width: 1190px) {
    .wpm-frontend-wrapper {
        flex-direction: column;
    }

    .wpm-maps-column,
    .wpm-table-container {
        width: 100%;
        max-width: 100%;
        flex: none;
    }

    .wpm-maps-column {
        margin-bottom: 30px;
    }

    .wpm-shape-label {
        transform: scale(1.75);
        transform-origin: center;
        transform-box: fill-box;
    }
}

@media (max-width: 768px) {
    .wpm-modal-table th {
        width: 50%;
    }

    .wpm-empty-cell {
        display: none !important;
    }

    .wpm-lots-table thead {
        display: none;
    }

    .wpm-lots-table,
    .wpm-lots-table tbody {
        display: block;
        width: 100%;
    }

    .wpm-lots-table tr {
        display: grid;
        grid-template-columns: 40% 60%;
        row-gap: 12px;
        column-gap: 5px;
        margin-bottom: 20px;
        background: #fff;
        border: 1px solid #eaeaea;
        border-radius: var(--wpm-border-radius, 8px);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
        padding: 15px;
        box-sizing: border-box;
    }

    .wpm-lots-table tr.wpm-row-status-sold {
        opacity: 0.6;
    }

    .wpm-lots-table td {
        border: none;
    }

    /* Header cell (Lot name) full width */
    .wpm-lots-table td:first-child {
        grid-column: 1 / -1;
        width: auto;
        display: flex;
        justify-content: space-between;
        align-items: center;
        background: #f9f9f9;
        margin: -15px -15px 10px -15px;
        padding: 10px 15px;
        border-bottom: 1px solid #eaeaea;
        border-radius: var(--wpm-border-radius, 8px) var(--wpm-border-radius, 8px) 0 0;
    }

    .wpm-mobile-lot-label {
        display: inline-block !important;
        font-weight: bold;
        color: var(--wpm-text-color);
        margin-right: 5px;
    }

    .wpm-mobile-availability-header {
        display: block !important;
    }

    /* Other cells with Grid */
    .wpm-lots-table td:not(:first-child) {
        width: auto;
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-start;
        padding: 0 5px;
        box-sizing: border-box;
        text-align: left;
        border-bottom: none;
    }

    .wpm-lots-table td:not(:first-child):last-child {
        border-bottom: none;
    }

    .wpm-lots-table td.wpm-price-cell {
        grid-column: 2;
    }

    /* Hide ::before as we use HTML spans now */
    .wpm-lots-table td:not(:first-child)::before {
        display: none !important;
    }

    /* Label rendering modes */
    .wpm-lots-table.wpm-labels-mode-text .wpm-mobile-text {
        display: inline-block !important;
        font-size: 13px;
        color: var(--wpm-text-color);
        margin-bottom: 0;
        margin-right: 5px;
        font-weight: bold;
    }

    .wpm-mobile-unit {
        display: inline !important;
        font-size: 12px;
        color: #888;
    }

    .wpm-lots-table td.wpm-availability-cell {
        display: none !important;
    }

    .wpm-lots-table.wpm-labels-mode-icons .wpm-mobile-icon {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        font-family: dashicons !important;
        color: #777;
        font-size: 18px;
        margin-right: 6px;
    }

    .wpm-lots-table.wpm-labels-mode-icons .wpm-mobile-icon::before {
        font-family: dashicons !important;
    }
}