/* Land Direct Property Map v3.1.9 - Mobile responsive fix + Google Maps race condition fix */

/* Hide Top Rated Local badge */
.trl-corner-widget,
#topratedlocal-widget,
.trl-fixed-left,
.trl-fixed-right,
.trl-widget,
[id*="topratedlocal"],
[class*="trl-corner"],
[class*="trl-widget"],
[class*="trl-fixed"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
}

/* Reset and Base */
.ldpm-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    background: #fff;
}

/* Full page mode - force full width, prevent scrolling */
.ldpm-container.ldpm-fullpage {
    position: relative;
    margin: 0 !important;
    padding: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    margin-left: calc(-50vw + 50%) !important;
    height: 100vh;
    overflow: hidden;
}

/* When fullpage mode is active, prevent body scroll */
body.ldpm-no-footer {
    overflow: hidden !important;
}

/* Hide page title when requested */
.ldpm-hide-title + h1,
.ldpm-hide-title + .entry-title,
.ldpm-hide-title ~ h1,
.ldpm-hide-title ~ .entry-title,
body.ldpm-no-title h1.entry-title,
body.ldpm-no-title .page-title,
body.ldpm-no-title article > header h1 {
    display: none !important;
}

/* Header - Hidden by default */
.ldpm-header {
    display: none;
}

.ldpm-header.ldpm-show-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #4eb8d4;
    color: white;
}

.ldpm-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
}

.ldpm-count {
    font-size: 14px;
    color: #10b981;
    font-weight: 600;
}

/* ============================================
   FILTERS - WHITE BACKGROUND (like old site)
   ============================================ */
.ldpm-filters {
    background: #fff;
    padding: 12px 15px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-sizing: border-box;
    border-bottom: 1px solid #e5e7eb;
}

.ldpm-filter-row {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    gap: 8px;
    align-items: center;
    flex: 1;
}

/* Dropdown styling - clean input look */
.ldpm-filter-select {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    flex: 1 1 0;
    min-width: 80px;
    max-width: 160px;
    color: #374151;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 30px;
}

.ldpm-filter-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ldpm-filter-select:hover {
    border-color: #9ca3af;
}

/* Reset Button - Red/coral like old site */
.ldpm-reset-btn {
    padding: 8px 20px;
    background: #ef4444;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.2s;
}

.ldpm-reset-btn:hover {
    background: #dc2626;
}

/* ============================================
   SEARCH BOX - Real-time APN/Address search
   ============================================ */
.ldpm-search-box {
    flex: 0 0 auto;
    margin-left: 10px;
}

.ldpm-search-input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    width: 200px;
    color: #374151;
    background: white;
}

.ldpm-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ldpm-search-input::placeholder {
    color: #9ca3af;
}

/* ============================================
   VIEW TOGGLE - Clean button group
   ============================================ */
.ldpm-view-toggle {
    display: flex;
    gap: 0;
    flex: 0 0 auto;
    margin-left: 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    overflow: hidden;
}

.ldpm-view-btn {
    padding: 8px 16px;
    border: none;
    background: #fff;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    color: #374151;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 1px solid #d1d5db;
}

.ldpm-view-btn:last-child {
    border-right: none;
}

.ldpm-view-btn.active {
    background: #3b82f6;
    color: white;
}

.ldpm-view-btn:hover:not(.active) {
    background: #f3f4f6;
}

/* View button icons */
.ldpm-view-btn svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   MAIN CONTENT - Full Width, Full Height
   ============================================ */
.ldpm-main {
    display: flex;
    width: 100%;
    height: calc(100vh - 60px);
    min-height: 500px;
}

.ldpm-fullpage .ldpm-main {
    height: calc(100vh - 55px);
}

/* Cards Panel - 38% width for more map space */
/* v3.1.4: Fixed position Load More constrained to panel */
.ldpm-cards-panel {
    width: 38%;
    position: relative;
    background: #f9fafb;
    box-sizing: border-box;
    height: 100%;
    overflow: hidden;
}

/* Scrollable content wrapper */
.ldpm-cards-scroll {
    height: calc(100% - 60px); /* Leave room for Load More button */
    overflow-y: auto;
    padding: 12px;
    padding-bottom: 20px;
}

/* Load More container - FIXED to bottom LEFT of viewport (panel area only) */
.ldpm-load-more-container {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 38%; /* Match panel width */
    height: 60px;
    padding: 10px 20px;
    text-align: center;
    background: #09589E; /* Blue to match header */
    z-index: 1000;
    box-sizing: border-box;
}

/* List view - Load More spans full width */
.ldpm-main[data-view="list"] .ldpm-load-more-container {
    width: 100%;
}

/* Map view - hide Load More */
.ldpm-main[data-view="map"] .ldpm-load-more-container {
    display: none !important;
}

.ldpm-main[data-view="list"] .ldpm-cards-panel {
    width: 100%;
    height: 100%;
}

.ldpm-main[data-view="list"] .ldpm-cards-scroll {
    padding: 20px;
}

.ldpm-main[data-view="map"] .ldpm-cards-panel {
    display: none;
}

/* Map Panel */
.ldpm-map-panel {
    width: 62%;
    position: relative;
    flex: 1;
}

.ldpm-main[data-view="list"] .ldpm-map-panel {
    display: none;
}

.ldpm-main[data-view="map"] .ldpm-map-panel {
    width: 100%;
}

.ldpm-map {
    width: 100%;
    height: 100%;
    min-height: 100%;
}

/* ============================================
   PROPERTY CARDS - 2 COLUMNS IN SPLIT VIEW
   ============================================ */
.ldpm-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

/* List view - 3 columns for better layout */
.ldpm-main[data-view="list"] .ldpm-cards {
    grid-template-columns: repeat(3, 1fr);
    max-width: 1400px;
    margin: 0 auto;
    gap: 20px;
    /* padding handled by scroll wrapper */
}

/* v3.0.2: Limit card width in list view to prevent image distortion */
.ldpm-main[data-view="list"] .ldpm-card {
    max-width: 420px;
    margin: 0 auto;
}

/* Taller images in list view since cards are wider */
.ldpm-main[data-view="list"] .ldpm-card-image {
    height: 200px;
}

.ldpm-card {
    background: white;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s;
}

.ldpm-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.ldpm-card.highlighted {
    box-shadow: 0 0 0 3px #3b82f6;
}

.ldpm-card-image {
    position: relative;
    height: 160px;
    background: #e5e7eb;
    overflow: hidden;
}

.ldpm-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.ldpm-card-banner {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #10b981;
    color: white;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
}

.ldpm-card-content {
    padding: 12px;
}

.ldpm-card-location {
    font-size: 11px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.ldpm-card-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.ldpm-card-address {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
    line-height: 1.3;
}

.ldpm-card-price {
    font-size: 18px;
    font-weight: 700;
    color: #10b981;
    margin-bottom: 6px;
    line-height: 1.4;
}

.ldpm-card-terms {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
}

.ldpm-card-features {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 10px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ldpm-card-btn {
    display: block;
    width: 100%;
    padding: 10px;
    background: #1e3a5f;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.ldpm-card-btn:hover {
    background: #2563eb;
    color: white;
}

/* The wrapper added by JS (if used) - kept for compatibility */
.ldpm-load-more-wrapper {
    grid-column: 1 / -1;
    padding: 30px 20px;
    text-align: center;
    background: #e0f2fe;
    border-radius: 8px;
    margin-top: 10px;
}

.ldpm-load-more {
    padding: 12px 40px !important;
    background: #ffffff !important;
    color: #1e3a5f !important;
    border: none !important;
    border-radius: 6px !important;
    font-size: 15px !important;
    cursor: pointer !important;
    font-weight: 700 !important;
    transition: all 0.2s ease;
    outline: none !important;
    box-shadow: none !important;
}

.ldpm-load-more:hover {
    background: #f0f4f8 !important;
    color: #1e3a5f !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
    border: none !important;
}

.ldpm-load-more:focus {
    outline: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* No Results */
.ldpm-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    color: #6b7280;
}

/* Map Error Message */
.ldpm-map-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
    background: #fef2f2;
    color: #dc2626;
    font-size: 16px;
    text-align: center;
    padding: 20px;
}

.ldpm-no-results h3 {
    font-size: 18px;
    color: #374151;
    margin-bottom: 8px;
}

/* No Image Placeholder */
.ldpm-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
    color: #9ca3af;
    font-size: 13px;
}

/* ============================================
   INFO WINDOW
   ============================================ */
.ldpm-info-window {
    max-width: 280px;
    padding: 5px;
}

.ldpm-info-image {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
}

.ldpm-info-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
}

.ldpm-info-location {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 6px;
}

.ldpm-info-details {
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.ldpm-info-price {
    font-weight: 700;
    color: #10b981;
}

.ldpm-info-btn {
    display: block;
    padding: 8px;
    background: #1e3a5f;
    color: white;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.2s;
}

.ldpm-info-btn:hover {
    background: #2563eb;
    color: white;
}

/* ============================================
   HIDE FOOTER
   ============================================ */
body.ldpm-no-footer footer,
body.ldpm-no-footer .elementor-location-footer,
body.ldpm-no-footer #footer,
body.ldpm-no-footer .site-footer,
body.ldpm-no-footer .footer,
body.ldpm-no-footer #colophon {
    display: none !important;
}

/* ============================================
   LOADING STATE
   ============================================ */
.ldpm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #6b7280;
}

.ldpm-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 1200px) {
    .ldpm-filter-select {
        font-size: 13px;
        padding: 7px 10px;
        min-width: 70px;
        max-width: 140px;
    }
    
    .ldpm-reset-btn,
    .ldpm-view-btn {
        font-size: 13px;
        padding: 7px 14px;
    }
}

@media (max-width: 1000px) {
    .ldpm-filters {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .ldpm-filter-row {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .ldpm-filter-select {
        flex: 1 1 calc(25% - 8px);
        max-width: none;
    }
    
    .ldpm-view-toggle {
        margin-left: 0;
    }
    
    /* Stack cards in split view on tablets */
    .ldpm-cards {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   RESPONSIVE - MOBILE (768px and below)
   AGGRESSIVE OVERRIDES FOR THEME COMPATIBILITY
   ============================================ */
@media (max-width: 768px) {
    /* Allow body scroll on mobile even in fullpage mode */
    body.ldpm-no-footer {
        overflow: auto !important;
        overflow-x: hidden !important;
    }
    
    /* Container adjustments for mobile */
    .ldpm-container.ldpm-fullpage {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow: visible !important;
    }
    
    /* FILTERS - CRITICAL MOBILE FIX */
    .ldpm-filters {
        display: flex !important;
        flex-direction: column !important;
        padding: 10px !important;
        gap: 10px !important;
        align-items: stretch !important;
    }
    
    /* Filter row - HORIZONTAL SCROLL */
    .ldpm-filter-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 8px !important;
        padding-bottom: 8px !important;
        width: 100% !important;
        scroll-behavior: smooth;
    }
    
    /* Show thin scrollbar on mobile to hint scrolling */
    .ldpm-filter-row::-webkit-scrollbar {
        height: 4px;
    }
    
    .ldpm-filter-row::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 2px;
    }
    
    .ldpm-filter-row::-webkit-scrollbar-thumb {
        background: #ccc;
        border-radius: 2px;
    }
    
    .ldpm-filter-select {
        flex: 0 0 auto !important;
        min-width: 110px !important;
        max-width: none !important;
        font-size: 14px !important;
        white-space: nowrap !important;
    }
    
    .ldpm-reset-btn {
        flex: 0 0 auto !important;
        white-space: nowrap !important;
    }
    
    /* Search and view toggle */
    .ldpm-search-box {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .ldpm-search-input {
        width: 100% !important;
    }
    
    .ldpm-view-toggle {
        margin-left: 0 !important;
        width: 100% !important;
        display: flex !important;
        justify-content: stretch !important;
    }
    
    .ldpm-view-btn {
        flex: 1 !important;
        justify-content: center !important;
        padding: 10px 8px !important;
        text-align: center !important;
    }
    
    /* MAIN LAYOUT - STACK VERTICALLY */
    .ldpm-main {
        display: flex !important;
        flex-direction: column !important;
        height: auto !important;
        min-height: auto !important;
    }
    
    .ldpm-fullpage .ldpm-main {
        height: auto !important;
    }
    
    /* SPLIT VIEW ON MOBILE - Cards only, NO map */
    .ldpm-main[data-view="split"] .ldpm-cards-panel {
        width: 100% !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
        display: block !important;
    }
    
    .ldpm-main[data-view="split"] .ldpm-map-panel {
        display: none !important;
    }
    
    .ldpm-main[data-view="split"] .ldpm-cards-scroll {
        height: auto !important;
        max-height: 70vh !important;
        overflow-y: auto !important;
        padding-bottom: 80px !important;
    }
    
    /* LIST VIEW ON MOBILE */
    .ldpm-main[data-view="list"] .ldpm-cards-panel {
        width: 100% !important;
        height: auto !important;
    }
    
    .ldpm-main[data-view="list"] .ldpm-cards-scroll {
        height: auto !important;
        max-height: none !important;
        padding-bottom: 80px !important;
    }
    
    .ldpm-main[data-view="list"] .ldpm-map-panel {
        display: none !important;
    }
    
    /* MAP VIEW ON MOBILE - Full screen map */
    .ldpm-main[data-view="map"] .ldpm-cards-panel {
        display: none !important;
    }
    
    .ldpm-main[data-view="map"] .ldpm-map-panel {
        width: 100% !important;
        height: 70vh !important;
        min-height: 400px !important;
        display: block !important;
    }
    
    /* Cards grid - single column */
    .ldpm-cards {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .ldpm-main[data-view="list"] .ldpm-cards {
        grid-template-columns: 1fr !important;
    }
    
    .ldpm-main[data-view="list"] .ldpm-card {
        max-width: none !important;
    }
    
    /* Load More - full width fixed at bottom */
    .ldpm-load-more-container {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 1001 !important;
    }
    
    /* Card styling on mobile */
    .ldpm-card-image {
        height: 180px !important;
    }
    
    .ldpm-main[data-view="list"] .ldpm-card-image {
        height: 180px !important;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE (480px and below)
   ============================================ */
@media (max-width: 480px) {
    .ldpm-filters {
        padding: 8px;
    }
    
    .ldpm-filter-select {
        min-width: 100px;
        font-size: 13px;
        padding: 8px 10px;
    }
    
    .ldpm-view-btn {
        padding: 8px 6px;
        font-size: 12px;
    }
    
    .ldpm-card-content {
        padding: 10px;
    }
    
    .ldpm-card-price {
        font-size: 16px;
    }
    
    .ldpm-card-title {
        font-size: 13px;
    }
    
    .ldpm-card-btn {
        padding: 12px;
        font-size: 14px;
    }
    
    .ldpm-load-more {
        padding: 14px 30px !important;
        font-size: 14px !important;
    }
}

/* ============================================
   ZOOM INDICATOR (v3.2.0)
   ============================================ */
.ldpm-zoom-indicator {
    position: absolute;
    top: 10px;
    right: 50px;
    background: rgba(30, 58, 95, 0.9);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    z-index: 100;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    pointer-events: none;
}

/* ============================================
   APN LABELS ON MAP MARKERS (v3.2.0)
   ============================================ */
.ldpm-apn-label {
    position: absolute;
    transform: translateX(-50%);
    background: rgba(30, 58, 95, 0.9);
    color: #fff;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
