/**
 * MLD Multi-Unit Modal Styles
 * Responsive modal for displaying multiple properties at the same location
 * 
 * @version 1.0.0
 */

/* Modal Overlay */
.mld-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: mldFadeIn 0.3s ease-out;
}

/* Prevent body scroll when modal is open */
body.mld-modal-open {
    overflow: hidden;
}

/* Modal Container */
.mld-modal-container {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    max-width: 1200px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: mldSlideUp 0.3s ease-out;
}

/* Modal Header */
.mld-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.mld-modal-title {
    font-size: 24px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.mld-modal-count {
    color: #3b82f6;
}

/* Close Button */
.mld-modal-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #6b7280;
    transition: all 0.2s;
    border-radius: 6px;
    margin-top: 5px;
}

.mld-modal-close:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.mld-modal-close:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Modal Body */
.mld-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

/* Property Grid */
.mld-property-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

/* Override existing card styles for modal context */
.mld-modal-body .bme-listing-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: none;
}

.mld-modal-body .bme-listing-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Remove padding-top override - use existing card image height */

/* Hide popup-specific controls in modal */
.mld-modal-body .bme-view-photos-btn,
.mld-modal-body .bme-popout-btn {
    display: none;
}

/* Ensure details section fills available space */
.mld-modal-body .bme-card-details {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Make the view details link more prominent in modal */
.mld-modal-body .bme-view-details-btn {
    display: block;
    margin-top: auto;
    text-align: center;
    padding: 8px 16px;
    background-color: #3b82f6;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

.mld-modal-body .bme-view-details-btn:hover {
    background-color: #2563eb;
    color: #fff;
}

/* Animations */
@keyframes mldFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes mldSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Mobile Styles */
@media (max-width: 768px) {
    .mld-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }
    
    .mld-modal-container {
        border-radius: 20px 20px 0 0;
        max-height: 90vh;
        width: 100%;
        max-width: none;
        animation: mldSlideUpMobile 0.3s ease-out;
    }
    
    .mld-modal-header {
        padding: 16px 20px;
        border-bottom: 1px solid #e5e7eb;
        /* Add drag handle indicator */
        position: relative;
    }
    
    .mld-modal-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background-color: #d1d5db;
        border-radius: 2px;
    }
    
    .mld-modal-title {
        font-size: 20px;
        padding-top: 12px;
    }
    
    .mld-modal-body {
        padding: 16px;
    }
    
    /* Single column on mobile */
    .mld-property-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    /* Adjust card layout for mobile */
    .mld-modal-body .bme-listing-card {
        min-height: 120px;
    }
    
    /* Make image smaller on mobile */
    .mld-modal-body .bme-card-image {
        height: 200px; /* Shorter height for mobile */
    }
    
    /* Adjust text sizes for mobile */
    .mld-modal-body .bme-card-price {
        font-size: 18px;
    }
    
    .mld-modal-body .bme-card-address {
        font-size: 13px;
    }
    
    .mld-modal-body .bme-card-specs {
        font-size: 12px;
    }
    
    .mld-modal-body .bme-card-secondary-info {
        font-size: 11px;
    }
    
    /* Smaller button on mobile */
    .mld-modal-body .bme-view-details-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    /* Touch-friendly spacing */
    .mld-modal-close {
        padding: 12px;
        margin: -4px -8px -4px 0;
    }
    
    @keyframes mldSlideUpMobile {
        from {
            transform: translateY(100%);
        }
        to {
            transform: translateY(0);
        }
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .mld-property-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Loading state */
.mld-loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* Empty state */
.mld-empty {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

/* Accessibility */
.mld-property-card:focus-within {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mld-modal-container {
        border: 2px solid #000;
    }
    
    .mld-property-card {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .mld-modal-overlay,
    .mld-modal-container,
    .mld-property-card {
        animation: none;
        transition: none;
    }
}