/* Listings Page Styles - Modern */

/* =========================================
   FULL WIDTH & PAGE TITLE HIDING
   ========================================= */

/* Hide page titles when listings wrapper is present */
body:has(.wpl-listings-wrapper) .entry-title,
body:has(.wpl-listings-wrapper) .page-title,
body:has(.wpl-listings-wrapper) .wp-block-post-title,
body:has(.wpl-listings-wrapper) h1.has-text-align-center,
body:has(.wpl-listings-wrapper) article>header,
body:has(.wpl-listings-wrapper) .ast-archive-description {
    display: none !important;
}

/* Override WordPress block editor constrained layout */
body:has(.wpl-listings-wrapper) .is-layout-constrained> :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
    max-width: none !important;
}

/* Remove container padding for full-width */
body:has(.wpl-listings-wrapper) .entry-content,
body:has(.wpl-listings-wrapper) .page-content,
body:has(.wpl-listings-wrapper) .wp-block-post-content,
body:has(.wpl-listings-wrapper) .wp-site-blocks,
body:has(.wpl-listings-wrapper) .has-global-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* JS fallback class for browsers without :has() */
body.wpl-has-listings-page .entry-title,
body.wpl-has-listings-page .page-title,
body.wpl-has-listings-page .wp-block-post-title,
body.wpl-has-listings-page article>header {
    display: none !important;
}

body.wpl-has-listings-page .is-layout-constrained> :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
    max-width: none !important;
}

body.wpl-has-listings-page .entry-content,
body.wpl-has-listings-page .wp-block-post-content,
body.wpl-has-listings-page .has-global-padding {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* =========================================
   MAIN WRAPPER STYLES
   ========================================= */

.wpl-listings-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 30px;
    width: 100%;
    box-sizing: border-box;
}

.wpl-listings-modern {
    display: flex;
    gap: 24px;
}

/* Filters Sidebar */
.wpl-filters-sidebar {
    flex: 0 0 300px;
}

.wpl-filters-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
    position: sticky;
    top: 100px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.wpl-filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    margin-bottom: 14px;
    border-bottom: 1px solid #e5e7eb;
}

.wpl-filters-title {
    display: flex;
    align-items: center;
    gap: 6px;
}

.wpl-filters-header .dashicons {
    color: #6b7280;
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.wpl-filters-header h2 {
    margin: 0;
    font-size: 0.9em;
    font-weight: 600;
    color: #1f2937;
}

/* Close button - hidden on desktop */
.wpl-filter-close-btn {
    display: none;
}

.wpl-filter-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wpl-filter-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.wpl-filter-group label {
    font-size: 0.7em;
    font-weight: 600;
    color: #374151;
}

.wpl-filter-group select,
.wpl-filter-group input {
    width: 100%;
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.75em;
    color: #1f2937;
    background: #f9fafb;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Ensure select has dropdown arrow */
.wpl-filter-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

.wpl-filter-group select:focus,
.wpl-filter-group input:focus {
    outline: none;
    border-color: var(--wpl-primary);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
    background-color: #fff;
}

.wpl-input-icon {
    position: relative;
    display: block;
}

.wpl-input-icon .dashicons {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--wpl-primary);
    font-size: 14px;
    width: 14px;
    height: 14px;
    z-index: 1;
    pointer-events: none;
}

.wpl-input-icon input,
.wpl-input-icon select {
    padding-left: 28px !important;
}

.wpl-price-inputs {
    display: flex;
    gap: 8px;
}

.wpl-price-inputs input {
    flex: 1;
    min-width: 0;
}

.wpl-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 6px;
}

.wpl-filter-actions-top {
    padding-top: 0;
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid #e5e7eb;
}

.wpl-filter-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.7em;
    color: #9ca3af;
    font-style: italic;
}

.wpl-price-formatted {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.wpl-price-formatted span {
    flex: 1;
    font-size: 0.7em;
    color: var(--wpl-primary, #4f46e5);
    font-weight: 600;
    text-align: center;
    min-height: 1em;
}

.wpl-option-disabled {
    color: #9ca3af !important;
    background: #f3f4f6 !important;
}

.wpl-btn-search {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 8px 14px;
    background: var(--wpl-primary);
    color: var(--wpl-btn-text, #fff);
    border: none;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.wpl-btn-search:hover {
    opacity: 0.9;
}

.wpl-btn-search .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.wpl-btn-reset {
    display: block;
    padding: 6px 12px;
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.75em;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.wpl-btn-reset:hover {
    background: #f3f4f6;
    color: #374151;
}

/* Main Listings Section */
.wpl-listings-main {
    flex: 1;
    min-width: 0;
}

.wpl-listings-header {
    margin-bottom: 16px;
}

.wpl-listings-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.wpl-listings-header h1 {
    margin: 0;
    font-size: 1.25em;
    font-weight: 700;
    color: #1f2937;
}

.wpl-results-count {
    font-size: 0.75em;
    color: #6b7280;
}

.wpl-listings-search-bar {
    max-width: 400px;
}

.wpl-listings-search-bar .wpl-search-input {
    height: 38px;
    padding: 8px 36px 8px 38px;
    font-size: 0.85em;
}

/* Property Grid */
.wpl-listings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

/* Property Card Modern */
.wpl-property-card-modern {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

/* Clickable Card Link */
a.wpl-property-card-modern.wpl-card-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.wpl-property-card-modern:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.wpl-card-image-modern {
    position: relative;
    height: 140px;
    overflow: hidden;
    background: #f3f4f6;
}

.wpl-card-image-modern img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s;
}

.wpl-property-card-modern:hover .wpl-card-image-modern img {
    transform: scale(1.05);
}

.wpl-no-image {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e5e7eb;
}

.wpl-no-image .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: #9ca3af;
}

.wpl-badge-transaction {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    background: var(--wpl-secondary);
    backdrop-filter: blur(4px);
    color: var(--wpl-btn-text, #fff);
    font-size: 0.6em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    z-index: 2;
}

.wpl-badge-type {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 3px 8px;
    background: var(--wpl-primary);
    color: var(--wpl-btn-text, #fff);
    font-size: 0.6em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 4px;
    z-index: 2;
}

.wpl-badge-sold {
    padding: 3px 10px;
    background: #1f2937;
    color: #fff;
    font-size: 0.65em;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 4px;
}

.wpl-card-image-modern .wpl-badge-sold {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 3;
}

.wpl-image-gradient {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.3));
    pointer-events: none;
}

.wpl-card-body-modern {
    padding: 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.wpl-card-title-modern {
    display: block;
    font-size: 0.9em;
    font-weight: 600;
    color: #1f2937;
    text-decoration: none;
    margin-bottom: 4px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color 0.2s;
}

.wpl-card-title-modern:hover {
    color: var(--wpl-primary);
}

.wpl-card-location-modern {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.7em;
    color: #6b7280;
    margin-bottom: 10px;
}

.wpl-card-location-modern .dashicons {
    color: var(--wpl-primary);
    font-size: 12px;
    width: 12px;
    height: 12px;
}

.wpl-card-specs-modern {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    padding: 8px 0;
    border-top: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 10px;
}

.wpl-spec-item-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 2px;
}

.wpl-spec-item-modern .dashicons {
    color: #9ca3af;
    font-size: 14px;
    width: 14px;
    height: 14px;
}

.wpl-spec-item-modern span:last-child {
    font-size: 0.65em;
    font-weight: 500;
    color: #374151;
}

.wpl-spec-middle {
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

.wpl-card-footer-modern {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.wpl-card-price-modern {
    font-size: 1em;
    font-weight: 700;
    color: var(--wpl-primary);
}

.wpl-btn-view-modern {
    padding: 5px 12px;
    border: 1px solid var(--wpl-primary);
    color: var(--wpl-primary);
    background: transparent;
    border-radius: 6px;
    font-size: 0.75em;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.wpl-btn-view-modern:hover {
    background: var(--wpl-primary);
    color: var(--wpl-btn-text, #fff);
}

/* No Results */
.wpl-no-results-modern {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 16px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px dashed #d1d5db;
}

.wpl-no-results-modern .dashicons {
    font-size: 36px;
    width: 36px;
    height: 36px;
    color: #9ca3af;
    margin-bottom: 12px;
}

.wpl-no-results-modern h3 {
    margin: 0 0 6px 0;
    font-size: 1em;
    color: #1f2937;
}

.wpl-no-results-modern p {
    color: #6b7280;
    margin: 0 0 14px 0;
    font-size: 0.85em;
}

.wpl-btn-clear {
    display: inline-block;
    padding: 8px 16px;
    background: var(--wpl-primary);
    color: var(--wpl-btn-text, #fff);
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8em;
    transition: opacity 0.2s;
}

.wpl-btn-clear:hover {
    opacity: 0.9;
    color: var(--wpl-btn-text, #fff);
}

/* Pagination */
.wpl-pagination-modern {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 24px;
}

.wpl-page-btn {
    padding: 6px 10px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    color: #374151;
    font-size: 0.8em;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.wpl-page-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #1f2937;
}

.wpl-page-btn.active {
    background: var(--wpl-primary);
    border-color: var(--wpl-primary);
    color: var(--wpl-btn-text, #fff);
}

/* Responsive */
@media (max-width: 1100px) {
    .wpl-listings-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .wpl-listings-wrapper {
        padding: 16px 20px;
    }

    .wpl-listings-modern {
        flex-direction: column;
        gap: 16px;
    }

    .wpl-filters-sidebar {
        flex: none;
        width: 100%;
    }

    .wpl-filters-card {
        position: static;
    }
}

@media (max-width: 640px) {
    .wpl-listings-wrapper {
        padding: 12px 16px;
    }

    .wpl-listings-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .wpl-listings-header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .wpl-listings-search-bar {
        max-width: 100%;
        width: 100%;
    }
}

/* =========================================
   MOBILE FILTER TOGGLE
   ========================================= */

/* Spacer after pagination */
.wpl-listings-spacer {
    height: 40px;
}

/* Mobile filter button - hidden on desktop */
.wpl-mobile-filter-btn {
    display: none;
}

/* Filter overlay */
.wpl-filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.wpl-filter-overlay.active {
    display: block;
}

/* Mobile/Tablet responsive filter */
@media (max-width: 900px) {

    /* Hide filters by default on mobile/tablet */
    .wpl-filters-sidebar {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 60px;
        width: 100%;
        max-width: 100%;
        z-index: 1000;
        background: #fff;
        overflow-y: auto;
        padding: 16px;
        box-sizing: border-box;
        animation: slideUp 0.3s ease;
    }

    .wpl-filters-sidebar.active {
        display: block;
    }

    .wpl-filters-card {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    /* Close button inside filter for mobile */
    .wpl-filters-sidebar.active .wpl-filters-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }

    .wpl-filters-sidebar .wpl-filter-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: #f3f4f6;
        border: none;
        border-radius: 50%;
        cursor: pointer;
        font-size: 18px;
        color: #374151;
    }

    .wpl-filters-sidebar .wpl-filter-close-btn:hover {
        background: #e5e7eb;
    }

    /* Show mobile filter button */
    .wpl-mobile-filter-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        position: fixed;
        bottom: 20px;
        left: 16px;
        right: 16px;
        padding: 14px 20px;
        background: var(--wpl-primary, #4f46e5);
        color: #fff;
        border: none;
        border-radius: 10px;
        font-size: 1em;
        font-weight: 600;
        cursor: pointer;
        z-index: 998;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transition: transform 0.2s, opacity 0.3s;
    }

    .wpl-mobile-filter-btn:hover {
        transform: translateY(-2px);
    }

    .wpl-mobile-filter-btn .dashicons {
        font-size: 18px;
        width: 18px;
        height: 18px;
    }

    .wpl-mobile-filter-btn.hidden {
        opacity: 0;
        pointer-events: none;
    }

    /* Larger spacer on mobile for fixed button */
    .wpl-listings-spacer {
        height: 80px;
    }
}

/* Animation */
@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Legacy support - keep old styles for backward compatibility */
.wpl-listings-container:not(.wpl-listings-modern) {
    display: flex;
    gap: 30px;
    margin-top: 20px;
}

.wpl-listings-container:not(.wpl-listings-modern) .wpl-filters-sidebar {
    flex: 0 0 280px;
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    height: fit-content;
}

/* ==================== */
/* Property Search Widget */
/* ==================== */
.wpl-search-widget {
    position: relative;
    max-width: 100%;
}

.wpl-search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.wpl-search-icon {
    position: absolute;
    left: 14px;
    color: #6b7280;
    font-size: 18px;
    width: 18px;
    height: 18px;
    z-index: 1;
}

.wpl-search-input {
    width: 100%;
    padding: 12px 40px 12px 42px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9em;
    color: #1f2937;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.wpl-search-input:focus {
    outline: none;
    border-color: var(--wpl-primary);
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.wpl-search-input::placeholder {
    color: #9ca3af;
}

.wpl-search-loader {
    position: absolute;
    right: 14px;
    color: var(--wpl-primary);
}

.wpl-spin {
    animation: wpl-spin 1s linear infinite;
}

@keyframes wpl-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.wpl-search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: 9999;
}

.wpl-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.wpl-search-result-item:last-child {
    border-bottom: none;
}

.wpl-search-result-item:hover {
    background: #f9fafb;
}

.wpl-search-result-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.wpl-search-result-no-image {
    width: 50px;
    height: 50px;
    border-radius: 6px;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.wpl-search-result-no-image .dashicons {
    color: #9ca3af;
    font-size: 20px;
    width: 20px;
    height: 20px;
}

.wpl-search-result-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.wpl-search-result-title {
    font-size: 0.85em;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wpl-search-result-location {
    font-size: 0.75em;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 2px;
}

.wpl-search-result-location .dashicons {
    font-size: 12px;
    width: 12px;
    height: 12px;
    color: var(--wpl-primary);
}

.wpl-search-result-price {
    font-size: 0.8em;
    font-weight: 600;
    color: var(--wpl-primary);
}

.wpl-search-no-results {
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 0.85em;
}

.wpl-search-no-results .dashicons {
    display: block;
    margin: 0 auto 8px;
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #d1d5db;
}

.wpl-listings-container:not(.wpl-listings-modern) .wpl-listings-grid {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}