/**
 * MLS Listings Grid Styles
 * Updated to use design system tokens
 *
 * @version 7.0.0
 */

.mld-listings-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--ds-space-5, 20px);
}

/* Header */
.mld-listings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--ds-space-5, 20px);
    padding-bottom: var(--ds-space-4, 15px);
    border-bottom: 2px solid var(--ds-border, #e5e7eb);
}

.mld-listings-count {
    font-size: var(--ds-text-base, 16px);
    color: var(--ds-text-tertiary, #374151);
}

.mld-listings-controls {
    display: flex;
    gap: var(--ds-space-4, 15px);
    align-items: center;
}

/* Layout Toggle */
.mld-layout-toggle {
    display: flex;
    gap: var(--ds-space-1, 5px);
}

.mld-layout-btn {
    background: var(--ds-surface-subtle, #f9fafb);
    border: 1px solid var(--ds-border, #e5e7eb);
    padding: var(--ds-space-2, 8px);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--ds-radius-md, 6px);
}

.mld-layout-btn:hover {
    background: var(--ds-surface-muted, #f3f4f6);
    border-color: var(--ds-border-strong, #d1d5db);
}

.mld-layout-btn.active {
    background: var(--ds-teal, #0891B2);
    color: var(--ds-white, white);
    border-color: var(--ds-teal, #0891B2);
}

.mld-layout-btn .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Sort Select */
.mld-sort-select {
    padding: var(--ds-space-2, 8px) var(--ds-space-3, 12px);
    border: 1px solid var(--ds-border, #e5e7eb);
    border-radius: var(--ds-radius-md, 4px);
    font-size: var(--ds-text-sm, 14px);
    cursor: pointer;
}

/* Grid Layout */
.mld-listings-container.mld-layout-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

/* List Layout */
.mld-listings-container.mld-layout-list .mld-listing-item {
    display: flex;
    margin-bottom: 20px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.mld-listings-container.mld-layout-list .mld-listing-image {
    flex: 0 0 300px;
}

.mld-listings-container.mld-layout-list .mld-listing-details {
    flex: 1;
    padding: 20px;
}

/* Listing Item - Modern card style */
.mld-listing-item {
    background: var(--ds-white, white);
    border: 1px solid var(--ds-border, #e5e7eb);
    border-radius: var(--ds-radius-xl, 12px);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--ds-shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
}

.mld-listing-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--ds-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));
}

/* Listing Image */
.mld-listing-image {
    position: relative;
    padding-bottom: 66.66%; /* 3:2 aspect ratio */
    overflow: hidden;
    background: var(--ds-surface-subtle, #f9fafb);
}

.mld-listing-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.mld-listing-item:hover .mld-listing-image img {
    transform: scale(1.05);
}

.mld-listing-price {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: var(--ds-glass-bg-dark, rgba(0, 0, 0, 0.85));
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: var(--ds-white, white);
    padding: 8px 14px;
    border-radius: var(--ds-radius-lg, 8px);
    font-size: 18px;
    font-weight: 700;
}

/* Listing Details */
.mld-listing-details {
    padding: var(--ds-space-4, 15px);
}

.mld-listing-address {
    margin: 0 0 var(--ds-space-2, 10px) 0;
    font-size: var(--ds-text-lg, 18px);
    font-weight: 600;
    color: var(--ds-text-primary, #000);
    line-height: 1.3;
}

.mld-listing-info {
    display: flex;
    gap: var(--ds-space-4, 15px);
    margin-bottom: var(--ds-space-4, 15px);
    font-size: var(--ds-text-sm, 14px);
    color: var(--ds-text-muted, #6b7280);
}

.mld-listing-info span {
    display: flex;
    align-items: center;
    gap: var(--ds-space-1, 5px);
}

.mld-listing-info strong {
    color: var(--ds-text-secondary, #1f2937);
}

.mld-listing-link {
    color: var(--ds-teal, #0891B2);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mld-listing-link:hover {
    text-decoration: underline;
}

.mld-listing-link .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* No Listings */
.mld-no-listings {
    text-align: center;
    padding: 60px 20px;
    background: var(--ds-surface-subtle, #f9fafb);
    border-radius: var(--ds-radius-lg, 8px);
}

.mld-no-listings p {
    font-size: var(--ds-text-lg, 18px);
    color: var(--ds-text-muted, #6b7280);
}

/* Pagination */
.mld-pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 40px;
}

.mld-page-link {
    display: inline-block;
    padding: 8px 12px;
    background: var(--ds-white, white);
    border: 1px solid var(--ds-border, #e5e7eb);
    border-radius: var(--ds-radius-md, 4px);
    color: var(--ds-text-secondary, #1f2937);
    text-decoration: none;
    transition: all 0.3s;
}

.mld-page-link:hover {
    background: var(--ds-surface-muted, #f3f4f6);
    border-color: var(--ds-teal, #0891B2);
}

.mld-page-link.active {
    background: var(--ds-teal, #0891B2);
    color: var(--ds-white, white);
    border-color: var(--ds-teal, #0891B2);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .mld-listings-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }

    .mld-listings-controls {
        width: 100%;
        justify-content: space-between;
    }

    .mld-listings-container.mld-layout-grid {
        grid-template-columns: 1fr;
    }

    .mld-listings-container.mld-layout-list .mld-listing-item {
        flex-direction: column;
    }

    .mld-listings-container.mld-layout-list .mld-listing-image {
        flex: none;
        width: 100%;
    }

    .mld-pagination {
        flex-wrap: wrap;
    }
}

/* ==========================================================================
   Listing Cards Shortcode - Infinite Scroll Styles
   [mld_listing_cards] shortcode specific styles
   ========================================================================== */

/* Wrapper */
.mld-listing-cards-wrapper {
    width: 100%;
    max-width: 100%;
}

/* Header */
.mld-cards-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--ds-space-4, 16px);
    padding-bottom: var(--ds-space-3, 12px);
    border-bottom: 1px solid var(--ds-border, #e5e7eb);
}

.mld-cards-count {
    font-size: var(--ds-text-sm, 14px);
    color: var(--ds-text-muted, #6b7280);
}

.mld-cards-controls {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3, 12px);
}

.mld-cards-sort {
    padding: var(--ds-space-2, 8px) var(--ds-space-3, 12px);
    border: 1px solid var(--ds-border, #e5e7eb);
    border-radius: var(--ds-radius-md, 6px);
    font-size: var(--ds-text-sm, 14px);
    background: var(--ds-white, #fff);
    cursor: pointer;
}

.mld-cards-sort:focus {
    outline: none;
    border-color: var(--ds-teal, #0891B2);
    box-shadow: 0 0 0 2px rgba(8, 145, 178, 0.2);
}

/* Grid Layout */
.mld-cards-grid {
    display: grid;
    gap: var(--ds-space-5, 20px);
}

.mld-cards-grid.mld-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.mld-cards-grid.mld-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.mld-cards-grid.mld-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Loading Indicator */
.mld-cards-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--ds-space-3, 12px);
    padding: var(--ds-space-6, 30px);
    color: var(--ds-text-muted, #6b7280);
    font-size: var(--ds-text-sm, 14px);
}

.mld-cards-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--ds-border, #e5e7eb);
    border-top-color: var(--ds-teal, #0891B2);
    border-radius: 50%;
    animation: mld-cards-spin 0.8s linear infinite;
}

@keyframes mld-cards-spin {
    to {
        transform: rotate(360deg);
    }
}

/* End of Results Message */
.mld-cards-end {
    text-align: center;
    padding: var(--ds-space-5, 20px);
    color: var(--ds-text-muted, #6b7280);
    font-size: var(--ds-text-sm, 14px);
    border-top: 1px solid var(--ds-border, #e5e7eb);
    margin-top: var(--ds-space-5, 20px);
}

.mld-cards-end p {
    margin: 0;
}

/* No Results */
.mld-cards-no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--ds-space-8, 60px) var(--ds-space-5, 20px);
    background: var(--ds-surface-subtle, #f9fafb);
    border-radius: var(--ds-radius-lg, 8px);
}

.mld-cards-no-results p {
    margin: 0;
    color: var(--ds-text-muted, #6b7280);
    font-size: var(--ds-text-base, 16px);
}

/* Error State */
.mld-listing-cards-error {
    padding: var(--ds-space-5, 20px);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--ds-radius-md, 6px);
    color: #dc2626;
    text-align: center;
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .mld-cards-grid.mld-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }

    .mld-cards-grid.mld-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .mld-cards-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--ds-space-3, 12px);
    }

    .mld-cards-controls {
        width: 100%;
    }

    .mld-cards-sort {
        width: 100%;
    }

    .mld-cards-grid.mld-cols-2,
    .mld-cards-grid.mld-cols-3,
    .mld-cards-grid.mld-cols-4 {
        grid-template-columns: 1fr;
    }

    .mld-cards-count {
        font-size: var(--ds-text-xs, 12px);
    }
}

/* ==========================================================================
   Listing Card - Simple Card Style
   Used by [mld_listing_cards] shortcode
   ========================================================================== */

.mld-listing-card-simple {
    display: block;
    background: var(--ds-white, #fff);
    border: 1px solid var(--ds-border, #e5e7eb);
    border-radius: var(--ds-radius-xl, 12px);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--ds-shadow-sm, 0 1px 3px rgba(0,0,0,0.1));
    text-decoration: none;
    color: inherit;
}

.mld-listing-card-simple:hover {
    transform: translateY(-4px);
    box-shadow: var(--ds-shadow-lg, 0 10px 15px rgba(0, 0, 0, 0.1));
    text-decoration: none;
    color: inherit;
}

.mld-card-simple-image {
    position: relative;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: var(--ds-surface-subtle, #f9fafb);
}

.mld-card-simple-image img,
.mld-card-simple-image .mld-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.mld-listing-card-simple:hover .mld-card-simple-image img,
.mld-listing-card-simple:hover .mld-card-simple-image .mld-card-image {
    transform: scale(1.05);
}

.mld-card-simple-details {
    padding: var(--ds-space-4, 16px);
}

.mld-card-simple-price {
    font-size: var(--ds-text-xl, 20px);
    font-weight: 700;
    color: var(--ds-text-primary, #1f2937);
    margin-bottom: var(--ds-space-2, 8px);
}

.mld-card-simple-address {
    margin-bottom: var(--ds-space-3, 12px);
}

.mld-card-simple-address span {
    display: block;
}

.mld-card-simple-address span:first-child {
    font-size: var(--ds-text-base, 16px);
    font-weight: 600;
    color: var(--ds-text-primary, #1f2937);
    line-height: 1.3;
}

.mld-card-simple-address span:last-child {
    font-size: var(--ds-text-sm, 14px);
    color: var(--ds-text-muted, #6b7280);
    margin-top: var(--ds-space-1, 4px);
}

.mld-card-simple-specs {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2, 8px);
    font-size: var(--ds-text-sm, 14px);
    color: var(--ds-text-muted, #6b7280);
}

.mld-card-simple-specs strong {
    color: var(--ds-text-secondary, #374151);
    font-weight: 600;
}

.mld-spec-divider {
    color: var(--ds-border-strong, #d1d5db);
}

/* Responsive - Tablet */
@media (max-width: 1024px) {
    .mld-card-simple-details {
        padding: var(--ds-space-3, 12px);
    }

    .mld-card-simple-price {
        font-size: var(--ds-text-lg, 18px);
    }
}

/* Responsive - Mobile */
@media (max-width: 768px) {
    .mld-card-simple-address span:first-child {
        font-size: var(--ds-text-sm, 14px);
    }

    .mld-card-simple-specs {
        font-size: var(--ds-text-xs, 12px);
        gap: var(--ds-space-1, 4px);
    }
}