/**
 * Texas IDX Plugin Styles - Complete Version
 */

/* Container and Layout */
.mdg-reso-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

.mdg-reso-results {
    width: 100%;
}

/* Modern Compact Search Form */
.mdg-reso-search-form {
    margin-bottom: 30px;
}

.mdg-reso-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-radius: 50px;
    transition: box-shadow 0.3s ease;
}


.mdg-search-input {
    flex: 1;
    min-width: 200px;
    max-width: 300px;
    padding: 10px 18px;
    border: none;
    background: #f8f8f8;
    border-radius: 20px;
    font-size: 14px;
    color: #333;
    outline: none;
    transition: background 0.2s ease;
}

.mdg-search-input:focus {
    background: #f0f0f0;
}

.mdg-search-input::placeholder {
    color: #999;
}

/* Custom Filter Dropdowns */
.mdg-custom-filter {
    position: relative;
}

.mdg-filter-trigger {
    padding: 10px 16px;
    border: 1px solid #e0e0e0;
    background: #fff;
    border-radius: 24px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
    outline: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    box-sizing: border-box;
}

.mdg-filter-trigger .filter-label {
    font-size: 13px;
    color: #333;
}

.mdg-filter-trigger .filter-arrow {
    font-size: 10px;
    color: #666;
    transition: transform 0.3s ease;
    margin-left: 2px;
}

.mdg-custom-filter.active .mdg-filter-trigger .filter-arrow {
    transform: rotate(180deg);
}

.mdg-filter-trigger:hover {
    background: #f0f0f0;
    border: 1px solid #999;
    color: #333;
}

.mdg-custom-filter.active .mdg-filter-trigger {
    background: #e8e8e8;
    border: 1px solid #999;
}

.mdg-custom-filter.active .mdg-filter-trigger:hover {
    background: #ddd;
    border: 1px solid #888;
    color: #333;
}

/* Filter Panels */
.mdg-filter-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 1000;
    min-width: 280px;
    display: none;
}

.mdg-custom-filter.active .mdg-filter-panel {
    display: block;
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-panel-header {
    font-size: 14px;
    font-weight: 600;
    color: #222;
    margin-bottom: 16px;
}

/* Price Range Slider */
.price-range-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
}

.price-value {
    flex: 1;
    padding: 10px 14px;
    background: #f8f8f8;
    border-radius: 8px;
    text-align: center;
}

.price-min-display,
.price-max-display {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.price-separator {
    color: #999;
    font-weight: 300;
}

.slider-container {
    position: relative;
    height: 40px;
    margin-bottom: 8px;
}

.price-slider {
    position: absolute;
    width: 100%;
    height: 6px;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    outline: none;
    pointer-events: none;
}

.price-slider::-webkit-slider-track {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
}

.price-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #333;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.price-slider::-moz-range-track {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
}

.price-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #333;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    pointer-events: all;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.price-slider:hover::-webkit-slider-thumb {
    background: #000;
}

.price-slider:hover::-moz-range-thumb {
    background: #000;
}

.filter-panel-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* Number Options (Beds/Baths) */
.number-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.number-option {
    padding: 12px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    text-align: center;
    box-sizing: border-box;
}

.number-option:hover {
    border: 2px solid #ccc;
    background: #f8f8f8;
    color: #666;
}

.number-option.active {
    border: 2px solid #333;
    background: #333;
    color: #fff;
}

.number-option.active:hover {
    border: 2px solid #000;
    background: #000;
    color: #fff;
}

/* Type Options */
.type-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.type-option {
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    background: #fff;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    text-align: left;
    box-sizing: border-box;
}

.type-option:hover {
    border: 2px solid #ccc;
    background: #f8f8f8;
    color: #666;
}

.type-option.active {
    border: 2px solid #333;
    background: #333;
    color: #fff;
}

.type-option.active:hover {
    border: 2px solid #000;
    background: #000;
    color: #fff;
}

.mdg-search-btn {
    padding: 10px 28px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.mdg-search-btn:hover {
    background: #555;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.mdg-search-reset {
    padding: 10px 16px;
    background: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.mdg-search-reset .reset-icon {
    font-size: 16px;
    font-weight: 300;
    line-height: 1;
}

.mdg-search-reset:hover {
    background: #e8e8e8;
    color: #333;
    border: 1px solid #ddd !important;
    padding: 10px 16px !important;
    font-weight: 500;
}

/* Spacer to push map toggle to the end */
.mdg-search-spacer {
    flex: 1;
    min-width: 20px;
}

/* Map Toggle Inline in Search Bar */
.mdg-map-toggle-inline {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.mdg-reso-search-bar .mdg-map-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f5f5f5;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mdg-reso-search-bar .mdg-map-toggle-wrapper:hover {
    background: #e8e8e8;
}

.mdg-reso-search-bar .mdg-map-toggle-label {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    order: 2;
}

.mdg-reso-search-bar .mdg-map-toggle-switch {
    width: 40px;
    height: 22px;
    background-color: #ddd;
    border-radius: 22px;
    transition: background-color 0.3s ease;
    order: 1;
}

.mdg-reso-search-bar .mdg-map-toggle-switch::before {
    width: 16px;
    height: 16px;
    top: 3px;
    left: 3px;
    transition: transform 0.3s ease;
}

.mdg-reso-search-bar .mdg-map-toggle-input:checked + .mdg-map-toggle-switch {
    background-color: #4CAF50;
}

.mdg-reso-search-bar .mdg-map-toggle-input:checked + .mdg-map-toggle-switch::before {
    transform: translateX(18px);
}

/* Grid Layout - FIXED */
.mdg-reso-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 30px;
    width: 100%;
}

.mdg-reso-grid.mdg-reso-cols-1 {
    grid-template-columns: 1fr;
}

.mdg-reso-grid.mdg-reso-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.mdg-reso-grid.mdg-reso-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.mdg-reso-grid.mdg-reso-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}

.mdg-reso-grid.mdg-reso-cols-5 {
    grid-template-columns: repeat(5, 1fr);
}

.mdg-reso-grid.mdg-reso-cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

.mdg-reso-grid.mdg-reso-cols-7 {
    grid-template-columns: repeat(7, 1fr);
}

.mdg-reso-grid.mdg-reso-cols-8 {
    grid-template-columns: repeat(8, 1fr);
}

/* Property Card - FIXED */
.mdg-reso-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mdg-reso-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.mdg-reso-card-image {
    position: relative;
    width: 100%;
    padding-bottom: 66.67%; /* 3:2 Aspect Ratio */
    overflow: hidden;
    background: #f0f0f0;
}

.mdg-reso-card-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.mdg-reso-card:hover .mdg-reso-card-image img {
    transform: scale(1.05);
}

.mdg-reso-no-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
    color: #999;
}


.mdg-reso-photo-count {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
}

/* Status Badge */
.mdg-reso-status-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 10;
}

/* Status colors based on MLS status */
.mdg-reso-status-active {
    background: #27ae60;
    color: white;
}

.mdg-reso-status-pending {
    background: #f39c12;
    color: white;
}

.mdg-reso-status-sold,
.mdg-reso-status-closed {
    background: #e74c3c;
    color: white;
}

.mdg-reso-status-coming-soon,
.mdg-reso-status-active-under-contract {
    background: #3498db;
    color: white;
}

.mdg-reso-status-expired,
.mdg-reso-status-withdrawn,
.mdg-reso-status-canceled,
.mdg-reso-status-cancelled {
    background: #95a5a6;
    color: white;
}

.mdg-reso-status-hold {
    background: #9b59b6;
    color: white;
}

/* Overlay Card Layout */
.mdg-reso-card-overlay .mdg-reso-card-image {
    position: relative;
}

.mdg-reso-card-overlay .mdg-reso-card-image::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70%;
    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%, rgba(0,0,0,0.85) 100%);
    pointer-events: none;
    z-index: 1;
}

.mdg-reso-card-overlay .mdg-reso-card-details {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: transparent;
    z-index: 2;
    color: #ffffff;
}

.mdg-reso-card-overlay .mdg-reso-price,
.mdg-reso-card-overlay .mdg-reso-address,
.mdg-reso-card-overlay .mdg-reso-features,
.mdg-reso-card-overlay .mdg-reso-features span {
    color: #ffffff !important;
}

.mdg-reso-card-overlay .mdg-reso-status-badge,
.mdg-reso-card-overlay .mdg-reso-photo-count {
    z-index: 3;
}

/* Standard Card Layout (default) */
.mdg-reso-card-details {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.mdg-reso-price {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.mdg-reso-address {
    font-size: 16px;
    color: #333;
    margin-bottom: 5px;
    font-weight: 400;
    line-height: 1.4;
}

.mdg-reso-city {
    font-size: 14px;
    color: #666;
    margin-bottom: 15px;
}

.mdg-reso-features {
    display: flex;
    gap: 15px;
    padding-top: 5px;
    flex-wrap: wrap;
}

.mdg-reso-feature {
    font-size: 14px;
    color: #555;
    white-space: nowrap;
}

.mdg-reso-feature strong {
    font-weight: 600;
}

.mdg-reso-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

/* Buttons */
.mdg-reso-btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: 100%;
}

.mdg-reso-btn-primary,
.mdg-reso-btn.mdg-reso-btn-primary {
    background: #3498db;
    color: white;
}

.mdg-reso-btn-primary:hover,
.mdg-reso-btn.mdg-reso-btn-primary:hover {
    background: #2980b9;
    color: white;
    text-decoration: none;
}

.mdg-reso-btn-secondary {
    background: #95a5a6;
    color: white;
}

.mdg-reso-btn-secondary:hover {
    background: #7f8c8d;
    color: white;
}

/* List View */
.mdg-reso-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
}

.mdg-reso-row {
    display: flex;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
    cursor: pointer;
}

.mdg-reso-row:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.mdg-reso-row-image {
    width: 300px;
    flex-shrink: 0;
    position: relative;
    background: #f0f0f0;
}

.mdg-reso-row-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mdg-reso-row-details {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.mdg-reso-row-info {
    flex: 1;
}

.mdg-reso-row-actions {
    padding-top: 15px;
    border-top: 1px solid #eee;
}

/* Pagination */
.mdg-reso-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.mdg-reso-page {
    display: inline-block;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.mdg-reso-page:hover {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.mdg-reso-page.current {
    background: #3498db;
    color: white;
    border-color: #3498db;
    font-weight: bold;
}

.mdg-reso-prev,
.mdg-reso-next {
    background: #3498db;
    color: white;
    border: none;
    font-weight: 600;
}

.mdg-reso-prev:hover,
.mdg-reso-next:hover {
    background: #2980b9;
    border: none;
}

/* Loading State */
.mdg-reso-loading {
    text-align: center;
    padding: 40px;
}

.mdg-reso-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.mdg-reso-error {
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    color: #c00;
}

.mdg-reso-no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

/* Map Toggle Switch */
.mdg-view-toggle {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

/* When inside search form */
.mdg-reso-search-form .mdg-view-toggle {
    padding-top: 20px;
    margin-top: 20px;
    margin-bottom: 0;
    border-top: 1px solid #e0e0e0;
}

/* When standalone (no search form) */
.mdg-reso-container > .mdg-view-toggle {
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 20px;
}

.mdg-map-toggle-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.mdg-map-toggle-label {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.mdg-map-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.mdg-map-toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    background-color: #ccc;
    border-radius: 28px;
    transition: background-color 0.3s ease;
}

.mdg-map-toggle-switch::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: white;
    top: 3px;
    left: 3px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.mdg-map-toggle-input:checked + .mdg-map-toggle-switch {
    background-color: #4CAF50;
}

.mdg-map-toggle-input:checked + .mdg-map-toggle-switch::before {
    transform: translateX(24px);
}

.mdg-map-toggle-input:focus + .mdg-map-toggle-switch {
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

.mdg-map-toggle-wrapper:hover .mdg-map-toggle-switch {
    background-color: #b3b3b3;
}

.mdg-map-toggle-wrapper:hover .mdg-map-toggle-input:checked + .mdg-map-toggle-switch {
    background-color: #45a049;
}

/* Map Container */
#mdg-listings-map,
#mdg-property-map {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#mdg-listings-map {
    display: none;
    height: 600px;
    margin-bottom: 20px;
}

.mdg-reso-container.map-view #mdg-listings-map {
    display: block;
}

/* Split-Screen Map View */
.mdg-reso-map-view-split {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.mdg-reso-map-view-listings {
    flex: 1;
    min-width: 0; /* Prevent flex item from overflowing */
}

.mdg-reso-map-view-map {
    flex: 1;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    height: calc(100vh - 40px); /* Full height minus top (20px) and bottom (20px) gaps */
}

.mdg-reso-map-view-map #mdg-listings-map {
    display: block;
    height: 100%;
    margin-bottom: 0;
}

/* Map Info Window */
.mdg-map-info-window {
    max-width: 250px;
}

.mdg-map-info-window img {
    width: 100%;
    border-radius: 4px;
    margin-bottom: 10px;
}

.mdg-map-info-window h4 {
    color: #2c3e50;
    margin: 10px 0 5px 0;
}

.mdg-map-info-window .mdg-reso-btn {
    margin-top: 10px;
    padding: 8px 16px;
    font-size: 14px;
}

/* Responsive Design for Grid */
@media (max-width: 1600px) {
    .mdg-reso-grid.mdg-reso-cols-8,
    .mdg-reso-grid.mdg-reso-cols-7 {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .mdg-reso-grid.mdg-reso-cols-6,
    .mdg-reso-grid.mdg-reso-cols-5 {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .mdg-reso-grid.mdg-reso-cols-8,
    .mdg-reso-grid.mdg-reso-cols-7,
    .mdg-reso-grid.mdg-reso-cols-6,
    .mdg-reso-grid.mdg-reso-cols-5,
    .mdg-reso-grid.mdg-reso-cols-4 {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .mdg-reso-grid.mdg-reso-cols-8,
    .mdg-reso-grid.mdg-reso-cols-7,
    .mdg-reso-grid.mdg-reso-cols-6,
    .mdg-reso-grid.mdg-reso-cols-5,
    .mdg-reso-grid.mdg-reso-cols-4,
    .mdg-reso-grid.mdg-reso-cols-3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Tablet - custom filters 2 per row */
    .mdg-custom-filter {
        flex: 1 1 calc(50% - 4px);
        min-width: 140px;
    }
    
    .mdg-filter-panel {
        left: 50%;
        transform: translateX(-50%);
        min-width: 280px;
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .mdg-reso-search-fields {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mdg-reso-grid.mdg-reso-cols-2,
    .mdg-reso-grid.mdg-reso-cols-3,
    .mdg-reso-grid.mdg-reso-cols-4,
    .mdg-reso-grid.mdg-reso-cols-5,
    .mdg-reso-grid.mdg-reso-cols-6,
    .mdg-reso-grid.mdg-reso-cols-7,
    .mdg-reso-grid.mdg-reso-cols-8 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .mdg-reso-row {
        flex-direction: column;
    }
    
    .mdg-reso-row-image {
        width: 100%;
        height: 200px;
    }
    
    #mdg-listings-map {
        height: 400px !important;
    }
    
    .mdg-view-toggle {
        text-align: center;
    }
    
    /* Stack split-screen on mobile */
    .mdg-reso-map-view-split {
        flex-direction: column;
    }
    
    .mdg-reso-map-view-map {
        position: relative;
        top: 0;
        height: 400px;
        max-height: none;
        order: -1; /* Show map first on mobile */
        width: 100%;
    }
}

@media (max-width: 576px) {
    .mdg-reso-grid.mdg-reso-cols-2,
    .mdg-reso-grid.mdg-reso-cols-3,
    .mdg-reso-grid.mdg-reso-cols-4,
    .mdg-reso-grid.mdg-reso-cols-5,
    .mdg-reso-grid.mdg-reso-cols-6,
    .mdg-reso-grid.mdg-reso-cols-7,
    .mdg-reso-grid.mdg-reso-cols-8 {
        grid-template-columns: 1fr;
    }
    .mdg-reso-search-field {
        min-width: 0;
        width: 100%;
    }
    .mdg-reso-features {
        flex-direction: column;
        gap: 8px;
    }
    .mdg-reso-search-actions .mdg-reso-btn {
        padding: 12px 6px;
        font-size: 14px;
    }
    
    .mdg-reso-feature {
        display: flex;
        justify-content: space-between;
    }
    
    /* Responsive search bar - stack on mobile */
    .mdg-reso-search-bar {
        flex-wrap: wrap;
        border-radius: 20px;
        padding: 8px;
    }
    
    .mdg-search-input {
        width: 100%;
        min-width: unset;
        max-width: unset;
        margin-bottom: 8px;
    }
    
    /* Custom filters on mobile */
    .mdg-custom-filter {
        flex: 1 1 calc(50% - 4px);
        min-width: 120px;
        margin-bottom: 8px;
    }
    
    .mdg-filter-trigger {
        width: 100%;
        justify-content: space-between;
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .mdg-filter-trigger .filter-label {
        font-size: 12px;
    }
    
    .mdg-filter-panel {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        min-width: 300px;
        max-width: calc(100vw - 32px);
        width: auto;
        padding: 16px;
    }
    
    /* Price range on mobile */
    .price-range-display {
        flex-direction: row;
        gap: 8px;
    }
    
    .price-value {
        padding: 8px 10px;
    }
    
    .price-min-display,
    .price-max-display {
        font-size: 13px;
    }
    
    /* Number and type options on mobile */
    .number-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .number-option {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .type-option {
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .filter-panel-header {
        font-size: 13px;
        margin-bottom: 12px;
    }
    
    .mdg-search-btn {
        width: 100%;
        margin-top: 8px;
    }
    
    .mdg-search-reset {
        width: 100%;
        margin-top: 8px;
        margin-left: 0;
    }
    
    /* Mobile Overlay Card Improvements */
    .mdg-reso-card-overlay .mdg-reso-photo-count {
        top: 10px;
        right: 10px;
        bottom: auto;
        left: auto;
    }
    
    .mdg-reso-card-overlay .mdg-reso-features {
        display: flex;
        flex-direction: row;
        gap: 12px;
        justify-content: flex-start;
    }
    
    .mdg-reso-card-overlay .mdg-reso-feature {
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 2px;
        white-space: nowrap;
    }
    
    .mdg-reso-card-overlay .mdg-reso-feature strong {
        font-size: 16px;
        order: -1;
    }

}

/* Print Styles */
@media print {
    .mdg-reso-search-form,
    .mdg-reso-pagination,
    .mdg-view-toggle,
    #mdg-listings-map {
        display: none !important;
    }
    
    .mdg-reso-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* Single Property Page */
.mdg-reso-single {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.mdg-reso-property-wrapper {
    background: white;
}

/* Gallery Styles */
.mdg-reso-gallery {
    margin-bottom: 30px;
    max-width: 100%;
}

/* Full-Width Gallery */
.mdg-reso-gallery-fullwidth {
    width: 100vw;
    max-width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    margin-top: 0;
    margin-bottom: 40px;
    position: relative;
    padding: 0;
}

.mdg-reso-gallery-fullwidth .mdg-reso-gallery-main {
    border-radius: 0;
    height: 600px;
    max-height: 600px;
}

.mdg-reso-gallery-fullwidth .mdg-reso-thumbnails-wrapper {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.mdg-reso-gallery-main {
    position: relative;
    width: 100%;
    max-height: 600px;
    background: #f0f0f0;
    margin-bottom: 10px;
    overflow: hidden;
    border-radius: 8px;
}

.mdg-reso-gallery-main img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.mdg-reso-gallery-main.no-image {
    height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mdg-reso-no-image-placeholder {
    text-align: center;
    color: #999;
}

.mdg-reso-gallery-counter {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 14px;
}

/* Thumbnails wrapper with navigation */
.mdg-reso-thumbnails-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 15px;
}

.mdg-reso-thumb-nav {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.mdg-reso-thumb-nav:hover {
    background: #fff;
    border-color: #3498db;
    color: #3498db;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mdg-reso-thumb-nav:active {
    transform: scale(0.95);
}

.mdg-reso-thumb-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.mdg-reso-gallery-thumbnails {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px 0;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    flex: 1;
    /* Hide scrollbar for cleaner look */
    scrollbar-width: thin;
}

/* Custom scrollbar styling - thin and subtle */
.mdg-reso-gallery-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.mdg-reso-gallery-thumbnails::-webkit-scrollbar-track {
    background: transparent;
}

.mdg-reso-gallery-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.mdg-reso-gallery-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.4);
}

/* Hide scrollbar completely on mobile for cleaner look */
@media (max-width: 768px) {
    .mdg-reso-gallery-thumbnails::-webkit-scrollbar {
        display: none;
    }
    .mdg-reso-gallery-thumbnails {
        -ms-overflow-style: none;  /* IE and Edge */
        scrollbar-width: none;  /* Firefox */
    }
}

.mdg-reso-thumbnail {
    position: relative;
    flex: 0 0 120px; /* Fixed width, no grow/shrink */
    height: 90px; /* Fixed height for 4:3 aspect ratio */
    background: #f0f0f0;
    cursor: pointer;
    overflow: hidden;
    border-radius: 4px;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.mdg-reso-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mdg-reso-thumbnail:hover {
    border-color: #3498db;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.mdg-reso-thumbnail.active {
    border-color: #3498db;
}

/* Property Header */
.mdg-reso-property-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
}

.mdg-reso-property-title h1 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 28px;
}

.mdg-reso-property-address {
    font-size: 18px;
    color: #666;
    margin-bottom: 5px;
}

.mdg-reso-property-mls {
    font-size: 14px;
    color: #999;
}

.mdg-reso-property-price-box {
    text-align: right;
}

.mdg-reso-property-price {
    font-size: 36px;
    font-weight: bold;
    color: #27ae60;
}

.mdg-reso-price-per-sqft {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

/* Key Features Bar */
.mdg-reso-property-key-features {
    display: flex;
    gap: 20px;
    padding: 20px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 30px;
    justify-content: space-around;
}

.mdg-reso-key-feature {
    text-align: center;
    flex: 1;
}

.mdg-reso-key-feature-value {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
    display: block;
    margin-bottom: 5px;
}

.mdg-reso-key-feature-label {
    font-size: 14px;
    color: #666;
}

/* Content Grid */
.mdg-reso-property-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 30px;
    margin-top: 30px;
}

.mdg-reso-property-main {
    min-width: 0;
}

/* Property Sections */
.mdg-reso-property-section {
    background: white;
    padding: 25px;
    margin-bottom: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.mdg-reso-property-section h2 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 24px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.mdg-reso-property-description {
    color: #333;
    line-height: 1.8;
    font-size: 16px;
}

/* Details Grid */
.mdg-reso-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
}

.mdg-reso-detail-group {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 6px;
}

.mdg-reso-detail-group h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    font-weight: 600;
}

.mdg-reso-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.mdg-reso-detail-row:last-child {
    border-bottom: none;
}

.mdg-reso-detail-label {
    font-weight: 500;
    color: #666;
    font-size: 14px;
}

.mdg-reso-detail-value {
    color: #333;
    font-size: 14px;
    text-align: right;
    font-weight: 500;
}

/* Features Grid */
.mdg-reso-features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 25px;
}

.mdg-reso-feature-group h3 {
    margin: 0 0 10px 0;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}

.mdg-reso-feature-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.mdg-reso-feature-list li {
    padding: 6px 0;
    color: #333;
    font-size: 14px;
    border-bottom: 1px solid #f0f0f0;
}

.mdg-reso-feature-list li:last-child {
    border-bottom: none;
}

.mdg-reso-feature-list li:before {
    content: "✓";
    color: #27ae60;
    margin-right: 8px;
}

/* Sidebar */
.mdg-reso-property-sidebar {
    position: sticky;
    top: 20px;
    height: fit-content;
}

.mdg-reso-sidebar-card {
    background: white;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.mdg-reso-sidebar-card h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 18px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.mdg-reso-agent-info {
    padding: 10px 0;
}

.mdg-reso-agent-name {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.mdg-reso-agent-office {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.mdg-reso-agent-phone a {
    color: #3498db;
    text-decoration: none;
    font-size: 14px;
}

.mdg-reso-agent-phone a:hover {
    text-decoration: underline;
}

/* Property Map */
#mdg-property-map {
    width: 100%;
    height: 400px;
    border-radius: 8px;
    overflow: hidden;
}

/* Responsive Design for Single Property */
@media (max-width: 1024px) {
    .mdg-reso-property-content {
        grid-template-columns: 1fr;
    }
    
    .mdg-reso-property-sidebar {
        position: static;
    }
    
    .mdg-reso-details-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .mdg-reso-property-header {
        flex-direction: column;
    }
    
    .mdg-reso-property-price-box {
        text-align: left;
    }
    
    .mdg-reso-property-key-features {
        flex-wrap: wrap;
    }
    
    .mdg-reso-key-feature {
        flex: 1 1 45%;
        margin-bottom: 10px;
    }
    
    .mdg-reso-thumbnail {
        flex: 0 0 100px; /* Smaller thumbnails on mobile */
        height: 75px;
    }
    
    .mdg-reso-thumb-nav {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }
    
    .mdg-reso-features-grid {
        grid-template-columns: 1fr;
    }
}

/* Lightbox Styles */
.mdg-lightbox {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    overflow: hidden;
}

.mdg-lightbox-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mdg-lightbox-image {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    user-select: none;
    animation: mdgLightboxZoom 0.3s ease;
}

@keyframes mdgLightboxZoom {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.mdg-lightbox-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #fff;
    font-size: 50px;
    font-weight: 300;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 100001;
    line-height: 1;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
}

.mdg-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.mdg-lightbox-prev,
.mdg-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    color: #fff;
    font-size: 60px;
    font-weight: 300;
    cursor: pointer;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    transition: all 0.3s ease;
    z-index: 100001;
    line-height: 1;
    border-radius: 4px;
}

.mdg-lightbox-prev:hover,
.mdg-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.mdg-lightbox-prev {
    left: 20px;
}

.mdg-lightbox-next {
    right: 20px;
}

.mdg-lightbox-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    font-size: 18px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 20px;
    border-radius: 25px;
    z-index: 100001;
}

/* Make gallery images clickable with cursor change */
.mdg-reso-gallery-main img {
    cursor: zoom-in;
}

.mdg-reso-gallery-main img:hover {
    opacity: 0.95;
}

@media (max-width: 480px) {
    .mdg-reso-single {
        padding: 10px;
    }
    
    .mdg-reso-property-section {
        padding: 15px;
    }
    
    .mdg-reso-key-feature {
        flex: 1 1 100%;
    }
    
    .mdg-reso-gallery-main {
        max-height: 300px;
    }
    
    .mdg-lightbox-close {
        top: 10px;
        right: 10px;
        font-size: 40px;
        width: 40px;
        height: 40px;
    }
    
    .mdg-lightbox-prev,
    .mdg-lightbox-next {
        font-size: 40px;
        padding: 15px;
    }
    
    .mdg-lightbox-prev {
        left: 10px;
    }
    
    .mdg-lightbox-next {
        right: 10px;
    }
    
    .mdg-lightbox-image {
        max-width: 95%;
        max-height: 85vh;
    }
    
    .mdg-lightbox-counter {
        bottom: 20px;
        font-size: 16px;
        padding: 8px 16px;
    }
    
    /* Extra small screens - full width filters */
    .mdg-custom-filter {
        flex: 1 1 100%;
        min-width: unset;
        max-width: unset;
    }
    
    .mdg-filter-panel {
        min-width: unset;
        max-width: calc(100vw - 24px);
        padding: 14px;
    }
    
    .number-options {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }
    
    .number-option {
        padding: 10px 6px;
        font-size: 12px;
    }
    
    .type-option {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .price-value {
        padding: 8px;
    }
    
    .price-min-display,
    .price-max-display {
        font-size: 12px;
    }
    
    .filter-panel-header {
        font-size: 12px;
    }
}