/* Apartment Building Popup Styles */
.apartment-popup .leaflet-popup-content-wrapper {
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    border: 1px solid #e9ecef;
    max-width: min(320px, calc(100vw - 40px)) !important;
    min-width: min(280px, calc(100vw - 40px)) !important;
    width: auto !important;
}

.apartment-popup .leaflet-popup-content {
    margin: 12px 18px;
    line-height: 1.4;
    max-width: 100%;
    overflow: hidden;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.apartment-building-popup .suite-selector {
    transition: all 0.2s ease;
    font-weight: 500;
    border: 2px solid #e9ecef;
    background: white;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 12px;
    padding: 8px 32px 8px 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.apartment-building-popup .suite-selector:hover {
    border-color: #ff6b35;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.15);
}

.apartment-building-popup .suite-selector:focus {
    outline: none;
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

.apartment-building-popup .suite-content {
    transition: all 0.3s ease;
    max-width: 100%;
    overflow: hidden;
    box-sizing: border-box;
}

.apartment-building-popup .suite-details {
    animation: fadeIn 0.3s ease;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* General apartment popup container constraints */
.apartment-building-popup {
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
}

.apartment-building-popup * {
    box-sizing: border-box;
    max-width: 100%;
}

/* Specific text overflow handling */
.apartment-building-popup select option {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.apartment-building-popup .suite-details > div,
.apartment-building-popup.app-data .unit-details > div {
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

/* Allow long addresses to wrap */
.apartment-building-popup .building-header > div > div:first-child > div:first-child {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}

.apartment-building-popup .building-header {
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
    margin: -12px -18px 16px -18px !important;
    padding: 16px 20px !important;
    background: linear-gradient(135deg, #ff6b35, #f7931e);
    color: white;
    border-radius: 8px 8px 0 0;
    position: relative;
    left: 0;
    right: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.apartment-building-popup.app-data .building-header {
    background: linear-gradient(135deg, #a02c8d, #ba6cdf) !important;
}

.apartment-building-popup button {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-wrap: break-word;
    white-space: normal;
}

/* Ensure dropdown options don't cause overflow */
.apartment-building-popup select option {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile-specific Leaflet popup positioning fixes */
@media (max-width: 768px) {
    .leaflet-popup {
        max-width: calc(100vw - 20px) !important;
    }
    
    .leaflet-popup-content-wrapper {
        max-width: 100% !important;
        overflow: hidden;
    }
    
    .leaflet-popup-content {
        max-width: 100% !important;
        overflow: hidden;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Ensure popups don't go off-screen on mobile */
    .leaflet-popup-pane {
        pointer-events: none;
    }
    
    .leaflet-popup {
        pointer-events: auto;
        margin: 0 10px;
    }
}

@media (max-width: 480px) {
    .leaflet-popup {
        max-width: calc(100vw - 15px) !important;
        margin: 0 7px;
    }
}

@media (max-width: 320px) {
    .leaflet-popup {
        max-width: calc(100vw - 10px) !important;
        margin: 0 5px;
    }
}

/* Additional mobile button fixes for ultra-small screens */
@media (max-width: 280px) {
    .apartment-building-popup.app-data .unit-details div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 2px !important;
    }
    
    .apartment-building-popup.app-data .unit-details button {
        flex: none !important;
        width: 100% !important;
        min-width: unset !important;
        margin-bottom: 2px;
    }
    
    .apartment-building-popup button {
        font-size: 8px !important;
        padding: 3px 5px !important;
        line-height: 1.2;
    }
    
    .apartment-building-popup .suite-selector,
    .apartment-building-popup.app-data .unit-selector {
        font-size: 8px !important;
        padding: 4px 18px 4px 4px !important;
    }
}

/* Prevent text selection on popup elements for better mobile UX */
.apartment-building-popup {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.apartment-building-popup input,
.apartment-building-popup select,
.apartment-building-popup textarea {
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}
