/* ==========================================================================
   Hacienda Lot Maps — Frontend Styles
   ========================================================================== */

.hlm-lot-map-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 1400px;
    margin: 0 auto 40px;
    border: 2px solid #2c5f4a;
    border-radius: 8px;
    overflow: visible;
    position: relative;
    background: #fff;
}

/* Header */
.hlm-map-header {
    background: #2c5f4a;
    color: #fff;
    padding: 16px 24px;
    text-align: center;
}

.hlm-map-title {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.5px;
}

/* Layout: map + side panel */
.hlm-map-layout {
    display: flex;
    min-height: 500px;
}

/* Map Area */
.hlm-map-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 2px solid #e0e0e0;
}

/* Legend Bar */
.hlm-legend-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
}

.hlm-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s, box-shadow 0.2s;
}

.hlm-legend-item:hover {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.hlm-legend-item.active {
    border-color: #333;
}

.hlm-legend-item:not(.active) {
    opacity: 0.4;
}

.hlm-legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* SVG / Map Container */
.hlm-svg-container {
    flex: 1;
    padding: 0;
    overflow: visible;
    position: relative;
    min-height: 500px;
}

/* Make sure Leaflet popups always sit above everything else in the map. */
.hlm-lot-map-wrapper .leaflet-popup-pane { z-index: 750 !important; }
.hlm-lot-map-wrapper .leaflet-popup       { z-index: 750 !important; }

.hlm-leaflet-map {
    width: 100%;
    height: 500px;
    z-index: 1;
}

.hlm-svg-source {
    display: none !important;
}

/* Lot number labels on map */
.hlm-lot-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none !important;
}

.hlm-lot-label span {
    display: block;
    text-align: center;
    font-size: 12px;
    font-weight: 800;
    color: #222;
    text-shadow:
        -1px -1px 0 rgba(255,255,255,0.9),
         1px -1px 0 rgba(255,255,255,0.9),
        -1px  1px 0 rgba(255,255,255,0.9),
         1px  1px 0 rgba(255,255,255,0.9),
         0    0   4px rgba(255,255,255,1);
    pointer-events: none;
    line-height: 1;
}

/* Map tooltip */
.hlm-map-tooltip {
    background: #333 !important;
    color: #fff !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3) !important;
}

.hlm-map-tooltip::before {
    border-top-color: #333 !important;
}

/* Map popup */
.hlm-popup-wrap .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    border: 2px solid #2c5f4a;
    padding: 0;
}

.hlm-popup-wrap .leaflet-popup-content {
    margin: 0;
}

.hlm-popup-wrap .leaflet-popup-tip {
    border-top-color: #2c5f4a;
}

.hlm-map-popup {
    padding: 14px 16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.hlm-map-popup-title {
    font-size: 15px;
    font-weight: 700;
    color: #333;
    margin-bottom: 6px;
}

.hlm-map-popup-price {
    font-weight: 600;
    color: #2c5f4a;
    font-size: 14px;
    margin-bottom: 4px;
}

.hlm-map-popup-row {
    font-size: 13px;
    color: #555;
    margin-bottom: 2px;
}

.hlm-map-popup-status {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 4px;
}

.hlm-map-popup-btn {
    display: inline-block;
    background: #2c5f4a;
    color: #fff !important;
    padding: 7px 18px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
}

.hlm-map-popup-btn:hover {
    background: #1e4435;
}

/* SVG Lot Polygons (static fallback) */
.hlm-svg-container [data-lot] {
    cursor: pointer;
    stroke: #333;
    stroke-width: 1;
    transition: opacity 0.3s, filter 0.2s;
}

.hlm-svg-container [data-lot]:hover {
    filter: brightness(0.85);
    stroke-width: 2;
}

.hlm-svg-container [data-lot].hlm-highlighted {
    stroke: #000;
    stroke-width: 3;
    filter: brightness(0.8);
}

.hlm-svg-container [data-lot].hlm-hidden {
    opacity: 0.08;
    pointer-events: none;
}

/* No Map Placeholder */
.hlm-no-map {
    text-align: center;
    padding: 60px 20px;
    color: #666;
    background: #f5f5f5;
    border-radius: 6px;
    width: 100%;
}

/* Side Panel */
.hlm-side-panel {
    width: 340px;
    min-width: 340px;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

.hlm-panel-header {
    padding: 14px 16px;
    background: #f0f0f0;
    border-bottom: 1px solid #e0e0e0;
}

.hlm-panel-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Panel Filter Buttons */
.hlm-panel-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f8f8;
}

.hlm-panel-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: #555;
}

.hlm-panel-filter-btn:hover {
    border-color: #999;
}

.hlm-panel-filter-btn.active {
    background: #2c5f4a;
    color: #fff;
    border-color: #2c5f4a;
}

.hlm-filter-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.15);
}

/* Lot Table */
.hlm-lot-table-wrap {
    flex: 1;
    overflow-y: auto;
    max-height: 500px;
}

.hlm-lot-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.hlm-lot-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.hlm-lot-table th {
    background: #e8e8e8;
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    color: #555;
    border-bottom: 2px solid #ccc;
}

.hlm-lot-table td {
    padding: 7px 10px;
    border-bottom: 1px solid #eee;
    color: #333;
}

.hlm-lot-row {
    cursor: pointer;
    transition: background-color 0.15s;
}

.hlm-lot-row:hover {
    background-color: #eef5f0 !important;
}

.hlm-lot-row.hlm-row-highlighted {
    background-color: #d4edda !important;
    font-weight: 600;
}

.hlm-lot-row.hlm-row-hidden {
    display: none;
}

.hlm-lot-num {
    font-weight: 600;
}

.hlm-status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.hlm-no-lots {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* Tooltip */
.hlm-tooltip {
    position: absolute;
    background: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
    transform: translate(-50%, -100%);
    margin-top: -10px;
}

.hlm-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #333;
}

.hlm-tooltip-lot {
    font-weight: 700;
    margin-bottom: 2px;
}

.hlm-tooltip-status {
    font-size: 11px;
    opacity: 0.85;
}

/* Click Info Popup */
.hlm-info-popup {
    position: absolute;
    z-index: 200;
    background: #fff;
    border: 2px solid #2c5f4a;
    border-radius: 8px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    padding: 20px;
    min-width: 240px;
    max-width: 300px;
}

.hlm-popup-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #999;
    line-height: 1;
    padding: 0;
}

.hlm-popup-close:hover {
    color: #333;
}

.hlm-popup-address {
    font-size: 16px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
    padding-right: 20px;
}

.hlm-popup-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    font-size: 14px;
}

.hlm-popup-price {
    font-weight: 600;
    color: #2c5f4a;
}

.hlm-popup-lot-label {
    color: #555;
}

.hlm-popup-status {
    font-weight: 700;
    font-size: 13px;
}

.hlm-popup-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13px;
    color: #666;
    margin-bottom: 12px;
}

.hlm-popup-link {
    display: inline-block;
    background: #2c5f4a;
    color: #fff;
    padding: 8px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.hlm-popup-link:hover {
    background: #1e4435;
    color: #fff;
}

/* Error */
.hlm-error {
    background: #fff3cd;
    border: 1px solid #ffc107;
    padding: 12px 16px;
    border-radius: 4px;
    color: #856404;
}

/* Responsive */
@media (max-width: 900px) {
    .hlm-map-layout {
        flex-direction: column;
    }

    .hlm-map-container {
        border-right: none;
        border-bottom: 2px solid #e0e0e0;
    }

    .hlm-side-panel {
        width: 100%;
        min-width: unset;
    }

    .hlm-lot-table-wrap {
        max-height: 350px;
    }
}
